{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.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":"2025-12-14T00: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":56195,"title":"Possible Rugby Scores","description":"Given a natural number s (\u003e 4), representing a rugby team's score, return an n-by-3 matrix representing all n possible combinations of tries, conversions, and penalties (or drop goals) that would result in such a score. The first column of the matrix represents the number of tries, the second column the number of conversions, the third column the number of penalties or drop goals. The order of the rows is not important, as long as all possibilities are uniquely represented.\r\nIn rugby, a try scores 5 points, a conversion scores 2, and a penalty or drop goal scores 3. However, a conversion can only be attempted after scoring a try. Hence the number of conversions can never be more than the number of tries.\r\ntcp = scorebreakdown(12)\r\n\r\ntcp =\r\n     2     1     0\r\n     0     0     4\r\n     \r\nTwo tries = 2*5 = 10 points. One conversion = 2 points. Total = 10 + 2 = 12.\r\nFour penalties = 4*3 = 12 points.\r\nNote that 1 try, 2 conversions, and 1 penalty would total 12 points, but is not allowed because it is not possible to have more conversions than tries.\r\n(This problem can be treated as finding all integer linear combinations of 5, 2, and 3, such that 5a + 2b + 3c = s, but with a restriction: b \u003c= a.)","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: 431.1px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 215.55px; transform-origin: 407px 215.55px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84.5px; 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 42.25px; text-align: left; transform-origin: 384px 42.25px; 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: 76.5px 8px; transform-origin: 76.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a natural number \u003c/span\u003e\u003c/span\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003es\u003c/span\u003e\u003c/span\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: 164px 8px; transform-origin: 164px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e (\u0026gt; 4), representing a rugby team's score, return an \u003c/span\u003e\u003c/span\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\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: 90px 8px; transform-origin: 90px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e-by-3 matrix representing all \u003c/span\u003e\u003c/span\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\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: 30px 8px; transform-origin: 30px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e possible combinations of tries, conversions, and penalties (or drop goals) that would result in such a score. The first column of the matrix represents the number of tries, the second column the number of conversions, the third column the number of penalties or drop goals. The order of the rows is not important, as long as all possibilities are uniquely represented.\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: 373.5px 8px; transform-origin: 373.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn rugby, a try scores 5 points, a conversion scores 2, and a penalty or drop goal scores 3. However, a conversion can only be attempted after scoring a try. Hence the number of conversions can never be more than the number of tries.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; 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 61.3px; transform-origin: 404px 61.3px; 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: 96px 8.5px; tab-size: 4; transform-origin: 96px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003etcp = scorebreakdown(12)\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: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\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: 20px 8.5px; tab-size: 4; transform-origin: 20px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003etcp =\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: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     2     1     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: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     0     0     4\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: 20px 8.5px; tab-size: 4; transform-origin: 20px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     \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: 235.5px 8px; transform-origin: 235.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTwo tries = 2*5 = 10 points. One conversion = 2 points. Total = 10 + 2 = 12.\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: 103px 8px; transform-origin: 103px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFour penalties = 4*3 = 12 points.\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: 373px 8px; transform-origin: 373px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote that 1 try, 2 conversions, and 1 penalty would total 12 points, but is not allowed because it is not possible to have more conversions than tries.\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: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e(This problem can be treated as finding all integer linear combinations of 5, 2, and 3, such that 5a + 2b + 3c = s, but with a restriction: b \u0026lt;= a.)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tcp = scorebreakdown(s)\r\n\r\ntcp = [s/5,s/2,s/3];\r\n\r\nend","test_suite":"%% s = 57\r\ntcp = scorebreakdown(57);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 19;2 1 15;3 0 14;3 3 12;4 2 11;5 1 10;5 4 8;6 0 9;6 3 7;6 6 5;7 2 6;7 5 4;8 1 5;8 4 3;8 7 1;9 0 4;9 3 2;9 6 0;10 2 1;11 1 0]) )\r\n%% s = 33\r\ntcp = scorebreakdown(33);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 11;2 1 7;3 0 6;3 3 4;4 2 3;5 1 2;5 4 0;6 0 1]) )\r\n%% s = 55\r\ntcp = scorebreakdown(55);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 16;2 0 15;3 2 12;4 1 11;4 4 9;5 0 10;5 3 8;6 2 7;6 5 5;7 1 6;7 4 4;7 7 2;8 0 5;8 3 3;8 6 1;9 2 2;9 5 0;10 1 1;11 0 0]) )\r\n%% s = 41\r\ntcp = scorebreakdown(41);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 12;2 2 9;3 1 8;4 0 7;4 3 5;5 2 4;5 5 2;6 1 3;6 4 1;7 0 2;7 3 0]) )\r\n%% s = 21\r\ntcp = scorebreakdown(21);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 7;2 1 3;3 0 2;3 3 0]) )\r\n%% s = 17\r\ntcp = scorebreakdown(17);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 4;2 2 1;3 1 0]) )\r\n%% s = 27\r\ntcp = scorebreakdown(27);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 9;2 1 5;3 0 4;3 3 2;4 2 1;5 1 0]) )\r\n%% s = 28\r\ntcp = scorebreakdown(28);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 7;2 0 6;3 2 3;4 1 2;4 4 0;5 0 1]) )\r\n%% s = 9\r\ntcp = scorebreakdown(9);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 3]) )\r\n%% s = 14\r\ntcp = scorebreakdown(14);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 3;2 2 0]) )\r\n%% s = 20\r\ntcp = scorebreakdown(20);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 5;2 2 2;3 1 1;4 0 0]) )\r\n%% s = 46\r\ntcp = scorebreakdown(46);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 13;2 0 12;3 2 9;4 1 8;4 4 6;5 0 7;5 3 5;6 2 4;6 5 2;7 1 3;7 4 1;8 0 2;8 3 0]) )\r\n%% s = 8\r\ntcp = scorebreakdown(8);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 1]) )\r\n%% s = 31\r\ntcp = scorebreakdown(31);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 8;2 0 7;3 2 4;4 1 3;4 4 1;5 0 2;5 3 0]) )\r\n%% s = 42\r\ntcp = scorebreakdown(42);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 14;2 1 10;3 0 9;3 3 7;4 2 6;5 1 5;5 4 3;6 0 4;6 3 2;6 6 0;7 2 1;8 1 0]) )\r\n%% s = 5\r\ntcp = scorebreakdown(5);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 0]) )\r\n%% s = 56\r\ntcp = scorebreakdown(56);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 17;2 2 14;3 1 13;4 0 12;4 3 10;5 2 9;5 5 7;6 1 8;6 4 6;7 0 7;7 3 5;7 6 3;8 2 4;8 5 2;8 8 0;9 1 3;9 4 1;10 0 2;10 3 0]) )\r\n%% s = 36\r\ntcp = scorebreakdown(36);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 12;2 1 8;3 0 7;3 3 5;4 2 4;5 1 3;5 4 1;6 0 2;6 3 0]) )\r\n%% s = 60\r\ntcp = scorebreakdown(60);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 20;2 1 16;3 0 15;3 3 13;4 2 12;5 1 11;5 4 9;6 0 10;6 3 8;6 6 6;7 2 7;7 5 5;8 1 6;8 4 4;8 7 2;9 0 5;9 3 3;9 6 1;10 2 2;10 5 0;11 1 1;12 0 0]) )\r\n%% s = 43\r\ntcp = scorebreakdown(43);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 12;2 0 11;3 2 8;4 1 7;4 4 5;5 0 6;5 3 4;6 2 3;6 5 1;7 1 2;7 4 0;8 0 1]) )\r\n%% s = 62\r\ntcp = scorebreakdown(62);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 19;2 2 16;3 1 15;4 0 14;4 3 12;5 2 11;5 5 9;6 1 10;6 4 8;7 0 9;7 3 7;7 6 5;8 2 6;8 5 4;8 8 2;9 1 5;9 4 3;9 7 1;10 0 4;10 3 2;10 6 0;11 2 1;12 1 0]) )\r\n%% s = 69\r\ntcp = scorebreakdown(69);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 23;2 1 19;3 0 18;3 3 16;4 2 15;5 1 14;5 4 12;6 0 13;6 3 11;6 6 9;7 2 10;7 5 8;8 1 9;8 4 7;8 7 5;9 0 8;9 3 6;9 6 4;9 9 2;10 2 5;10 5 3;10 8 1;11 1 4;11 4 2;11 7 0;12 0 3;12 3 1;13 2 0]) )\r\n%% s = 63\r\ntcp = scorebreakdown(63);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 21;2 1 17;3 0 16;3 3 14;4 2 13;5 1 12;5 4 10;6 0 11;6 3 9;6 6 7;7 2 8;7 5 6;8 1 7;8 4 5;8 7 3;9 0 6;9 3 4;9 6 2;9 9 0;10 2 3;10 5 1;11 1 2;11 4 0;12 0 1]) )\r\n%% s = 71\r\ntcp = scorebreakdown(71);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 22;2 2 19;3 1 18;4 0 17;4 3 15;5 2 14;5 5 12;6 1 13;6 4 11;7 0 12;7 3 10;7 6 8;8 2 9;8 5 7;8 8 5;9 1 8;9 4 6;9 7 4;10 0 7;10 3 5;10 6 3;10 9 1;11 2 4;11 5 2;11 8 0;12 1 3;12 4 1;13 0 2;13 3 0]) )\r\n%% s = 81\r\ntcp = scorebreakdown(81);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 27;2 1 23;3 0 22;3 3 20;4 2 19;5 1 18;5 4 16;6 0 17;6 3 15;6 6 13;7 2 14;7 5 12;8 1 13;8 4 11;8 7 9;9 0 12;9 3 10;9 6 8;9 9 6;10 2 9;10 5 7;10 8 5;11 1 8;11 4 6;11 7 4;11 10 2;12 0 7;12 3 5;12 6 3;12 9 1;13 2 4;13 5 2;13 8 0;14 1 3;14 4 1;15 0 2;15 3 0]) )\r\n%% s = 123\r\ntcp = scorebreakdown(123);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 41;2 1 37;3 0 36;3 3 34;4 2 33;5 1 32;5 4 30;6 0 31;6 3 29;6 6 27;7 2 28;7 5 26;8 1 27;8 4 25;8 7 23;9 0 26;9 3 24;9 6 22;9 9 20;10 2 23;10 5 21;10 8 19;11 1 22;11 4 20;11 7 18;11 10 16;12 0 21;12 3 19;12 6 17;12 9 15;12 12 13;13 2 18;13 5 16;13 8 14;13 11 12;14 1 17;14 4 15;14 7 13;14 10 11;14 13 9;15 0 16;15 3 14;15 6 12;15 9 10;15 12 8;15 15 6;16 2 13;16 5 11;16 8 9;16 11 7;16 14 5;17 1 12;17 4 10;17 7 8;17 10 6;17 13 4;17 16 2;18 0 11;18 3 9;18 6 7;18 9 5;18 12 3;18 15 1;19 2 8;19 5 6;19 8 4;19 11 2;19 14 0;20 1 7;20 4 5;20 7 3;20 10 1;21 0 6;21 3 4;21 6 2;21 9 0;22 2 3;22 5 1;23 1 2;23 4 0;24 0 1]) )\r\n%% s = 145\r\ntcp = scorebreakdown(145);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 46;2 0 45;3 2 42;4 1 41;4 4 39;5 0 40;5 3 38;6 2 37;6 5 35;7 1 36;7 4 34;7 7 32;8 0 35;8 3 33;8 6 31;9 2 32;9 5 30;9 8 28;10 1 31;10 4 29;10 7 27;10 10 25;11 0 30;11 3 28;11 6 26;11 9 24;12 2 27;12 5 25;12 8 23;12 11 21;13 1 26;13 4 24;13 7 22;13 10 20;13 13 18;14 0 25;14 3 23;14 6 21;14 9 19;14 12 17;15 2 22;15 5 20;15 8 18;15 11 16;15 14 14;16 1 21;16 4 19;16 7 17;16 10 15;16 13 13;16 16 11;17 0 20;17 3 18;17 6 16;17 9 14;17 12 12;17 15 10;18 2 17;18 5 15;18 8 13;18 11 11;18 14 9;18 17 7;19 1 16;19 4 14;19 7 12;19 10 10;19 13 8;19 16 6;19 19 4;20 0 15;20 3 13;20 6 11;20 9 9;20 12 7;20 15 5;20 18 3;21 2 12;21 5 10;21 8 8;21 11 6;21 14 4;21 17 2;21 20 0;22 1 11;22 4 9;22 7 7;22 10 5;22 13 3;22 16 1;23 0 10;23 3 8;23 6 6;23 9 4;23 12 2;23 15 0;24 2 7;24 5 5;24 8 3;24 11 1;25 1 6;25 4 4;25 7 2;25 10 0;26 0 5;26 3 3;26 6 1;27 2 2;27 5 0;28 1 1;29 0 0]) )\r\n%% Some random checks\r\nfor k = 1:20\r\n    s = randi([5 145]);\r\n    tcp = scorebreakdown(s);\r\n    assert( all(tcp(:,1) \u003e= tcp(:,2)) )\r\n    assert( all(tcp*[5;2;3] == s) )\r\nend","published":true,"deleted":false,"likes_count":7,"comments_count":0,"created_by":287,"edited_by":287,"edited_at":"2022-10-24T13:06:10.000Z","deleted_by":null,"deleted_at":null,"solvers_count":115,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-09-30T18:06:54.000Z","updated_at":"2026-04-01T14:47:08.000Z","published_at":"2022-10-24T13:06:10.000Z","restored_at":null,"restored_by":null,"spam":null,"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\u003eGiven a natural number \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (\u0026gt; 4), representing a rugby team's score, return an \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e-by-3 matrix representing all \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e possible combinations of tries, conversions, and penalties (or drop goals) that would result in such a score. The first column of the matrix represents the number of tries, the second column the number of conversions, the third column the number of penalties or drop goals. The order of the rows is not important, as long as all possibilities are uniquely represented.\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\u003eIn rugby, a try scores 5 points, a conversion scores 2, and a penalty or drop goal scores 3. However, a conversion can only be attempted after scoring a try. Hence the number of conversions can never be more than the number of tries.\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[tcp = scorebreakdown(12)\\n\\ntcp =\\n     2     1     0\\n     0     0     4\\n     ]]\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\u003eTwo tries = 2*5 = 10 points. One conversion = 2 points. Total = 10 + 2 = 12.\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\u003eFour penalties = 4*3 = 12 points.\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\u003eNote that 1 try, 2 conversions, and 1 penalty would total 12 points, but is not allowed because it is not possible to have more conversions than tries.\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(This problem can be treated as finding all integer linear combinations of 5, 2, and 3, such that 5a + 2b + 3c = s, but with a restriction: b \u0026lt;= a.)\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\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":56195,"title":"Possible Rugby Scores","description":"Given a natural number s (\u003e 4), representing a rugby team's score, return an n-by-3 matrix representing all n possible combinations of tries, conversions, and penalties (or drop goals) that would result in such a score. The first column of the matrix represents the number of tries, the second column the number of conversions, the third column the number of penalties or drop goals. The order of the rows is not important, as long as all possibilities are uniquely represented.\r\nIn rugby, a try scores 5 points, a conversion scores 2, and a penalty or drop goal scores 3. However, a conversion can only be attempted after scoring a try. Hence the number of conversions can never be more than the number of tries.\r\ntcp = scorebreakdown(12)\r\n\r\ntcp =\r\n     2     1     0\r\n     0     0     4\r\n     \r\nTwo tries = 2*5 = 10 points. One conversion = 2 points. Total = 10 + 2 = 12.\r\nFour penalties = 4*3 = 12 points.\r\nNote that 1 try, 2 conversions, and 1 penalty would total 12 points, but is not allowed because it is not possible to have more conversions than tries.\r\n(This problem can be treated as finding all integer linear combinations of 5, 2, and 3, such that 5a + 2b + 3c = s, but with a restriction: b \u003c= a.)","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: 431.1px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 215.55px; transform-origin: 407px 215.55px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84.5px; 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 42.25px; text-align: left; transform-origin: 384px 42.25px; 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: 76.5px 8px; transform-origin: 76.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a natural number \u003c/span\u003e\u003c/span\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003es\u003c/span\u003e\u003c/span\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: 164px 8px; transform-origin: 164px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e (\u0026gt; 4), representing a rugby team's score, return an \u003c/span\u003e\u003c/span\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\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: 90px 8px; transform-origin: 90px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e-by-3 matrix representing all \u003c/span\u003e\u003c/span\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: 4px 8px; transform-origin: 4px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003en\u003c/span\u003e\u003c/span\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: 30px 8px; transform-origin: 30px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e possible combinations of tries, conversions, and penalties (or drop goals) that would result in such a score. The first column of the matrix represents the number of tries, the second column the number of conversions, the third column the number of penalties or drop goals. The order of the rows is not important, as long as all possibilities are uniquely represented.\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: 373.5px 8px; transform-origin: 373.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn rugby, a try scores 5 points, a conversion scores 2, and a penalty or drop goal scores 3. However, a conversion can only be attempted after scoring a try. Hence the number of conversions can never be more than the number of tries.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; 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 61.3px; transform-origin: 404px 61.3px; 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: 96px 8.5px; tab-size: 4; transform-origin: 96px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003etcp = scorebreakdown(12)\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: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\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: 20px 8.5px; tab-size: 4; transform-origin: 20px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003etcp =\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: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     2     1     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: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     0     0     4\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: 20px 8.5px; tab-size: 4; transform-origin: 20px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     \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: 235.5px 8px; transform-origin: 235.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTwo tries = 2*5 = 10 points. One conversion = 2 points. Total = 10 + 2 = 12.\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: 103px 8px; transform-origin: 103px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFour penalties = 4*3 = 12 points.\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: 373px 8px; transform-origin: 373px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote that 1 try, 2 conversions, and 1 penalty would total 12 points, but is not allowed because it is not possible to have more conversions than tries.\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: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e(This problem can be treated as finding all integer linear combinations of 5, 2, and 3, such that 5a + 2b + 3c = s, but with a restriction: b \u0026lt;= a.)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tcp = scorebreakdown(s)\r\n\r\ntcp = [s/5,s/2,s/3];\r\n\r\nend","test_suite":"%% s = 57\r\ntcp = scorebreakdown(57);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 19;2 1 15;3 0 14;3 3 12;4 2 11;5 1 10;5 4 8;6 0 9;6 3 7;6 6 5;7 2 6;7 5 4;8 1 5;8 4 3;8 7 1;9 0 4;9 3 2;9 6 0;10 2 1;11 1 0]) )\r\n%% s = 33\r\ntcp = scorebreakdown(33);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 11;2 1 7;3 0 6;3 3 4;4 2 3;5 1 2;5 4 0;6 0 1]) )\r\n%% s = 55\r\ntcp = scorebreakdown(55);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 16;2 0 15;3 2 12;4 1 11;4 4 9;5 0 10;5 3 8;6 2 7;6 5 5;7 1 6;7 4 4;7 7 2;8 0 5;8 3 3;8 6 1;9 2 2;9 5 0;10 1 1;11 0 0]) )\r\n%% s = 41\r\ntcp = scorebreakdown(41);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 12;2 2 9;3 1 8;4 0 7;4 3 5;5 2 4;5 5 2;6 1 3;6 4 1;7 0 2;7 3 0]) )\r\n%% s = 21\r\ntcp = scorebreakdown(21);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 7;2 1 3;3 0 2;3 3 0]) )\r\n%% s = 17\r\ntcp = scorebreakdown(17);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 4;2 2 1;3 1 0]) )\r\n%% s = 27\r\ntcp = scorebreakdown(27);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 9;2 1 5;3 0 4;3 3 2;4 2 1;5 1 0]) )\r\n%% s = 28\r\ntcp = scorebreakdown(28);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 7;2 0 6;3 2 3;4 1 2;4 4 0;5 0 1]) )\r\n%% s = 9\r\ntcp = scorebreakdown(9);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 3]) )\r\n%% s = 14\r\ntcp = scorebreakdown(14);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 3;2 2 0]) )\r\n%% s = 20\r\ntcp = scorebreakdown(20);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 5;2 2 2;3 1 1;4 0 0]) )\r\n%% s = 46\r\ntcp = scorebreakdown(46);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 13;2 0 12;3 2 9;4 1 8;4 4 6;5 0 7;5 3 5;6 2 4;6 5 2;7 1 3;7 4 1;8 0 2;8 3 0]) )\r\n%% s = 8\r\ntcp = scorebreakdown(8);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 1]) )\r\n%% s = 31\r\ntcp = scorebreakdown(31);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 8;2 0 7;3 2 4;4 1 3;4 4 1;5 0 2;5 3 0]) )\r\n%% s = 42\r\ntcp = scorebreakdown(42);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 14;2 1 10;3 0 9;3 3 7;4 2 6;5 1 5;5 4 3;6 0 4;6 3 2;6 6 0;7 2 1;8 1 0]) )\r\n%% s = 5\r\ntcp = scorebreakdown(5);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 0]) )\r\n%% s = 56\r\ntcp = scorebreakdown(56);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 17;2 2 14;3 1 13;4 0 12;4 3 10;5 2 9;5 5 7;6 1 8;6 4 6;7 0 7;7 3 5;7 6 3;8 2 4;8 5 2;8 8 0;9 1 3;9 4 1;10 0 2;10 3 0]) )\r\n%% s = 36\r\ntcp = scorebreakdown(36);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 12;2 1 8;3 0 7;3 3 5;4 2 4;5 1 3;5 4 1;6 0 2;6 3 0]) )\r\n%% s = 60\r\ntcp = scorebreakdown(60);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 20;2 1 16;3 0 15;3 3 13;4 2 12;5 1 11;5 4 9;6 0 10;6 3 8;6 6 6;7 2 7;7 5 5;8 1 6;8 4 4;8 7 2;9 0 5;9 3 3;9 6 1;10 2 2;10 5 0;11 1 1;12 0 0]) )\r\n%% s = 43\r\ntcp = scorebreakdown(43);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 12;2 0 11;3 2 8;4 1 7;4 4 5;5 0 6;5 3 4;6 2 3;6 5 1;7 1 2;7 4 0;8 0 1]) )\r\n%% s = 62\r\ntcp = scorebreakdown(62);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 19;2 2 16;3 1 15;4 0 14;4 3 12;5 2 11;5 5 9;6 1 10;6 4 8;7 0 9;7 3 7;7 6 5;8 2 6;8 5 4;8 8 2;9 1 5;9 4 3;9 7 1;10 0 4;10 3 2;10 6 0;11 2 1;12 1 0]) )\r\n%% s = 69\r\ntcp = scorebreakdown(69);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 23;2 1 19;3 0 18;3 3 16;4 2 15;5 1 14;5 4 12;6 0 13;6 3 11;6 6 9;7 2 10;7 5 8;8 1 9;8 4 7;8 7 5;9 0 8;9 3 6;9 6 4;9 9 2;10 2 5;10 5 3;10 8 1;11 1 4;11 4 2;11 7 0;12 0 3;12 3 1;13 2 0]) )\r\n%% s = 63\r\ntcp = scorebreakdown(63);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 21;2 1 17;3 0 16;3 3 14;4 2 13;5 1 12;5 4 10;6 0 11;6 3 9;6 6 7;7 2 8;7 5 6;8 1 7;8 4 5;8 7 3;9 0 6;9 3 4;9 6 2;9 9 0;10 2 3;10 5 1;11 1 2;11 4 0;12 0 1]) )\r\n%% s = 71\r\ntcp = scorebreakdown(71);\r\nassert( isequal(sortrows(tcp,1:3),[1 0 22;2 2 19;3 1 18;4 0 17;4 3 15;5 2 14;5 5 12;6 1 13;6 4 11;7 0 12;7 3 10;7 6 8;8 2 9;8 5 7;8 8 5;9 1 8;9 4 6;9 7 4;10 0 7;10 3 5;10 6 3;10 9 1;11 2 4;11 5 2;11 8 0;12 1 3;12 4 1;13 0 2;13 3 0]) )\r\n%% s = 81\r\ntcp = scorebreakdown(81);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 27;2 1 23;3 0 22;3 3 20;4 2 19;5 1 18;5 4 16;6 0 17;6 3 15;6 6 13;7 2 14;7 5 12;8 1 13;8 4 11;8 7 9;9 0 12;9 3 10;9 6 8;9 9 6;10 2 9;10 5 7;10 8 5;11 1 8;11 4 6;11 7 4;11 10 2;12 0 7;12 3 5;12 6 3;12 9 1;13 2 4;13 5 2;13 8 0;14 1 3;14 4 1;15 0 2;15 3 0]) )\r\n%% s = 123\r\ntcp = scorebreakdown(123);\r\nassert( isequal(sortrows(tcp,1:3),[0 0 41;2 1 37;3 0 36;3 3 34;4 2 33;5 1 32;5 4 30;6 0 31;6 3 29;6 6 27;7 2 28;7 5 26;8 1 27;8 4 25;8 7 23;9 0 26;9 3 24;9 6 22;9 9 20;10 2 23;10 5 21;10 8 19;11 1 22;11 4 20;11 7 18;11 10 16;12 0 21;12 3 19;12 6 17;12 9 15;12 12 13;13 2 18;13 5 16;13 8 14;13 11 12;14 1 17;14 4 15;14 7 13;14 10 11;14 13 9;15 0 16;15 3 14;15 6 12;15 9 10;15 12 8;15 15 6;16 2 13;16 5 11;16 8 9;16 11 7;16 14 5;17 1 12;17 4 10;17 7 8;17 10 6;17 13 4;17 16 2;18 0 11;18 3 9;18 6 7;18 9 5;18 12 3;18 15 1;19 2 8;19 5 6;19 8 4;19 11 2;19 14 0;20 1 7;20 4 5;20 7 3;20 10 1;21 0 6;21 3 4;21 6 2;21 9 0;22 2 3;22 5 1;23 1 2;23 4 0;24 0 1]) )\r\n%% s = 145\r\ntcp = scorebreakdown(145);\r\nassert( isequal(sortrows(tcp,1:3),[1 1 46;2 0 45;3 2 42;4 1 41;4 4 39;5 0 40;5 3 38;6 2 37;6 5 35;7 1 36;7 4 34;7 7 32;8 0 35;8 3 33;8 6 31;9 2 32;9 5 30;9 8 28;10 1 31;10 4 29;10 7 27;10 10 25;11 0 30;11 3 28;11 6 26;11 9 24;12 2 27;12 5 25;12 8 23;12 11 21;13 1 26;13 4 24;13 7 22;13 10 20;13 13 18;14 0 25;14 3 23;14 6 21;14 9 19;14 12 17;15 2 22;15 5 20;15 8 18;15 11 16;15 14 14;16 1 21;16 4 19;16 7 17;16 10 15;16 13 13;16 16 11;17 0 20;17 3 18;17 6 16;17 9 14;17 12 12;17 15 10;18 2 17;18 5 15;18 8 13;18 11 11;18 14 9;18 17 7;19 1 16;19 4 14;19 7 12;19 10 10;19 13 8;19 16 6;19 19 4;20 0 15;20 3 13;20 6 11;20 9 9;20 12 7;20 15 5;20 18 3;21 2 12;21 5 10;21 8 8;21 11 6;21 14 4;21 17 2;21 20 0;22 1 11;22 4 9;22 7 7;22 10 5;22 13 3;22 16 1;23 0 10;23 3 8;23 6 6;23 9 4;23 12 2;23 15 0;24 2 7;24 5 5;24 8 3;24 11 1;25 1 6;25 4 4;25 7 2;25 10 0;26 0 5;26 3 3;26 6 1;27 2 2;27 5 0;28 1 1;29 0 0]) )\r\n%% Some random checks\r\nfor k = 1:20\r\n    s = randi([5 145]);\r\n    tcp = scorebreakdown(s);\r\n    assert( all(tcp(:,1) \u003e= tcp(:,2)) )\r\n    assert( all(tcp*[5;2;3] == s) )\r\nend","published":true,"deleted":false,"likes_count":7,"comments_count":0,"created_by":287,"edited_by":287,"edited_at":"2022-10-24T13:06:10.000Z","deleted_by":null,"deleted_at":null,"solvers_count":115,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-09-30T18:06:54.000Z","updated_at":"2026-04-01T14:47:08.000Z","published_at":"2022-10-24T13:06:10.000Z","restored_at":null,"restored_by":null,"spam":null,"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\u003eGiven a natural number \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (\u0026gt; 4), representing a rugby team's score, return an \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e-by-3 matrix representing all \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e possible combinations of tries, conversions, and penalties (or drop goals) that would result in such a score. The first column of the matrix represents the number of tries, the second column the number of conversions, the third column the number of penalties or drop goals. The order of the rows is not important, as long as all possibilities are uniquely represented.\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\u003eIn rugby, a try scores 5 points, a conversion scores 2, and a penalty or drop goal scores 3. However, a conversion can only be attempted after scoring a try. Hence the number of conversions can never be more than the number of tries.\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[tcp = scorebreakdown(12)\\n\\ntcp =\\n     2     1     0\\n     0     0     4\\n     ]]\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\u003eTwo tries = 2*5 = 10 points. One conversion = 2 points. Total = 10 + 2 = 12.\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\u003eFour penalties = 4*3 = 12 points.\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\u003eNote that 1 try, 2 conversions, and 1 penalty would total 12 points, but is not allowed because it is not possible to have more conversions than tries.\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(This problem can be treated as finding all integer linear combinations of 5, 2, and 3, such that 5a + 2b + 3c = s, but with a restriction: b \u0026lt;= a.)\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\"}]}"}],"term":"tag:\"rugby\"","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:\"rugby\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"rugby\"","","\"","rugby","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f5350aee6b0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f5350aee610\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f5350ae9b10\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f5350aef150\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f5350aeeed0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f5350aee930\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f5350aee890\u003e":"tag:\"rugby\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f5350aee890\u003e":"tag:\"rugby\""},"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":"search","password":"J3bGPZzQ7asjJcCk","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:\"rugby\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"rugby\"","","\"","rugby","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f5350aee6b0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f5350aee610\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f5350ae9b10\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f5350aef150\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f5350aeeed0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f5350aee930\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f5350aee890\u003e":"tag:\"rugby\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f5350aee890\u003e":"tag:\"rugby\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":56195,"difficulty_rating":"easy-medium"}]}}