{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":384,"title":"Poker Series 08: IsPair","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA pair is 2 cards of the same rank (column) and the three kickers.  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next three highest cards are the kickers.  If the kickers also form a pair, or three of a kind, it is still considered a pair for the purposes of this function.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 1 0 0 0 0 0\r\n  0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a pair, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a pair\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 0 0 0 0 0 0 0 0 1 0 0\r\n  0 0 1 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 1 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 1 1 0 0 0 1 0 1\r\n  0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the pair.  If more than one pair can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same pair, return the one higher up in the matrix, same for kickers.  If the pair happens to also be a four of a kind or full house, two pair, etc.. it still meets the defintion and should be returned.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA pair is 2 cards of the same rank (column) and the three kickers.  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next three highest cards are the kickers.  If the kickers also form a pair, or three of a kind, it is still considered a pair for the purposes of this function.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 1 0 0 0 0 0\r\n0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a pair, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a pair\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 0 0 0 0 0 0 0 0 1 0 0\r\n0 0 1 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 1 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 1 1 1 0 0 0 1 0 1\r\n0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the pair.  If more than one pair can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same pair, return the one higher up in the matrix, same for kickers.  If the pair happens to also be a four of a kind or full house, two pair, etc.. it still meets the defintion and should be returned.\u003c/p\u003e","function_template":"function out = isPair(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 1 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 1 0 0 0 0 0 1 0 0 0 1 0\r\n      0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 1 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 1\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 1 1\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      1 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      1 1 0 0 0 0 0 0 0 0 0 1 1\r\n      0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n      1 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 1\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2012-02-22T19:17:35.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-22T19:17:35.000Z","updated_at":"2026-02-15T05:44:51.000Z","published_at":"2012-02-22T19:17:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA pair is 2 cards of the same rank (column) and the three kickers. The Ace (first column) is highest. The columns represent A, 2, 3, ... K. The next three highest cards are the kickers. If the kickers also form a pair, or three of a kind, it is still considered a pair for the purposes of this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 1 0 0 0 0 0\\n0 1 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a pair, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a pair\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 0 0 0 0 0 0 0 0 1 0 0\\n0 0 1 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 1 1 1 0 0 0 1 0 1\\n0 0 0 1 0 1 0 0 0 1 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the pair. If more than one pair can be made, return the higher ranking one (the one with the highest rank. Ace being the highest). If different suits are possible for the same pair, return the one higher up in the matrix, same for kickers. If the pair happens to also be a four of a kind or full house, two pair, etc.. it still meets the defintion and should be returned.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":385,"title":"Poker Series 09: IsHighCard","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nHigh Card is the five highest cards in your hand.  It is basically what you have if you don't have anything else!  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  If the kickers also form a pair, it is still considered high card for the purposes of this function.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a high card, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not (because it is defined as five cards):\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a high card\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 0 0 0 0 0 0 0 0 1 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 1 0 1 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 1 1 0 0 0 0 0 1\r\n  0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the high card.  If more than one hag card can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same high card, return the one higher up in the matrix, same for kickers.  If the high card also happens to also be a four of a kind or full house, it still meets the defintion and should be returned.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eHigh Card is the five highest cards in your hand.  It is basically what you have if you don't have anything else!  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  If the kickers also form a pair, it is still considered high card for the purposes of this function.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a high card, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not (because it is defined as five cards):\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a high card\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 0 0 0 0 0 0 0 0 1 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 1 0 0 0 1 0 1 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 1 1 0 0 0 0 0 1\r\n0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the high card.  If more than one hag card can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same high card, return the one higher up in the matrix, same for kickers.  If the high card also happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/p\u003e","function_template":"function out = isHighCard(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"clear\r\nclc\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isHighCard(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 1 0 1 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isHighCard(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 1 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isHighCard(hm),y_correct))\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isHighCard(hm),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2012-02-22T19:38:00.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-22T19:38:00.000Z","updated_at":"2026-02-15T05:43:12.000Z","published_at":"2012-02-22T19:48:08.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHigh Card is the five highest cards in your hand. It is basically what you have if you don't have anything else! The Ace (first column) is highest. The columns represent A, 2, 3, ... K. If the kickers also form a pair, it is still considered high card for the purposes of this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0\\n0 1 0 1 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a high card, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not (because it is defined as five cards):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a high card\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 0 0 0 0 0 0 0 0 1 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 1 0 0 0 1 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 1 1 0 0 0 0 0 1\\n0 0 0 1 0 1 0 0 0 1 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the high card. If more than one hag card can be made, return the higher ranking one (the one with the highest rank. Ace being the highest). If different suits are possible for the same high card, return the one higher up in the matrix, same for kickers. If the high card also happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":376,"title":"Poker Series 05: isStraight","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA straight is 5 cards of the adjacent ranks (columns) regardless of suits (rows).  The Ace (first column) is both lowest and highest.  The columns represent A, 2, 3, ... K.  This means A, K, Q, J, Ten is a straight also.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a straight, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a straight\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 0 0 0 0 0 0 0 0 1 0 0\r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n  1 0 0 0 0 1 0 0 0 0 0 1 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 0 1 0 0 0 0 0 0\r\n  0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the straight.  If more than one straight can be made, return the higher ranking one (the one with the highest top card.  Ace being the highest).  If different suits are possible for the same straight cards, return the one higher up in the matrix.  If the straight happens to also be a straight flush, it still meets the defintion and should be returned.  The highest straight should be returned, even if a straight flush can also be made.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA straight is 5 cards of the adjacent ranks (columns) regardless of suits (rows).  The Ace (first column) is both lowest and highest.  The columns represent A, 2, 3, ... K.  This means A, K, Q, J, Ten is a straight also.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a straight, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a straight\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 0 0 0 0 0 0 0 0 1 0 0\r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n1 0 0 0 0 1 0 0 0 0 0 1 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the straight.  If more than one straight can be made, return the higher ranking one (the one with the highest top card.  Ace being the highest).  If different suits are possible for the same straight cards, return the one higher up in the matrix.  If the straight happens to also be a straight flush, it still meets the defintion and should be returned.  The highest straight should be returned, even if a straight flush can also be made.\u003c/p\u003e","function_template":"function out = isStraight(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 1 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 0 1 0 1 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 1 0 0 0 0 0 0 0\r\n                               0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 1 0 0 0 0 0 0 0\r\n      0 1 0 1 0 0 0 0 0 1 0 1 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 1 0 0 0 0 0 0 0\r\n                               0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 0 0 1 0 0 0 0 0 0 0\r\n      0 1 0 1 0 0 0 0 0 1 0 1 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 1 0 0 0 0 0 0 0\r\n                               0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 1 0 0 0 0 0 0 0 1 0 0 \r\n      0 0 0 0 0 1 0 0 0 0 0 0 1\r\n      0 1 0 1 0 0 0 0 0 1 0 1 0 \r\n      1 0 0 0 1 0 0 0 0 0 0 0 1];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 1 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 1\r\n                               0 0 0 0 0 0 0 0 0 1 0 1 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":62,"test_suite_updated_at":"2012-02-21T19:24:51.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-21T19:24:51.000Z","updated_at":"2026-02-15T05:51:00.000Z","published_at":"2012-02-21T19:50:10.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA straight is 5 cards of the adjacent ranks (columns) regardless of suits (rows). The Ace (first column) is both lowest and highest. The columns represent A, 2, 3, ... K. This means A, K, Q, J, Ten is a straight also.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0\\n0 0 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a straight, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a straight\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 0 0 0 0 0 0 0 0 1 0 0\\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\n1 0 0 0 0 1 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the straight. If more than one straight can be made, return the higher ranking one (the one with the highest top card. Ace being the highest). If different suits are possible for the same straight cards, return the one higher up in the matrix. If the straight happens to also be a straight flush, it still meets the defintion and should be returned. The highest straight should be returned, even if a straight flush can also be made.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":335,"title":"Poker Series 04: isFlush","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA flush is 5 cards of the same suit (row).  If there are more than five cards in a suit to choose from, the highest five count. The Ace (first column) is the highest.  The columns represent A, 2, 3, ... K.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 1 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nrepresents a flush, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a flush\r\n\r\n  1 0 0 0 0 0 0 0 0 1 1 1 1 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 0 1 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\r\nWould be FALSE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the flush.  If more than one flush can be made, return the higher ranking one (the one with the highest top card.  Ace being the highest- ties broken by the second, third, fourth, and then fifth card).  If different suits are possible for the same flush, return the one higher up in the matrix.  If the flush happens to also be a straight flush, it still meets the defintion and should be returned.  The highest flush should be returned, even if a straight flush can also be made.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA flush is 5 cards of the same suit (row).  If there are more than five cards in a suit to choose from, the highest five count. The Ace (first column) is the highest.  The columns represent A, 2, 3, ... K.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 1 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a flush, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a flush\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 0 0 0 0 0 0 0 0 1 1 1 1 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be FALSE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the flush.  If more than one flush can be made, return the higher ranking one (the one with the highest top card.  Ace being the highest- ties broken by the second, third, fourth, and then fifth card).  If different suits are possible for the same flush, return the one higher up in the matrix.  If the flush happens to also be a straight flush, it still meets the defintion and should be returned.  The highest flush should be returned, even if a straight flush can also be made.\u003c/p\u003e","function_template":"function out = isFlush(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 1 1 0 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 1 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      1 1 0 1 0 0 0 0 1 1 1 1 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 1 1 1 1 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 1 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      1 1 0 1 0 0 0 0 1 1 1 1 0 \r\n      1 0 0 0 0 0 0 0 1 1 1 1 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 1 1 1 1 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 0 0 0 1 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 0 0 0 0 0 1 0 1 1 0 \r\n      1 0 0 0 0 0 0 0 1 1 0 1 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":69,"test_suite_updated_at":"2012-02-21T19:24:06.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-17T21:55:47.000Z","updated_at":"2026-04-02T20:50:40.000Z","published_at":"2012-02-21T19:24:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA flush is 5 cards of the same suit (row). If there are more than five cards in a suit to choose from, the highest five count. The Ace (first column) is the highest. The columns represent A, 2, 3, ... K.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 1 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a flush, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a flush\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 0 0 0 0 0 0 0 0 1 1 1 1 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be FALSE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the flush. If more than one flush can be made, return the higher ranking one (the one with the highest top card. Ace being the highest- ties broken by the second, third, fourth, and then fifth card). If different suits are possible for the same flush, return the one higher up in the matrix. If the flush happens to also be a straight flush, it still meets the defintion and should be returned. The highest flush should be returned, even if a straight flush can also be made.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":329,"title":"Poker Series 01: isStraightFlush","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n--------\r\nA straight flush is 5 cards of the same suit (row) and five continuous ranks (columns). The Ace (first column) can also make a straight flush when combined with the last four columns. The columns represent A, 2, 3, ... K.\r\nThis hand matrix:\r\n0 1 1 1 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\nrepresents a straight flush, so the return value from the function is TRUE.\r\nThis hand matrix does not:\r\n0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\nso the return value should be FALSE.\r\nThis hand matrix does represent a straight flush\r\n1 0 0 0 0 0 0 0 0 1 1 1 1 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\nWould be FALSE for this function.\r\nA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Straight Flush. If more than one straight flush can be made, return the higher ranking one (the one with the highest top card. Ace being the highest). If different suits are possible for the same straight flush, return the one higher up in the matrix.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 940.933px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 470.467px; transform-origin: 407px 470.467px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 373px 8px; transform-origin: 373px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 373px 8px; transform-origin: 373px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e--------\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 369.5px 8px; transform-origin: 369.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA straight flush is 5 cards of the same suit (row) and five continuous ranks (columns). The Ace (first column) can also make a straight flush when combined with the last four columns. The columns represent A, 2, 3, ... K.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 54px 8px; transform-origin: 54px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis hand matrix:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 1 1 1 1 1 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 230.5px 8px; transform-origin: 230.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003erepresents a straight flush, so the return value from the function is TRUE.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 83.5px 8px; transform-origin: 83.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis hand matrix does not:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 1 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 118px 8px; transform-origin: 118px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eso the return value should be FALSE.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 150.5px 8px; transform-origin: 150.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis hand matrix does represent a straight flush\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e1 0 0 0 0 0 0 0 0 1 1 1 1 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 1 0 0 0 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 221.5px 8px; transform-origin: 221.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 1 0 1 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 1 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 106px 8px; transform-origin: 106px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWould be FALSE for this function.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 370px 8px; transform-origin: 370px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Straight Flush. If more than one straight flush can be made, return the higher ranking one (the one with the highest top card. Ace being the highest). If different suits are possible for the same straight flush, return the one higher up in the matrix.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function out = isStraightFlush(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 1 1 1 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 1 1 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isStraightFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0\r\n      0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isStraightFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 0 0 0 0 0 0 0 0 1 1 1 1\r\n      0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 1 1 1 1\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isStraightFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 0 0 0 0 0 0 0 0 1 1 1 1\r\n      1 1 0 0 0 0 0 0 0 1 1 1 1 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 1 1 1 1\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isStraightFlush(hm),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":8,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":124,"test_suite_updated_at":"2021-09-27T06:47:34.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-16T20:30:55.000Z","updated_at":"2026-04-02T20:19:31.000Z","published_at":"2012-02-17T18:24:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA straight flush is 5 cards of the same suit (row) and five continuous ranks (columns). The Ace (first column) can also make a straight flush when combined with the last four columns. The columns represent A, 2, 3, ... K.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 1 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a straight flush, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a straight flush\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 0 0 0 0 0 0 0 0 1 1 1 1 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be FALSE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Straight Flush. If more than one straight flush can be made, return the higher ranking one (the one with the highest top card. Ace being the highest). If different suits are possible for the same straight flush, return the one higher up in the matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":377,"title":"Poker Series 06: isThreeKind","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA three of a kind is 3 cards of the same rank (column).  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next two highest cards are the kickers.  If the kickers also form a pair, it is still considered three of a kind for the purposes of this function.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a three of a kind, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a three of a kind\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 0 0 0 0 0 0 0 0 1 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 1 0 1 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 1 1 0 0 0 0 0 1\r\n  0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind.  If more than one three of a kind can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same three of a kind cards, return the one higher up in the matrix, same for kickers.  If the three of a kind happens to also be a four of a kind or full house, it still meets the defintion and should be returned.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA three of a kind is 3 cards of the same rank (column).  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next two highest cards are the kickers.  If the kickers also form a pair, it is still considered three of a kind for the purposes of this function.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a three of a kind, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a three of a kind\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 0 0 0 0 0 0 0 0 1 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 1 0 0 0 1 0 1 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 1 1 0 0 0 0 0 1\r\n0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind.  If more than one three of a kind can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same three of a kind cards, return the one higher up in the matrix, same for kickers.  If the three of a kind happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/p\u003e","function_template":"function out = isThreeKind(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 1 1 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0\r\n      1 0 0 1 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 0 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      1 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 0 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      1 0 0 1 0 0 0 0 1 0 0 0 1 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 1];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      1 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2012-02-21T21:50:59.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-21T21:17:05.000Z","updated_at":"2026-02-15T05:49:06.000Z","published_at":"2012-02-22T17:26:53.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA three of a kind is 3 cards of the same rank (column). The Ace (first column) is highest. The columns represent A, 2, 3, ... K. The next two highest cards are the kickers. If the kickers also form a pair, it is still considered three of a kind for the purposes of this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0\\n0 1 0 1 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a three of a kind, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a three of a kind\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 0 0 0 0 0 0 0 0 1 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 1 0 0 0 1 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 1 1 0 0 0 0 0 1\\n0 0 0 1 0 1 0 0 0 1 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind. If more than one three of a kind can be made, return the higher ranking one (the one with the highest rank. Ace being the highest). If different suits are possible for the same three of a kind cards, return the one higher up in the matrix, same for kickers. If the three of a kind happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":334,"title":"Poker Series 03: isFullHouse","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA full house is three cards of one rank (column) and two cards of a different rank.  The Ace (first column) is the highest rank.  The columns represent A, 2, 3, ... K.  When there is a choice between two possible three of a kind, choose the higher.  Once a three of a kind is choosen, choose the highest possible pair.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 0 0 0 1 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 0 0 1 0 0 0 0 0\r\n\r\nrepresents a full house, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\n  0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a full house\r\n\r\n  1 0 1 0 0 0 0 0 0 0 1 0 1 \r\n  0 0 1 0 0 1 0 0 0 0 0 0 0\r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 0 1 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\r\nWould be FALSE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand Matrix, but it only shows the cards used to make the full house.  If more than one full house can be made, return the higher ranking one (the one with the highest ranking three of a kind.  Ace being the highest.  Ties are broken with the highest ranking pair).  If different suits are possible for the same full house, return the ones higher up in the matrix.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA full house is three cards of one rank (column) and two cards of a different rank.  The Ace (first column) is the highest rank.  The columns represent A, 2, 3, ... K.  When there is a choice between two possible three of a kind, choose the higher.  Once a three of a kind is choosen, choose the highest possible pair.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 0 0 0 1 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 0 0 1 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a full house, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 0 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a full house\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 0 1 0 0 0 0 0 0 0 1 0 1 \r\n0 0 1 0 0 1 0 0 0 0 0 0 0\r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be FALSE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand Matrix, but it only shows the cards used to make the full house.  If more than one full house can be made, return the higher ranking one (the one with the highest ranking three of a kind.  Ace being the highest.  Ties are broken with the highest ranking pair).  If different suits are possible for the same full house, return the ones higher up in the matrix.\u003c/p\u003e","function_template":"function out = isFullHouse(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 1 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 1 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 1 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 1 0 0 0 0 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 1 0 0 0 0 0 0 1 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 1 0 0 0 1 1 0 1 1 \r\n      1 1 0 0 1 0 0 0 0 0 0 0 0\r\n      1 0 0 1 1 0 0 0 0 0 0 0 0 \r\n      1 1 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 1 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 1 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 1 0 0 0 1 0 0 0 0 0 1 0\r\n      0 0 0 1 0 1 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 1 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 1 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 1 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":71,"test_suite_updated_at":"2012-02-17T21:20:39.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-17T21:20:39.000Z","updated_at":"2026-04-02T20:43:08.000Z","published_at":"2012-02-17T21:54:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA full house is three cards of one rank (column) and two cards of a different rank. The Ace (first column) is the highest rank. The columns represent A, 2, 3, ... K. When there is a choice between two possible three of a kind, choose the higher. Once a three of a kind is choosen, choose the highest possible pair.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 0 0 0 1 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 1 0 0 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 0 0 1 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a full house, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 0 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\n0 0 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a full house\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 0 1 0 0 0 0 0 0 0 1 0 1 \\n0 0 1 0 0 1 0 0 0 0 0 0 0\\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be FALSE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the full house. If more than one full house can be made, return the higher ranking one (the one with the highest ranking three of a kind. Ace being the highest. Ties are broken with the highest ranking pair). If different suits are possible for the same full house, return the ones higher up in the matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":333,"title":"Poker Series 02: isQuads","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nFour of a kind is four cards of the same rank (column) and the highest other card as a 'kicker'.  The columns represent A, 2, 3, ... K in the input.  Aces are high.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 0 0 0 0 0 0 0 0\r\nrepresents quads, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\n  0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent quads\r\n\r\n  1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n  1 0 0 0 0 0 0 0 0 0 0 0 0\r\n  1 0 1 0 0 0 0 0 0 1 0 0 0 \r\n  1 0 0 0 0 1 0 0 0 0 0 0 0\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 0 1 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\nWould be FALSE for this function.\r\n\r\nA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Quads plus kicker. If more than one Quads can be made, return the higher ranking one (Ace being the highest). If different suits are possible for the kicker, return the one higher up in the matrix.\r\n\r\n","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eFour of a kind is four cards of the same rank (column) and the highest other card as a 'kicker'.  The columns represent A, 2, 3, ... K in the input.  Aces are high.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 0 1 0 0 0 0 0 0 0 \r\n0 1 0 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 0 0 0 0 0 0 0 0\r\nrepresents quads, so the return value from the function is TRUE.\r\n\u003c/pre\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\nso the return value should be FALSE.\r\n\u003c/pre\u003e\u003cp\u003eThis hand matrix does represent quads\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n1 0 0 0 0 0 0 0 0 0 0 0 0\r\n1 0 1 0 0 0 0 0 0 1 0 0 0 \r\n1 0 0 0 0 1 0 0 0 0 0 0 0\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\nWould be FALSE for this function.\r\n\u003c/pre\u003e\u003cp\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Quads plus kicker. If more than one Quads can be made, return the higher ranking one (Ace being the highest). If different suits are possible for the kicker, return the one higher up in the matrix.\u003c/p\u003e","function_template":"function out = isQuads(hm)\r\n  out.flag = false;\r\n  out.usedCards = false(4,13)\r\nend","test_suite":"%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [1 0 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 1 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [1 0 0 1 0 0 0 0 1 0 0 0 1 \r\n      0 0 0 1 0 0 0 0 1 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 1 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\n hm = [1 0 0 0 0 0 0 1 0 0 0 0 0\r\n       1 0 0 0 0 0 0 1 0 0 0 0 1\r\n       1 0 0 0 0 0 0 1 0 0 0 0 0\r\n       1 0 0 0 0 0 0 1 0 0 0 0 0];\r\n \r\ny_correct.flag = true; \r\ny_correct.usedCards = logical(...\r\n      [1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n       1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       1 0 0 0 0 0 0 0 0 0 0 0 0]);\r\n   \r\nassert(isequal(isQuads(hm),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":"2016-12-13T18:48:26.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-17T18:21:26.000Z","updated_at":"2026-04-02T20:32:11.000Z","published_at":"2012-02-17T21:02:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFour of a kind is four cards of the same rank (column) and the highest other card as a 'kicker'. The columns represent A, 2, 3, ... K in the input. Aces are high.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 0 1 0 0 0 0 0 0 0 \\n0 1 0 0 0 0 0 0 0 0 0 0 0\\n0 1 0 0 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 0 0 0 0 0 0 0 0\\nrepresents quads, so the return value from the function is TRUE.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\n0 0 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\nso the return value should be FALSE.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent quads\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 0 0 0 0 0 0 0 0 0 0 0 1 \\n1 0 0 0 0 0 0 0 0 0 0 0 0\\n1 0 1 0 0 0 0 0 0 1 0 0 0 \\n1 0 0 0 0 1 0 0 0 0 0 0 0\\nRemember, hand matrices can contain any number of 1's from 0 to 52.\\n\\n0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\nWould be FALSE for this function.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Quads plus kicker. If more than one Quads can be made, return the higher ranking one (Ace being the highest). If different suits are possible for the kicker, return the one higher up in the matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":386,"title":"Poker Series 10: bestHand","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nFind the best hand using the definitions from earlier in this series.\r\n\r\nout.code is:\r\n\r\n# Straight Flush\r\n# Quads\r\n# Full House\r\n# Flush\r\n# Straight\r\n# Three of a kind\r\n# Two pair\r\n# Pair\r\n# High Card\r\n# No valid Hand\r\n\r\nout.cardsUsed is the same as is returned from the functions defined earlier for each type of hand.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a three of a kind, so the return code is 6.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eFind the best hand using the definitions from earlier in this series.\u003c/p\u003e\u003cp\u003eout.code is:\u003c/p\u003e\u003col\u003e\u003cli\u003eStraight Flush\u003c/li\u003e\u003cli\u003eQuads\u003c/li\u003e\u003cli\u003eFull House\u003c/li\u003e\u003cli\u003eFlush\u003c/li\u003e\u003cli\u003eStraight\u003c/li\u003e\u003cli\u003eThree of a kind\u003c/li\u003e\u003cli\u003eTwo pair\u003c/li\u003e\u003cli\u003ePair\u003c/li\u003e\u003cli\u003eHigh Card\u003c/li\u003e\u003cli\u003eNo valid Hand\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eout.cardsUsed is the same as is returned from the functions defined earlier for each type of hand.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a three of a kind, so the return code is 6.\u003c/p\u003e","function_template":"function out = bestPokerHand(hm)\r\n\r\nout.code      = 10;\r\nout.usedCards = false(4,13); ","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.code = 10;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 0 0 0 1 0 0 0 0 0 0 1 0\r\n      0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 1 0 0 0];\r\n\r\ny_correct.code = 9;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 0 0 0 1 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 1 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.code = 8;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 1 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 1 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.code = 7;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 1 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 1 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 0 0 0 0 0 1 0 0 0 0 0 0\r\n      0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 1 0 0 0 0 1 0];\r\n\r\ny_correct.code = 6;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 0 0 0 0 0 1 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 1 0 0 0 0 1 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      1 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 1 1 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.code = 5;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 1 1 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.code = 4;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 0 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 1 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.code = 3;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 1 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 1 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.code = 2;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 1 1 1 1 1 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.code = 1;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 1 1 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":18,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":44,"test_suite_updated_at":"2016-12-13T18:56:05.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-22T20:58:19.000Z","updated_at":"2026-02-15T04:18:26.000Z","published_at":"2012-02-22T20:58:26.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the best hand using the definitions from earlier in this series.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eout.code is:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStraight Flush\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eQuads\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFull House\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFlush\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStraight\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThree of a kind\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTwo pair\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePair\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHigh Card\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNo valid Hand\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eout.cardsUsed is the same as is returned from the functions defined earlier for each type of hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0\\n0 1 0 1 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a three of a kind, so the return code is 6.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":383,"title":"Poker Series 07: IsTwoPair","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA two pair is two pairs of cards of the same rank (column).  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next highest card is the kicker.  If the kicker also form three of a kind with a pair, it is still considered two pair for the purposes of this function.  Four of a kind is still two pair also.  (I got two pair, a pair of Aces and another Pair of Aces!)\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 1 0 0 0\r\n  0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 1 0 0 1 0 0 0 0\r\n\r\nrepresents a two pair, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a two pair\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 1 0 0 0 0 0 0 0 1 0 1\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 1 0 0 1 1 1 0 0 0 0 1 0\r\n  0 1 0 1 0 0 0 0 0 1 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind.  If more than one two pair can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same pair, return the ones higher up in the matrix, same for kickers.  If the two pair happens to also be a four of a kind or full house, it still meets the defintion and should be returned.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA two pair is two pairs of cards of the same rank (column).  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next highest card is the kicker.  If the kicker also form three of a kind with a pair, it is still considered two pair for the purposes of this function.  Four of a kind is still two pair also.  (I got two pair, a pair of Aces and another Pair of Aces!)\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 1 0 0 0\r\n0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 1 1 0 0 1 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a two pair, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a two pair\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 1 0 0 0 0 0 0 0 1 0 1\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n0 1 0 0 1 1 1 0 0 0 0 1 0\r\n0 1 0 1 0 0 0 0 0 1 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind.  If more than one two pair can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same pair, return the ones higher up in the matrix, same for kickers.  If the two pair happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/p\u003e","function_template":"function out = isTwoPair(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 1 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 0 0 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      1 0 0 1 0 0 0 0 1 1 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 1 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 1 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 1 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 0 0 \r\n      0 1 0 0 0 0 0 0 0 1 0 0 0\r\n      1 0 0 1 0 0 0 0 1 1 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 1 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 1 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 0 0 \r\n      0 1 0 0 0 0 0 0 0 1 0 0 0\r\n      1 0 0 1 0 0 0 0 1 1 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 1 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 1 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 1 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0\r\n      1 0 0 0 0 0 0 0 0 1 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2012-02-22T17:28:05.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-22T17:28:05.000Z","updated_at":"2026-02-15T05:47:26.000Z","published_at":"2012-02-22T17:28:08.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA two pair is two pairs of cards of the same rank (column). The Ace (first column) is highest. The columns represent A, 2, 3, ... K. The next highest card is the kicker. If the kicker also form three of a kind with a pair, it is still considered two pair for the purposes of this function. Four of a kind is still two pair also. (I got two pair, a pair of Aces and another Pair of Aces!)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 1 0 0 0\\n0 1 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 1 1 0 0 1 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a two pair, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a two pair\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 1 0 0 0 0 0 0 0 1 0 1\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 1 0 0 0 0 0 0 0 \\n0 1 0 0 1 1 1 0 0 0 0 1 0\\n0 1 0 1 0 0 0 0 0 1 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind. If more than one two pair can be made, return the higher ranking one (the one with the highest rank. Ace being the highest). If different suits are possible for the same pair, return the ones higher up in the matrix, same for kickers. If the two pair happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":391,"title":"Poker Series 11: selectBestHand","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nSelect the best hand using the definitions from earlier in this series.\r\n\r\n  out.hm{1} = cards used from the first hand matrix;\r\n  out.hm{2} = cards used from the second hand matrix;   \r\n  out.winner = 1,2 or zero for a tie;\r\n\r\n\r\nStandard poker ranks apply: Straight flush is best, high card is worst, with many gradations within each rank.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eSelect the best hand using the definitions from earlier in this series.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eout.hm{1} = cards used from the first hand matrix;\r\nout.hm{2} = cards used from the second hand matrix;   \r\nout.winner = 1,2 or zero for a tie;\r\n\u003c/pre\u003e\u003cp\u003eStandard poker ranks apply: Straight flush is best, high card is worst, with many gradations within each rank.\u003c/p\u003e","function_template":"function out = selectBestHand(hm1, hm2)\r\n\r\n%winner is 1,2 or 0 is tie, even if both have no valid hand\r\n\r\nout.hm{1}  = false(4,13);\r\nout.hm{2}  = false(4,13);\r\nout.winner = 0;","test_suite":"%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 0;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 2;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 1 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 1 0 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 1;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 1 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 1 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 1;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 1;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n\r\n%%\r\nhm1 = [1 1 1 1 1 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 1 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\nom1 = [1 1 1 1 1 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 1;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n\r\n%%\r\nhm1 = [1 1 1 1 1 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 1 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\nom1 = [1 1 1 1 1 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [1 1 1 1 1 1 0 0 0 0 0 1 1 \r\n       0 0 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 1 1 1 1 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 2;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n\r\n%%\r\nhm1 = [0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 0 0 0 1 1 0 0 0 0 0 1 1 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 0 0 0 1 0 0 0 0 0 0 1 1 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 2;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 1 0 0 0 0 1 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 0 0 0 0 0 1 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 2;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":16,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":37,"test_suite_updated_at":"2016-12-13T18:59:04.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-23T16:55:58.000Z","updated_at":"2026-02-15T04:12:40.000Z","published_at":"2012-02-23T20:20:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSelect the best hand using the definitions from earlier in this series.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[out.hm{1} = cards used from the first hand matrix;\\nout.hm{2} = cards used from the second hand matrix;   \\nout.winner = 1,2 or zero for a tie;]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStandard poker ranks apply: Straight flush is best, high card is worst, with many gradations within each rank.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":384,"title":"Poker Series 08: IsPair","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA pair is 2 cards of the same rank (column) and the three kickers.  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next three highest cards are the kickers.  If the kickers also form a pair, or three of a kind, it is still considered a pair for the purposes of this function.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 1 0 0 0 0 0\r\n  0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a pair, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a pair\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 0 0 0 0 0 0 0 0 1 0 0\r\n  0 0 1 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 1 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 1 1 0 0 0 1 0 1\r\n  0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the pair.  If more than one pair can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same pair, return the one higher up in the matrix, same for kickers.  If the pair happens to also be a four of a kind or full house, two pair, etc.. it still meets the defintion and should be returned.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA pair is 2 cards of the same rank (column) and the three kickers.  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next three highest cards are the kickers.  If the kickers also form a pair, or three of a kind, it is still considered a pair for the purposes of this function.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 1 0 0 0 0 0\r\n0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a pair, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a pair\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 0 0 0 0 0 0 0 0 1 0 0\r\n0 0 1 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 1 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 1 1 1 0 0 0 1 0 1\r\n0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the pair.  If more than one pair can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same pair, return the one higher up in the matrix, same for kickers.  If the pair happens to also be a four of a kind or full house, two pair, etc.. it still meets the defintion and should be returned.\u003c/p\u003e","function_template":"function out = isPair(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 1 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 1 0 0 0 0 0 1 0 0 0 1 0\r\n      0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 1 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 1\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 1 1\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      1 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n      1 1 0 0 0 0 0 0 0 0 0 1 1\r\n      0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n      1 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 1\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isPair(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2012-02-22T19:17:35.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-22T19:17:35.000Z","updated_at":"2026-02-15T05:44:51.000Z","published_at":"2012-02-22T19:17:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA pair is 2 cards of the same rank (column) and the three kickers. The Ace (first column) is highest. The columns represent A, 2, 3, ... K. The next three highest cards are the kickers. If the kickers also form a pair, or three of a kind, it is still considered a pair for the purposes of this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 1 0 0 0 0 0\\n0 1 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a pair, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a pair\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 0 0 0 0 0 0 0 0 1 0 0\\n0 0 1 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 1 1 1 0 0 0 1 0 1\\n0 0 0 1 0 1 0 0 0 1 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the pair. If more than one pair can be made, return the higher ranking one (the one with the highest rank. Ace being the highest). If different suits are possible for the same pair, return the one higher up in the matrix, same for kickers. If the pair happens to also be a four of a kind or full house, two pair, etc.. it still meets the defintion and should be returned.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":385,"title":"Poker Series 09: IsHighCard","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nHigh Card is the five highest cards in your hand.  It is basically what you have if you don't have anything else!  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  If the kickers also form a pair, it is still considered high card for the purposes of this function.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a high card, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not (because it is defined as five cards):\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a high card\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 0 0 0 0 0 0 0 0 1 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 1 0 1 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 1 1 0 0 0 0 0 1\r\n  0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the high card.  If more than one hag card can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same high card, return the one higher up in the matrix, same for kickers.  If the high card also happens to also be a four of a kind or full house, it still meets the defintion and should be returned.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eHigh Card is the five highest cards in your hand.  It is basically what you have if you don't have anything else!  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  If the kickers also form a pair, it is still considered high card for the purposes of this function.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a high card, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not (because it is defined as five cards):\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a high card\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 0 0 0 0 0 0 0 0 1 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 1 0 0 0 1 0 1 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 1 1 0 0 0 0 0 1\r\n0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the high card.  If more than one hag card can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same high card, return the one higher up in the matrix, same for kickers.  If the high card also happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/p\u003e","function_template":"function out = isHighCard(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"clear\r\nclc\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isHighCard(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 1 0 1 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isHighCard(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 1 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isHighCard(hm),y_correct))\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isHighCard(hm),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2012-02-22T19:38:00.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-22T19:38:00.000Z","updated_at":"2026-02-15T05:43:12.000Z","published_at":"2012-02-22T19:48:08.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHigh Card is the five highest cards in your hand. It is basically what you have if you don't have anything else! The Ace (first column) is highest. The columns represent A, 2, 3, ... K. If the kickers also form a pair, it is still considered high card for the purposes of this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0\\n0 1 0 1 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a high card, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not (because it is defined as five cards):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a high card\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 0 0 0 0 0 0 0 0 1 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 1 0 0 0 1 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 1 1 0 0 0 0 0 1\\n0 0 0 1 0 1 0 0 0 1 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the high card. If more than one hag card can be made, return the higher ranking one (the one with the highest rank. Ace being the highest). If different suits are possible for the same high card, return the one higher up in the matrix, same for kickers. If the high card also happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":376,"title":"Poker Series 05: isStraight","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA straight is 5 cards of the adjacent ranks (columns) regardless of suits (rows).  The Ace (first column) is both lowest and highest.  The columns represent A, 2, 3, ... K.  This means A, K, Q, J, Ten is a straight also.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a straight, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a straight\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 0 0 0 0 0 0 0 0 1 0 0\r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n  1 0 0 0 0 1 0 0 0 0 0 1 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 0 1 0 0 0 0 0 0\r\n  0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the straight.  If more than one straight can be made, return the higher ranking one (the one with the highest top card.  Ace being the highest).  If different suits are possible for the same straight cards, return the one higher up in the matrix.  If the straight happens to also be a straight flush, it still meets the defintion and should be returned.  The highest straight should be returned, even if a straight flush can also be made.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA straight is 5 cards of the adjacent ranks (columns) regardless of suits (rows).  The Ace (first column) is both lowest and highest.  The columns represent A, 2, 3, ... K.  This means A, K, Q, J, Ten is a straight also.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a straight, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a straight\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 0 0 0 0 0 0 0 0 1 0 0\r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n1 0 0 0 0 1 0 0 0 0 0 1 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the straight.  If more than one straight can be made, return the higher ranking one (the one with the highest top card.  Ace being the highest).  If different suits are possible for the same straight cards, return the one higher up in the matrix.  If the straight happens to also be a straight flush, it still meets the defintion and should be returned.  The highest straight should be returned, even if a straight flush can also be made.\u003c/p\u003e","function_template":"function out = isStraight(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 1 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 0 1 0 1 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 1 0 0 0 0 0 0 0\r\n                               0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 1 0 0 0 0 0 0 0\r\n      0 1 0 1 0 0 0 0 0 1 0 1 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 1 0 0 0 0 0 0 0\r\n                               0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 0 0 1 0 0 0 0 0 0 0\r\n      0 1 0 1 0 0 0 0 0 1 0 1 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 1 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 1 0 0 0 0 0 0 0\r\n                               0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 1 0 0 0 0 0 0 0 1 0 0 \r\n      0 0 0 0 0 1 0 0 0 0 0 0 1\r\n      0 1 0 1 0 0 0 0 0 1 0 1 0 \r\n      1 0 0 0 1 0 0 0 0 0 0 0 1];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 1 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 1\r\n                               0 0 0 0 0 0 0 0 0 1 0 1 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isStraight(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":62,"test_suite_updated_at":"2012-02-21T19:24:51.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-21T19:24:51.000Z","updated_at":"2026-02-15T05:51:00.000Z","published_at":"2012-02-21T19:50:10.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA straight is 5 cards of the adjacent ranks (columns) regardless of suits (rows). The Ace (first column) is both lowest and highest. The columns represent A, 2, 3, ... K. This means A, K, Q, J, Ten is a straight also.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0\\n0 0 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a straight, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a straight\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 0 0 0 0 0 0 0 0 1 0 0\\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\n1 0 0 0 0 1 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the straight. If more than one straight can be made, return the higher ranking one (the one with the highest top card. Ace being the highest). If different suits are possible for the same straight cards, return the one higher up in the matrix. If the straight happens to also be a straight flush, it still meets the defintion and should be returned. The highest straight should be returned, even if a straight flush can also be made.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":335,"title":"Poker Series 04: isFlush","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA flush is 5 cards of the same suit (row).  If there are more than five cards in a suit to choose from, the highest five count. The Ace (first column) is the highest.  The columns represent A, 2, 3, ... K.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 1 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nrepresents a flush, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a flush\r\n\r\n  1 0 0 0 0 0 0 0 0 1 1 1 1 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 0 1 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\r\nWould be FALSE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the flush.  If more than one flush can be made, return the higher ranking one (the one with the highest top card.  Ace being the highest- ties broken by the second, third, fourth, and then fifth card).  If different suits are possible for the same flush, return the one higher up in the matrix.  If the flush happens to also be a straight flush, it still meets the defintion and should be returned.  The highest flush should be returned, even if a straight flush can also be made.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA flush is 5 cards of the same suit (row).  If there are more than five cards in a suit to choose from, the highest five count. The Ace (first column) is the highest.  The columns represent A, 2, 3, ... K.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 1 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a flush, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a flush\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 0 0 0 0 0 0 0 0 1 1 1 1 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be FALSE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the flush.  If more than one flush can be made, return the higher ranking one (the one with the highest top card.  Ace being the highest- ties broken by the second, third, fourth, and then fifth card).  If different suits are possible for the same flush, return the one higher up in the matrix.  If the flush happens to also be a straight flush, it still meets the defintion and should be returned.  The highest flush should be returned, even if a straight flush can also be made.\u003c/p\u003e","function_template":"function out = isFlush(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 1 1 0 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 1 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      1 1 0 1 0 0 0 0 1 1 1 1 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 1 1 1 1 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 1 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      1 1 0 1 0 0 0 0 1 1 1 1 0 \r\n      1 0 0 0 0 0 0 0 1 1 1 1 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 1 1 1 1 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 0 0 0 1 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 0 0 0 0 0 1 0 1 1 0 \r\n      1 0 0 0 0 0 0 0 1 1 0 1 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isFlush(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":69,"test_suite_updated_at":"2012-02-21T19:24:06.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-17T21:55:47.000Z","updated_at":"2026-04-02T20:50:40.000Z","published_at":"2012-02-21T19:24:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA flush is 5 cards of the same suit (row). If there are more than five cards in a suit to choose from, the highest five count. The Ace (first column) is the highest. The columns represent A, 2, 3, ... K.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 1 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a flush, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a flush\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 0 0 0 0 0 0 0 0 1 1 1 1 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be FALSE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the flush. If more than one flush can be made, return the higher ranking one (the one with the highest top card. Ace being the highest- ties broken by the second, third, fourth, and then fifth card). If different suits are possible for the same flush, return the one higher up in the matrix. If the flush happens to also be a straight flush, it still meets the defintion and should be returned. The highest flush should be returned, even if a straight flush can also be made.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":329,"title":"Poker Series 01: isStraightFlush","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n--------\r\nA straight flush is 5 cards of the same suit (row) and five continuous ranks (columns). The Ace (first column) can also make a straight flush when combined with the last four columns. The columns represent A, 2, 3, ... K.\r\nThis hand matrix:\r\n0 1 1 1 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\nrepresents a straight flush, so the return value from the function is TRUE.\r\nThis hand matrix does not:\r\n0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\nso the return value should be FALSE.\r\nThis hand matrix does represent a straight flush\r\n1 0 0 0 0 0 0 0 0 1 1 1 1 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\nWould be FALSE for this function.\r\nA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Straight Flush. If more than one straight flush can be made, return the higher ranking one (the one with the highest top card. Ace being the highest). If different suits are possible for the same straight flush, return the one higher up in the matrix.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 940.933px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 470.467px; transform-origin: 407px 470.467px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 373px 8px; transform-origin: 373px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 373px 8px; transform-origin: 373px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 63px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e--------\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 369.5px 8px; transform-origin: 369.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA straight flush is 5 cards of the same suit (row) and five continuous ranks (columns). The Ace (first column) can also make a straight flush when combined with the last four columns. The columns represent A, 2, 3, ... K.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 54px 8px; transform-origin: 54px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis hand matrix:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 1 1 1 1 1 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 230.5px 8px; transform-origin: 230.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003erepresents a straight flush, so the return value from the function is TRUE.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 83.5px 8px; transform-origin: 83.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis hand matrix does not:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 1 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 118px 8px; transform-origin: 118px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eso the return value should be FALSE.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 150.5px 8px; transform-origin: 150.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis hand matrix does represent a straight flush\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e1 0 0 0 0 0 0 0 0 1 1 1 1 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 1 0 0 0 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 221.5px 8px; transform-origin: 221.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 1 0 1 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 104px 8.5px; tab-size: 4; transform-origin: 104px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 0 0 0 0 0 0 0 0 0 0 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e0 0 1 0 0 0 0 0 0 0 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 106px 8px; transform-origin: 106px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWould be FALSE for this function.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 370px 8px; transform-origin: 370px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Straight Flush. If more than one straight flush can be made, return the higher ranking one (the one with the highest top card. Ace being the highest). If different suits are possible for the same straight flush, return the one higher up in the matrix.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function out = isStraightFlush(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 1 1 1 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 1 1 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isStraightFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0\r\n      0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isStraightFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 0 0 0 0 0 0 0 0 1 1 1 1\r\n      0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 1 1 1 1\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isStraightFlush(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 0 0 0 0 0 0 0 0 1 1 1 1\r\n      1 1 0 0 0 0 0 0 0 1 1 1 1 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 1 1 1 1\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isStraightFlush(hm),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":8,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":124,"test_suite_updated_at":"2021-09-27T06:47:34.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-16T20:30:55.000Z","updated_at":"2026-04-02T20:19:31.000Z","published_at":"2012-02-17T18:24:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA straight flush is 5 cards of the same suit (row) and five continuous ranks (columns). The Ace (first column) can also make a straight flush when combined with the last four columns. The columns represent A, 2, 3, ... K.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 1 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a straight flush, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a straight flush\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 0 0 0 0 0 0 0 0 1 1 1 1 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be FALSE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Straight Flush. If more than one straight flush can be made, return the higher ranking one (the one with the highest top card. Ace being the highest). If different suits are possible for the same straight flush, return the one higher up in the matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":377,"title":"Poker Series 06: isThreeKind","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA three of a kind is 3 cards of the same rank (column).  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next two highest cards are the kickers.  If the kickers also form a pair, it is still considered three of a kind for the purposes of this function.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a three of a kind, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a three of a kind\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 0 0 0 0 0 0 0 0 1 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 1 0 1 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 1 1 0 0 0 0 0 1\r\n  0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind.  If more than one three of a kind can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same three of a kind cards, return the one higher up in the matrix, same for kickers.  If the three of a kind happens to also be a four of a kind or full house, it still meets the defintion and should be returned.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA three of a kind is 3 cards of the same rank (column).  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next two highest cards are the kickers.  If the kickers also form a pair, it is still considered three of a kind for the purposes of this function.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a three of a kind, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a three of a kind\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 0 0 0 0 0 0 0 0 1 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 1 0 0 0 1 0 1 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 1 1 0 0 0 0 0 1\r\n0 0 0 1 0 1 0 0 0 1 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind.  If more than one three of a kind can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same three of a kind cards, return the one higher up in the matrix, same for kickers.  If the three of a kind happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/p\u003e","function_template":"function out = isThreeKind(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 1 1 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0\r\n      1 0 0 1 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 0 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      1 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 0 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      1 0 0 1 0 0 0 0 1 0 0 0 1 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 1];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n\r\n%%\r\nhm = [1 1 0 0 0 0 0 0 1 1 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      1 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isThreeKind(hm),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2012-02-21T21:50:59.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-21T21:17:05.000Z","updated_at":"2026-02-15T05:49:06.000Z","published_at":"2012-02-22T17:26:53.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA three of a kind is 3 cards of the same rank (column). The Ace (first column) is highest. The columns represent A, 2, 3, ... K. The next two highest cards are the kickers. If the kickers also form a pair, it is still considered three of a kind for the purposes of this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0\\n0 1 0 1 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a three of a kind, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a three of a kind\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 0 0 0 0 0 0 0 0 1 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 1 0 0 0 1 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 1 1 0 0 0 0 0 1\\n0 0 0 1 0 1 0 0 0 1 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind. If more than one three of a kind can be made, return the higher ranking one (the one with the highest rank. Ace being the highest). If different suits are possible for the same three of a kind cards, return the one higher up in the matrix, same for kickers. If the three of a kind happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":334,"title":"Poker Series 03: isFullHouse","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA full house is three cards of one rank (column) and two cards of a different rank.  The Ace (first column) is the highest rank.  The columns represent A, 2, 3, ... K.  When there is a choice between two possible three of a kind, choose the higher.  Once a three of a kind is choosen, choose the highest possible pair.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 0 0 0 1 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 0 0 1 0 0 0 0 0\r\n\r\nrepresents a full house, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\n  0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a full house\r\n\r\n  1 0 1 0 0 0 0 0 0 0 1 0 1 \r\n  0 0 1 0 0 1 0 0 0 0 0 0 0\r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 0 1 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\r\nWould be FALSE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand Matrix, but it only shows the cards used to make the full house.  If more than one full house can be made, return the higher ranking one (the one with the highest ranking three of a kind.  Ace being the highest.  Ties are broken with the highest ranking pair).  If different suits are possible for the same full house, return the ones higher up in the matrix.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA full house is three cards of one rank (column) and two cards of a different rank.  The Ace (first column) is the highest rank.  The columns represent A, 2, 3, ... K.  When there is a choice between two possible three of a kind, choose the higher.  Once a three of a kind is choosen, choose the highest possible pair.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 0 0 0 1 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 0 0 1 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a full house, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 0 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a full house\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 0 1 0 0 0 0 0 0 0 1 0 1 \r\n0 0 1 0 0 1 0 0 0 0 0 0 0\r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be FALSE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand Matrix, but it only shows the cards used to make the full house.  If more than one full house can be made, return the higher ranking one (the one with the highest ranking three of a kind.  Ace being the highest.  Ties are broken with the highest ranking pair).  If different suits are possible for the same full house, return the ones higher up in the matrix.\u003c/p\u003e","function_template":"function out = isFullHouse(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 1 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 1 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 1 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 1 0 0 0 0 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 1 0 0 0 0 0 0 1 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 1 0 0 0 1 1 0 1 1 \r\n      1 1 0 0 1 0 0 0 0 0 0 0 0\r\n      1 0 0 1 1 0 0 0 0 0 0 0 0 \r\n      1 1 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 1 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 1 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      1 1 0 0 0 1 0 0 0 0 0 1 0\r\n      0 0 0 1 0 1 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 1 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 1 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 1 0 0 0 0 0 0 0])\r\nassert(isequal(isFullHouse(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":71,"test_suite_updated_at":"2012-02-17T21:20:39.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-17T21:20:39.000Z","updated_at":"2026-04-02T20:43:08.000Z","published_at":"2012-02-17T21:54:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA full house is three cards of one rank (column) and two cards of a different rank. The Ace (first column) is the highest rank. The columns represent A, 2, 3, ... K. When there is a choice between two possible three of a kind, choose the higher. Once a three of a kind is choosen, choose the highest possible pair.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 0 0 0 1 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 1 0 0 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 0 0 1 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a full house, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 0 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\n0 0 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a full house\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 0 1 0 0 0 0 0 0 0 1 0 1 \\n0 0 1 0 0 1 0 0 0 0 0 0 0\\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be FALSE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the full house. If more than one full house can be made, return the higher ranking one (the one with the highest ranking three of a kind. Ace being the highest. Ties are broken with the highest ranking pair). If different suits are possible for the same full house, return the ones higher up in the matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":333,"title":"Poker Series 02: isQuads","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nFour of a kind is four cards of the same rank (column) and the highest other card as a 'kicker'.  The columns represent A, 2, 3, ... K in the input.  Aces are high.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 0 0 0 0 0 0 0 0\r\nrepresents quads, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\n  0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 1 0 0 0 0 0 0 0 0 0\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent quads\r\n\r\n  1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n  1 0 0 0 0 0 0 0 0 0 0 0 0\r\n  1 0 1 0 0 0 0 0 0 1 0 0 0 \r\n  1 0 0 0 0 1 0 0 0 0 0 0 0\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 0 1 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0 \r\nWould be FALSE for this function.\r\n\r\nA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Quads plus kicker. If more than one Quads can be made, return the higher ranking one (Ace being the highest). If different suits are possible for the kicker, return the one higher up in the matrix.\r\n\r\n","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eFour of a kind is four cards of the same rank (column) and the highest other card as a 'kicker'.  The columns represent A, 2, 3, ... K in the input.  Aces are high.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 0 1 0 0 0 0 0 0 0 \r\n0 1 0 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 0 0 0 0 0 0 0 0\r\nrepresents quads, so the return value from the function is TRUE.\r\n\u003c/pre\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\n0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n0 0 0 1 0 0 0 0 0 0 0 0 0\r\nso the return value should be FALSE.\r\n\u003c/pre\u003e\u003cp\u003eThis hand matrix does represent quads\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n1 0 0 0 0 0 0 0 0 0 0 0 0\r\n1 0 1 0 0 0 0 0 0 1 0 0 0 \r\n1 0 0 0 0 1 0 0 0 0 0 0 0\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 1 0 1 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0 \r\nWould be FALSE for this function.\r\n\u003c/pre\u003e\u003cp\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Quads plus kicker. If more than one Quads can be made, return the higher ranking one (Ace being the highest). If different suits are possible for the kicker, return the one higher up in the matrix.\u003c/p\u003e","function_template":"function out = isQuads(hm)\r\n  out.flag = false;\r\n  out.usedCards = false(4,13)\r\nend","test_suite":"%%\r\nhm = [0 0 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [1 0 0 0 0 0 0 0 1 0 0 0 1 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 1 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\nhm = [1 0 0 1 0 0 0 0 1 0 0 0 1 \r\n      0 0 0 1 0 0 0 0 1 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 1 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([1 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\nassert(isequal(isQuads(hm),y_correct))\r\n\r\n%%\r\n hm = [1 0 0 0 0 0 0 1 0 0 0 0 0\r\n       1 0 0 0 0 0 0 1 0 0 0 0 1\r\n       1 0 0 0 0 0 0 1 0 0 0 0 0\r\n       1 0 0 0 0 0 0 1 0 0 0 0 0];\r\n \r\ny_correct.flag = true; \r\ny_correct.usedCards = logical(...\r\n      [1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       1 0 0 0 0 0 0 0 0 0 0 0 1 \r\n       1 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       1 0 0 0 0 0 0 0 0 0 0 0 0]);\r\n   \r\nassert(isequal(isQuads(hm),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":"2016-12-13T18:48:26.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-17T18:21:26.000Z","updated_at":"2026-04-02T20:32:11.000Z","published_at":"2012-02-17T21:02:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFour of a kind is four cards of the same rank (column) and the highest other card as a 'kicker'. The columns represent A, 2, 3, ... K in the input. Aces are high.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 0 1 0 0 0 0 0 0 0 \\n0 1 0 0 0 0 0 0 0 0 0 0 0\\n0 1 0 0 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 0 0 0 0 0 0 0 0\\nrepresents quads, so the return value from the function is TRUE.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\n0 0 0 1 0 0 0 0 0 0 0 0 0 \\n0 0 0 1 0 0 0 0 0 0 0 0 0\\nso the return value should be FALSE.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent quads\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1 0 0 0 0 0 0 0 0 0 0 0 1 \\n1 0 0 0 0 0 0 0 0 0 0 0 0\\n1 0 1 0 0 0 0 0 0 1 0 0 0 \\n1 0 0 0 0 1 0 0 0 0 0 0 0\\nRemember, hand matrices can contain any number of 1's from 0 to 52.\\n\\n0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 1 0 1 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0 \\nWould be FALSE for this function.]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand Matrix, but it only shows the cards used to make the Quads plus kicker. If more than one Quads can be made, return the higher ranking one (Ace being the highest). If different suits are possible for the kicker, return the one higher up in the matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":386,"title":"Poker Series 10: bestHand","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nFind the best hand using the definitions from earlier in this series.\r\n\r\nout.code is:\r\n\r\n# Straight Flush\r\n# Quads\r\n# Full House\r\n# Flush\r\n# Straight\r\n# Three of a kind\r\n# Two pair\r\n# Pair\r\n# High Card\r\n# No valid Hand\r\n\r\nout.cardsUsed is the same as is returned from the functions defined earlier for each type of hand.\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 0 0\r\n  0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n  0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nrepresents a three of a kind, so the return code is 6.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eFind the best hand using the definitions from earlier in this series.\u003c/p\u003e\u003cp\u003eout.code is:\u003c/p\u003e\u003col\u003e\u003cli\u003eStraight Flush\u003c/li\u003e\u003cli\u003eQuads\u003c/li\u003e\u003cli\u003eFull House\u003c/li\u003e\u003cli\u003eFlush\u003c/li\u003e\u003cli\u003eStraight\u003c/li\u003e\u003cli\u003eThree of a kind\u003c/li\u003e\u003cli\u003eTwo pair\u003c/li\u003e\u003cli\u003ePair\u003c/li\u003e\u003cli\u003eHigh Card\u003c/li\u003e\u003cli\u003eNo valid Hand\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eout.cardsUsed is the same as is returned from the functions defined earlier for each type of hand.\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 0 0\r\n0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n0 1 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a three of a kind, so the return code is 6.\u003c/p\u003e","function_template":"function out = bestPokerHand(hm)\r\n\r\nout.code      = 10;\r\nout.usedCards = false(4,13); ","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.code = 10;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 0 0 0 1 0 0 0 0 0 0 1 0\r\n      0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 1 0 0 0];\r\n\r\ny_correct.code = 9;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 0 0 0 1 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 1 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.code = 8;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 1 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 1 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n      1 0 0 1 0 0 0 0 0 0 1 0 0];\r\n\r\ny_correct.code = 7;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 1 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 1 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      0 0 0 0 0 0 1 0 0 0 0 0 0\r\n      0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n      0 0 0 0 0 0 1 0 0 0 0 1 0];\r\n\r\ny_correct.code = 6;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 1 \r\n                               0 0 0 0 0 0 1 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 1 0 0 0 0 1 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n      1 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 1 1 0 0 0 0 0 0 0 0 0 \r\n      0 0 0 0 1 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.code = 5;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 1 1 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 1 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.code = 4;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 0 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 1 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.code = 3;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 1 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 1 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 0 1 1 1 \r\n      0 1 0 0 0 0 0 0 1 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.code = 2;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 1 1 1 1 1 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 1 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\ny_correct.code = 1;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 1 1 1 1 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(bestPokerHand(hm),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":18,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":44,"test_suite_updated_at":"2016-12-13T18:56:05.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-22T20:58:19.000Z","updated_at":"2026-02-15T04:18:26.000Z","published_at":"2012-02-22T20:58:26.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the best hand using the definitions from earlier in this series.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eout.code is:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStraight Flush\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eQuads\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFull House\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFlush\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStraight\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThree of a kind\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eTwo pair\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePair\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHigh Card\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNo valid Hand\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eout.cardsUsed is the same as is returned from the functions defined earlier for each type of hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 0 0\\n0 1 0 1 0 0 0 0 0 0 0 0 0 \\n0 1 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a three of a kind, so the return code is 6.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":383,"title":"Poker Series 07: IsTwoPair","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nA two pair is two pairs of cards of the same rank (column).  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next highest card is the kicker.  If the kicker also form three of a kind with a pair, it is still considered two pair for the purposes of this function.  Four of a kind is still two pair also.  (I got two pair, a pair of Aces and another Pair of Aces!)\r\n\r\nThis hand matrix:\r\n\r\n  0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 1 0 0 0\r\n  0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n  0 0 0 0 1 1 0 0 1 0 0 0 0\r\n\r\nrepresents a two pair, so the return value from the function is TRUE.\r\n\r\nThis hand matrix does not:\r\n\r\n  0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\r\nso the return value should be FALSE.\r\n\r\nThis hand matrix does represent a two pair\r\n\r\n  0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n  0 0 1 0 0 0 0 0 0 0 1 0 1\r\n  0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n  0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\r\nRemember, hand matrices can contain any number of 1's from 0 to 52.\r\n\r\n  0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n  0 1 0 0 1 1 1 0 0 0 0 1 0\r\n  0 1 0 1 0 0 0 0 0 1 0 0 0 \r\n  0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\r\nWould be TRUE for this function.\r\n\r\nA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind.  If more than one two pair can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same pair, return the ones higher up in the matrix, same for kickers.  If the two pair happens to also be a four of a kind or full house, it still meets the defintion and should be returned.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eA two pair is two pairs of cards of the same rank (column).  The Ace (first column) is highest.  The columns represent A, 2, 3, ... K.  The next highest card is the kicker.  If the kicker also form three of a kind with a pair, it is still considered two pair for the purposes of this function.  Four of a kind is still two pair also.  (I got two pair, a pair of Aces and another Pair of Aces!)\u003c/p\u003e\u003cp\u003eThis hand matrix:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 1 0 0 0\r\n0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n0 0 0 0 1 1 0 0 1 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003erepresents a two pair, so the return value from the function is TRUE.\u003c/p\u003e\u003cp\u003eThis hand matrix does not:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 1 1 0 1 1 0 0 0 0 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eso the return value should be FALSE.\u003c/p\u003e\u003cp\u003eThis hand matrix does represent a two pair\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 0 0 0 0 1 0 0 1 \r\n0 0 1 0 0 0 0 0 0 0 1 0 1\r\n0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n0 0 0 0 0 1 0 0 0 0 0 0 0\r\n\u003c/pre\u003e\u003cp\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e0 0 0 0 0 1 0 0 0 0 0 0 0 \r\n0 1 0 0 1 1 1 0 0 0 0 1 0\r\n0 1 0 1 0 0 0 0 0 1 0 0 0 \r\n0 0 1 0 0 0 0 0 0 0 0 1 0 \r\n\u003c/pre\u003e\u003cp\u003eWould be TRUE for this function.\u003c/p\u003e\u003cp\u003eA second output argument should come from this function.  It is a usedCards Matrix.  It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind.  If more than one two pair can be made, return the higher ranking one (the one with the highest rank.  Ace being the highest).  If different suits are possible for the same pair, return the ones higher up in the matrix, same for kickers.  If the two pair happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/p\u003e","function_template":"function out = isTwoPair(hm)\r\n  out.flag      = false;\r\n  out.usedCards = false(4,13);\r\nend","test_suite":"%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 1 1 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 0 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 1 0 0 0 0 0 0 1 0 0 0 1 \r\n                               0 1 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 1 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 0 0 \r\n      0 1 0 0 0 0 0 0 0 0 0 0 0\r\n      1 0 0 1 0 0 0 0 1 1 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 1 1 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 0 1 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0\r\n      0 0 0 1 0 0 0 0 1 1 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 0 0 \r\n      0 1 0 0 0 0 0 0 0 1 0 0 0\r\n      1 0 0 1 0 0 0 0 1 1 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 1 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 1 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               1 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n\r\n%%\r\nhm = [0 1 0 0 0 0 0 0 1 1 0 0 0 \r\n      0 1 0 0 0 0 0 0 0 1 0 0 0\r\n      1 0 0 1 0 0 0 0 1 1 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 1 0 0 0];\r\n\r\ny_correct.flag = true;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 1 0 0 0\r\n                               1 0 0 0 0 0 0 0 0 1 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 1 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))\r\n\r\n%%\r\nhm = [0 0 0 0 0 0 0 0 0 1 0 0 0 \r\n      1 0 0 0 0 0 0 0 0 0 0 0 0\r\n      1 0 0 0 0 0 0 0 0 1 0 0 0 \r\n      0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\ny_correct.flag = false;\r\ny_correct.usedCards = logical([0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0\r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n                               0 0 0 0 0 0 0 0 0 0 0 0 0])\r\n                           \r\nassert(isequal(isTwoPair(hm),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2012-02-22T17:28:05.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-22T17:28:05.000Z","updated_at":"2026-02-15T05:47:26.000Z","published_at":"2012-02-22T17:28:08.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA two pair is two pairs of cards of the same rank (column). The Ace (first column) is highest. The columns represent A, 2, 3, ... K. The next highest card is the kicker. If the kicker also form three of a kind with a pair, it is still considered two pair for the purposes of this function. Four of a kind is still two pair also. (I got two pair, a pair of Aces and another Pair of Aces!)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 0 0 1 0 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 1 0 0 0\\n0 1 0 0 0 0 0 0 0 0 0 0 0 \\n0 0 0 0 1 1 0 0 1 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003erepresents a two pair, so the return value from the function is TRUE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does not:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 1 1 0 1 1 0 0 0 0 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 0 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eso the return value should be FALSE.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis hand matrix does represent a two pair\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 0 0 0 0 1 0 0 1 \\n0 0 1 0 0 0 0 0 0 0 1 0 1\\n0 0 0 0 0 0 0 0 0 1 0 0 0 \\n0 0 0 0 0 1 0 0 0 0 0 0 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRemember, hand matrices can contain any number of 1's from 0 to 52.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[0 0 0 0 0 1 0 0 0 0 0 0 0 \\n0 1 0 0 1 1 1 0 0 0 0 1 0\\n0 1 0 1 0 0 0 0 0 1 0 0 0 \\n0 0 1 0 0 0 0 0 0 0 0 1 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWould be TRUE for this function.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA second output argument should come from this function. It is a usedCards Matrix. It is of the same form as the hand matrix, but it only shows the cards used to make the three of a kind. If more than one two pair can be made, return the higher ranking one (the one with the highest rank. Ace being the highest). If different suits are possible for the same pair, return the ones higher up in the matrix, same for kickers. If the two pair happens to also be a four of a kind or full house, it still meets the defintion and should be returned.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":391,"title":"Poker Series 11: selectBestHand","description":"The Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\r\n\r\nA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\r\n\r\nFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\r\n\r\n--------\r\n\r\nSelect the best hand using the definitions from earlier in this series.\r\n\r\n  out.hm{1} = cards used from the first hand matrix;\r\n  out.hm{2} = cards used from the second hand matrix;   \r\n  out.winner = 1,2 or zero for a tie;\r\n\r\n\r\nStandard poker ranks apply: Straight flush is best, high card is worst, with many gradations within each rank.","description_html":"\u003cp\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior.  Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/p\u003e\u003cp\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use.  This program will be expandable to use 5 card hands through 52 card hands!  Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/p\u003e\u003cp\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series.  To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed.  This is being done as an exercise in coding.  The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/p\u003e\u003cp\u003e--------\u003c/p\u003e\u003cp\u003eSelect the best hand using the definitions from earlier in this series.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eout.hm{1} = cards used from the first hand matrix;\r\nout.hm{2} = cards used from the second hand matrix;   \r\nout.winner = 1,2 or zero for a tie;\r\n\u003c/pre\u003e\u003cp\u003eStandard poker ranks apply: Straight flush is best, high card is worst, with many gradations within each rank.\u003c/p\u003e","function_template":"function out = selectBestHand(hm1, hm2)\r\n\r\n%winner is 1,2 or 0 is tie, even if both have no valid hand\r\n\r\nout.hm{1}  = false(4,13);\r\nout.hm{2}  = false(4,13);\r\nout.winner = 0;","test_suite":"%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 0;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 2;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 1 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 1 0 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 1;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 1 0 1 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 1 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 1 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0\r\n       0 1 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 1;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 1;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n\r\n%%\r\nhm1 = [1 1 1 1 1 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 1 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\nom1 = [1 1 1 1 1 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 1 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 1;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n\r\n%%\r\nhm1 = [1 1 1 1 1 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 1 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\nom1 = [1 1 1 1 1 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [1 1 1 1 1 1 0 0 0 0 0 1 1 \r\n       0 0 0 0 0 0 0 0 0 0 0 1 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 1 1 1 1 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 2;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n\r\n%%\r\nhm1 = [0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 1 0 0 0 0 0 0 0 0 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];\r\n   \r\nhm2 = [0 0 0 0 1 1 0 0 0 0 0 1 1 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 0 0 0 1 0 0 0 0 0 0 1 1 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0\r\n       0 0 0 0 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 2;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n%%\r\nhm1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 1 0 0 1 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n\r\nom1 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 0 0 0 0 0 0 0 \r\n       0 0 0 0 0 0 0 0 1 0 0 0 0];\r\n   \r\nhm2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 1 0 0 0 0 1 0 \r\n       0 0 0 0 1 0 0 0 0 0 0 0 0];  \r\n   \r\nom2 = [0 1 0 0 0 0 0 0 0 0 0 0 1 \r\n       0 1 0 0 0 0 0 0 0 0 0 0 1\r\n       0 0 0 0 0 0 0 0 0 0 0 1 0 \r\n       0 0 0 0 0 0 0 0 0 0 0 0 0];   \r\n\r\nout.hm{1} = om1;\r\nout.hm{2} = om2;   \r\nout.winner = 2;\r\n\r\nassert(isequal(selectBestHand(hm1,hm2),out))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":16,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":37,"test_suite_updated_at":"2016-12-13T18:59:04.000Z","rescore_all_solutions":false,"group_id":15,"created_at":"2012-02-23T16:55:58.000Z","updated_at":"2026-02-15T04:12:40.000Z","published_at":"2012-02-23T20:20:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Poker Series consists of many short, well defined functions that when combined will lead to complex behavior. Our goal is to create a function that will take two hand matrices (defined below) and return the winning hand.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA hand matrix is 4x13 binary matrix showing the cards that are available for a poker player to use. This program will be expandable to use 5 card hands through 52 card hands! Suits of the cards are all equally ranked, so they only matter for determination of flushes (and straight flushes).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor each challenge, you should feel free to reuse your solutions from prior challenges in the series. To break this problem into smaller pieces, I am likely making architectural choices that are sub-optimal for speed. This is being done as an exercise in coding. The larger goal of this project can likely be done in a much faster, but more obscure way.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e--------\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSelect the best hand using the definitions from earlier in this series.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[out.hm{1} = cards used from the first hand matrix;\\nout.hm{2} = cards used from the second hand matrix;   \\nout.winner = 1,2 or zero for a tie;]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStandard poker ranks apply: Straight flush is best, high card is worst, with many gradations within each rank.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"pokerseries\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"pokerseries\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"pokerseries\"","","\"","pokerseries","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f03f0a046a0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f03f0a04600\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f03f0a035c0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f03f0a04a60\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f03f0a049c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f03f0a04880\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f03f0a047e0\u003e":"tag:\"pokerseries\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f03f0a047e0\u003e":"tag:\"pokerseries\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"pokerseries\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"pokerseries\"","","\"","pokerseries","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f03f0a046a0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f03f0a04600\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f03f0a035c0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f03f0a04a60\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f03f0a049c0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f03f0a04880\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f03f0a047e0\u003e":"tag:\"pokerseries\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f03f0a047e0\u003e":"tag:\"pokerseries\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":384,"difficulty_rating":"easy-medium"},{"id":385,"difficulty_rating":"easy-medium"},{"id":376,"difficulty_rating":"easy-medium"},{"id":335,"difficulty_rating":"medium"},{"id":329,"difficulty_rating":"medium"},{"id":377,"difficulty_rating":"medium"},{"id":334,"difficulty_rating":"medium"},{"id":333,"difficulty_rating":"medium"},{"id":386,"difficulty_rating":"medium"},{"id":383,"difficulty_rating":"medium"},{"id":391,"difficulty_rating":"medium"}]}}