{"group":{"group":{"id":17,"name":"Computational Geometry I","lockable":false,"created_at":"2017-01-24T19:17:18.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Computational geometry is one of the oldest fields of computing. Test your knowledge of geometric-based algorithms.","is_default":false,"created_by":26769,"badge_id":31,"featured":false,"trending":false,"solution_count_in_trending_period":12,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":396,"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":"{\"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\u003eComputational geometry is one of the oldest fields of computing. Test your knowledge of geometric-based algorithms.\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\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; 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: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 21px; transform-origin: 289.5px 21px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; perspective-origin: 266.5px 21px; transform-origin: 266.5px 21px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eComputational geometry is one of the oldest fields of computing. Test your knowledge of geometric-based algorithms.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2019-05-08T19:55:20.000Z"},"current_player":null},"problems":[{"id":1103,"title":"Right Triangle Side Lengths (Inspired by Project Euler Problem 39)","description":"If p is the perimeter of a right angle triangle with integral length sides, { a, b, c }, there are exactly three solutions for p = 120.\r\n{[20,48,52], [24,45,51], [30,40,50]}\r\nGiven any value of p, return a cell array whose elements are the sorted side lengths of a possible right triangle whose perimeter is p. Furthermore, the elements of the output should be sorted by their shortest side length.","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: 123px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.5px; transform-origin: 407px 61.5px; 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: 3.5px 8px; transform-origin: 3.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ep\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: 212px 8px; transform-origin: 212px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is the perimeter of a right angle triangle with integral length sides, {\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ea\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003eb\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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: 3.5px 8px; transform-origin: 3.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ec\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: 120px 8px; transform-origin: 120px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e }, there are exactly three solutions for\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ep\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: 8px 8px; transform-origin: 8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e = 120.\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: 109px 8px; transform-origin: 109px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e{[20,48,52], [24,45,51], [30,40,50]}\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: 59px 8px; transform-origin: 59px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven any value of\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ep\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: 306.5px 8px; transform-origin: 306.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, return a cell array whose elements are the sorted side lengths of a possible right triangle whose perimeter is\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ep\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: 276.5px 8px; transform-origin: 276.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Furthermore, the elements of the output should be sorted by their shortest side length.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function c = right_triangle_sides(p)\r\n  c = {[p p p]};\r\nend","test_suite":"%%\r\nassert(isequal(right_triangle_sides(240),{ [15 112 113] [40 96 104] [48 90 102] [60 80 100] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(12),{ [3 4 5] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(418),{ [57 176 185] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(490),{ [140 147 203] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(112),{ [14 48 50] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(390),{ [52 165 173] [65 156 169] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(132),{ [11 60 61] [33 44 55] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(576),{ [64 252 260] [144 192 240] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(60),{ [10 24 26] [15 20 25] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(650),{ [25 312 313] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(732),{ [183 244 305] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(648),{ [162 216 270] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(930),{ [155 372 403] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(876),{ [219 292 365] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(588),{ [84 245 259] [147 196 245] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(208),{ [39 80 89] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(228),{ [57 76 95] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(312),{ [24 143 145] [78 104 130] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(924),{ [42 440 442] [77 420 427] [132 385 407] [198 336 390] [231 308 385] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(980),{ [280 294 406] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(112),{ [14 48 50] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(30),{ [5 12 13] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(680),{ [102 280 298] [136 255 289] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(396),{ [33 180 183] [72 154 170] [99 132 165] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(988),{ [266 312 410] }))\r\n\r\n","published":true,"deleted":false,"likes_count":37,"comments_count":9,"created_by":134,"edited_by":223089,"edited_at":"2023-02-02T09:19:18.000Z","deleted_by":null,"deleted_at":null,"solvers_count":2045,"test_suite_updated_at":"2023-02-02T09:19:18.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-12-07T06:24:10.000Z","updated_at":"2026-04-06T23:02:14.000Z","published_at":"2012-12-07T06:24: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\u003eIf\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the perimeter of a right angle triangle with integral length sides, {\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ec\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e }, there are exactly three solutions for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e = 120.\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{[20,48,52], [24,45,51], [30,40,50]}\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\u003eGiven any value of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, return a cell array whose elements are the sorted side lengths of a possible right triangle whose perimeter is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Furthermore, the elements of the output should be sorted by their shortest side length.\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":769,"title":"Calculate the area of a triangle between three points","description":"Calculate the area of a triangle between three points:\r\nP1(X1,Y1)\r\nP2(X2,Y2)\r\nP3(X3,Y3)\r\nthese three points are the vertices of the triangle.","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: 141px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 70.5px; transform-origin: 407px 70.5px; vertical-align: baseline; \"\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: 167.5px 8px; transform-origin: 167.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCalculate the area of a triangle between three points:\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: 32px 8px; transform-origin: 32px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eP1(X1,Y1)\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: 32px 8px; transform-origin: 32px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eP2(X2,Y2)\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: 32px 8px; transform-origin: 32px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eP3(X3,Y3)\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: 155.5px 8px; transform-origin: 155.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethese three points are the vertices of the triangle.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"% X=[x1 x2 x3]\r\n% Y=[y1 y2 y3]\r\nfunction y = your_fcn_name(X,Y)\r\n  y = X.*Y;\r\nend","test_suite":"%%\r\nX=[1 0 0];\r\nY=[0 0 1];\r\ny_correct = 0.5;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)\r\n\r\n%%\r\nX=[1 1.5 2];\r\nY=[0 1 0];\r\ny_correct = 0.5;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)\r\n\r\n%%\r\nX=[2 3 1];\r\nY=[0 3 4];\r\ny_correct = 3.500;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)\r\n\r\n%%\r\nX=[10 12 -10];\r\nY=[-7 -3 -47];\r\ny_correct = 0;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)\r\n\r\n%%\r\nX=[0 5 0];\r\nY=[6 0 0];\r\ny_correct = 15;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)","published":true,"deleted":false,"likes_count":32,"comments_count":6,"created_by":4320,"edited_by":223089,"edited_at":"2023-02-02T09:07:51.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3428,"test_suite_updated_at":"2023-02-02T09:07:51.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-06-15T14:26:12.000Z","updated_at":"2026-04-06T23:09:50.000Z","published_at":"2012-06-15T14:26:12.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\u003eCalculate the area of a triangle between three 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\u003eP1(X1,Y1)\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\u003eP2(X2,Y2)\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\u003eP3(X3,Y3)\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\u003ethese three points are the vertices of the triangle.\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":1103,"title":"Right Triangle Side Lengths (Inspired by Project Euler Problem 39)","description":"If p is the perimeter of a right angle triangle with integral length sides, { a, b, c }, there are exactly three solutions for p = 120.\r\n{[20,48,52], [24,45,51], [30,40,50]}\r\nGiven any value of p, return a cell array whose elements are the sorted side lengths of a possible right triangle whose perimeter is p. Furthermore, the elements of the output should be sorted by their shortest side length.","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: 123px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.5px; transform-origin: 407px 61.5px; 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: 3.5px 8px; transform-origin: 3.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ep\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: 212px 8px; transform-origin: 212px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is the perimeter of a right angle triangle with integral length sides, {\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ea\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003eb\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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: 3.5px 8px; transform-origin: 3.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003ec\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: 120px 8px; transform-origin: 120px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e }, there are exactly three solutions for\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ep\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: 8px 8px; transform-origin: 8px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e = 120.\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: 109px 8px; transform-origin: 109px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e{[20,48,52], [24,45,51], [30,40,50]}\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: 59px 8px; transform-origin: 59px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven any value of\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ep\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: 306.5px 8px; transform-origin: 306.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, return a cell array whose elements are the sorted side lengths of a possible right triangle whose perimeter is\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \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; \"\u003ep\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: 276.5px 8px; transform-origin: 276.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. Furthermore, the elements of the output should be sorted by their shortest side length.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function c = right_triangle_sides(p)\r\n  c = {[p p p]};\r\nend","test_suite":"%%\r\nassert(isequal(right_triangle_sides(240),{ [15 112 113] [40 96 104] [48 90 102] [60 80 100] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(12),{ [3 4 5] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(418),{ [57 176 185] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(490),{ [140 147 203] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(112),{ [14 48 50] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(390),{ [52 165 173] [65 156 169] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(132),{ [11 60 61] [33 44 55] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(576),{ [64 252 260] [144 192 240] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(60),{ [10 24 26] [15 20 25] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(650),{ [25 312 313] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(732),{ [183 244 305] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(648),{ [162 216 270] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(930),{ [155 372 403] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(876),{ [219 292 365] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(588),{ [84 245 259] [147 196 245] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(208),{ [39 80 89] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(228),{ [57 76 95] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(312),{ [24 143 145] [78 104 130] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(924),{ [42 440 442] [77 420 427] [132 385 407] [198 336 390] [231 308 385] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(980),{ [280 294 406] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(112),{ [14 48 50] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(30),{ [5 12 13] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(680),{ [102 280 298] [136 255 289] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(396),{ [33 180 183] [72 154 170] [99 132 165] }))\r\n\r\n%%\r\nassert(isequal(right_triangle_sides(988),{ [266 312 410] }))\r\n\r\n","published":true,"deleted":false,"likes_count":37,"comments_count":9,"created_by":134,"edited_by":223089,"edited_at":"2023-02-02T09:19:18.000Z","deleted_by":null,"deleted_at":null,"solvers_count":2045,"test_suite_updated_at":"2023-02-02T09:19:18.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-12-07T06:24:10.000Z","updated_at":"2026-04-06T23:02:14.000Z","published_at":"2012-12-07T06:24: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\u003eIf\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the perimeter of a right angle triangle with integral length sides, {\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eb\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ec\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e }, there are exactly three solutions for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e = 120.\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{[20,48,52], [24,45,51], [30,40,50]}\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\u003eGiven any value of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, return a cell array whose elements are the sorted side lengths of a possible right triangle whose perimeter is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ep\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Furthermore, the elements of the output should be sorted by their shortest side length.\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":1072,"title":"Television Screen Dimensions","description":"Given a width to height ratio of a TV screen given as _w_ and _h_ as well as the diagonal length of the television _l_, return the actual width and height of the screen to one decimal point of precision.\r\n\r\nExample:\r\n\r\n    w = 16;\r\n    h = 9;\r\n    l = 42;\r\n    [W,H] = teledims(w,h,l);\r\n\r\noutputs\r\n\r\n    W = 36.6\r\n    H = 20.6","description_html":"\u003cp\u003eGiven a width to height ratio of a TV screen given as \u003ci\u003ew\u003c/i\u003e and \u003ci\u003eh\u003c/i\u003e as well as the diagonal length of the television \u003ci\u003el\u003c/i\u003e, return the actual width and height of the screen to one decimal point of precision.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e    w = 16;\r\n    h = 9;\r\n    l = 42;\r\n    [W,H] = teledims(w,h,l);\u003c/pre\u003e\u003cp\u003eoutputs\u003c/p\u003e\u003cpre\u003e    W = 36.6\r\n    H = 20.6\u003c/pre\u003e","function_template":"function [W,H] = teledims(w,h,l)\r\n  W = w*l;\r\n  H = h*l;\r\nend","test_suite":"%%\r\n[W,H]=teledims(2.4,1,46);\r\nassert(H == 17.7 \u0026\u0026 W == 42.5)\r\n\r\n%%\r\n[W,H]=teledims(4,3,32);\r\nassert(H == 19.2 \u0026\u0026 W == 25.6)\r\n\r\n%%\r\n[W,H]=teledims(3,2,60);\r\nassert(H == 33.3 \u0026\u0026 W == 49.9)\r\n\r\n%%\r\n[W,H]=teledims(1.85,1,42);\r\nassert(H == 20.0 \u0026\u0026 W == 36.9)\r\n\r\n%%\r\n[W,H]=teledims(3,2,1000);\r\nassert(H == 554.7 \u0026\u0026 W == 832.1)\r\n\r\n%%\r\n[W,H]=teledims(16,10,92);\r\nassert(H == 48.8 \u0026\u0026 W == 78.0)\r\n\r\n%%\r\n[W,H]=teledims(2.4,1,92);\r\nassert(H == 35.4 \u0026\u0026 W == 84.9)\r\n\r\n%%\r\n[W,H]=teledims(16,10,32);\r\nassert(H == 17.0 \u0026\u0026 W == 27.1)\r\n\r\n%%\r\n[W,H]=teledims(3,2,82);\r\nassert(H == 45.5 \u0026\u0026 W == 68.2)\r\n\r\n%%\r\n[W,H]=teledims(16,10,82);\r\nassert(H == 43.5 \u0026\u0026 W == 69.5)\r\n\r\n%%\r\n[W,H]=teledims(16,10,60);\r\nassert(H == 31.8 \u0026\u0026 W == 50.9)\r\n\r\n%%\r\n[W,H]=teledims(3,2,92);\r\nassert(H == 51.0 \u0026\u0026 W == 76.5)\r\n\r\n%%\r\n[W,H]=teledims(1.85,1,1000);\r\nassert(H == 475.5 \u0026\u0026 W == 879.7)\r\n\r\n%%\r\n[W,H]=teledims(2.4,1,42);\r\nassert(H == 16.2 \u0026\u0026 W == 38.8)\r\n\r\n%%\r\n[W,H]=teledims(1.85,1,27);\r\nassert(H == 12.8 \u0026\u0026 W == 23.8)\r\n\r\n%%\r\n[W,H]=teledims(16,10,82);\r\nassert(H == 43.5 \u0026\u0026 W == 69.5)\r\n\r\n%%\r\n[W,H]=teledims(4,3,46);\r\nassert(H == 27.6 \u0026\u0026 W == 36.8)\r\n\r\n%%\r\n[W,H]=teledims(2.4,1,60);\r\nassert(H == 23.1 \u0026\u0026 W == 55.4)\r\n\r\n%%\r\n[W,H]=teledims(4,3,92);\r\nassert(H == 55.2 \u0026\u0026 W == 73.6)\r\n\r\n%%\r\n[W,H]=teledims(1.85,1,60);\r\nassert(H == 28.5 \u0026\u0026 W == 52.8)\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":5,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":561,"test_suite_updated_at":"2012-12-04T21:15:03.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-11-27T21:06:09.000Z","updated_at":"2026-03-11T22:47:57.000Z","published_at":"2012-12-04T19:57:12.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\u003eGiven a width to height ratio of a TV screen given as\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ew\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eh\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as well as the diagonal length of the television\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003el\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, return the actual width and height of the screen to one decimal point of precision.\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\u003eExample:\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[    w = 16;\\n    h = 9;\\n    l = 42;\\n    [W,H] = teledims(w,h,l);]]\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\u003eoutputs\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[    W = 36.6\\n    H = 20.6]]\u003e\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":833,"title":"Find third Side of a right triangle given hypotenuse and a side. No  * - or other functions allowed","description":"Find the remaining side of a triangle given the hypotenuse and a side.\r\nHowever, the normal functions and symbols are not allowed.\r\n\r\nUnallowed functions and symbols: mtimes cross prod cumprod times mldivide mrdivide dot * / \\ - ^ '\r\n\r\nDerivative of Aurelien's \u003chttp://www.mathworks.com/matlabcentral/cody/problems/813-multiply-2-numbers Cody 813 Multiply 2 numbers\u003e\r\n\r\nTest suite disallowed function usage check courtesy of Aurelien Queffurust.\r\n\r\n\r\nExample : h= 5; x= 3;\r\n\r\noutput = 4 since y=(h^2-x^2)^0.5","description_html":"\u003cp\u003eFind the remaining side of a triangle given the hypotenuse and a side.\r\nHowever, the normal functions and symbols are not allowed.\u003c/p\u003e\u003cp\u003eUnallowed functions and symbols: mtimes cross prod cumprod times mldivide mrdivide dot * / \\ - ^ '\u003c/p\u003e\u003cp\u003eDerivative of Aurelien's \u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/813-multiply-2-numbers\"\u003eCody 813 Multiply 2 numbers\u003c/a\u003e\u003c/p\u003e\u003cp\u003eTest suite disallowed function usage check courtesy of Aurelien Queffurust.\u003c/p\u003e\u003cp\u003eExample : h= 5; x= 3;\u003c/p\u003e\u003cp\u003eoutput = 4 since y=(h^2-x^2)^0.5\u003c/p\u003e","function_template":"function y = triangle_side(h,x)\r\n  y = sqrt(h^2-x^2); % Neither ^ nor - are permitted\r\nend","test_suite":"%%\r\n% Courtesy of Aurelien Queffurust\r\nfiletext = fileread('triangle_side.m');\r\nassert(isempty(strfind(filetext, '*')),'sign * forbidden')\r\nassert(isempty(strfind(filetext, 'mtimes')),'mtimes forbidden')\r\nassert(isempty(strfind(filetext, 'cross')),'cross forbidden')\r\nassert(isempty(strfind(filetext, 'prod')),'prod forbidden')\r\nassert(isempty(strfind(filetext, 'cumprod')))\r\nassert(isempty(strfind(filetext, 'times')))\r\nassert(isempty(strfind(filetext, 'mldivide')))\r\nassert(isempty(strfind(filetext, 'mrdivide')))\r\nassert(isempty(strfind(filetext, '/')),'/ forbidden')\r\nassert(isempty(strfind(filetext, '\\')))\r\nassert(isempty(strfind(filetext, '-')))\r\nassert(isempty(strfind(filetext, '^')),'^ forbidden')\r\nassert(isempty(strfind(filetext, 'dot')))\r\nassert(isempty(strfind(filetext, '''')),'string forbidden')\r\nassert(isempty(strfind(filetext, 'num2str')))\r\nassert(isempty(strfind(filetext, 'int2str')))\r\nassert(isempty(strfind(filetext, 'dec2bin')))\r\n%%\r\nh=16;\r\nx=5+rand % No cheats allowed\r\ny_correct=round(1e6*sqrt(h^2-x^2))/1e6\r\nassert(isequal(round(1e6*triangle_side(h,x))/1e6,y_correct))\r\n%%\r\nh=5;\r\nx=3;\r\ny_correct=round(1e6*sqrt(h^2-x^2))/1e6\r\nassert(isequal(round(1e6*triangle_side(h,x))/1e6,y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":5,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":253,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":17,"created_at":"2012-07-15T04:59:54.000Z","updated_at":"2026-04-01T10:20:05.000Z","published_at":"2012-07-15T05:38:18.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\u003eFind the remaining side of a triangle given the hypotenuse and a side. However, the normal functions and symbols are not allowed.\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\u003eUnallowed functions and symbols: mtimes cross prod cumprod times mldivide mrdivide dot * / \\\\ - ^ '\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\u003eDerivative of Aurelien's\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/813-multiply-2-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody 813 Multiply 2 numbers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eTest suite disallowed function usage check courtesy of Aurelien Queffurust.\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\u003eExample : h= 5; x= 3;\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\u003eoutput = 4 since y=(h^2-x^2)^0.5\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":769,"title":"Calculate the area of a triangle between three points","description":"Calculate the area of a triangle between three points:\r\nP1(X1,Y1)\r\nP2(X2,Y2)\r\nP3(X3,Y3)\r\nthese three points are the vertices of the triangle.","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: 141px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 70.5px; transform-origin: 407px 70.5px; vertical-align: baseline; \"\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: 167.5px 8px; transform-origin: 167.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCalculate the area of a triangle between three points:\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: 32px 8px; transform-origin: 32px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eP1(X1,Y1)\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: 32px 8px; transform-origin: 32px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eP2(X2,Y2)\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: 32px 8px; transform-origin: 32px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eP3(X3,Y3)\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: 155.5px 8px; transform-origin: 155.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ethese three points are the vertices of the triangle.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"% X=[x1 x2 x3]\r\n% Y=[y1 y2 y3]\r\nfunction y = your_fcn_name(X,Y)\r\n  y = X.*Y;\r\nend","test_suite":"%%\r\nX=[1 0 0];\r\nY=[0 0 1];\r\ny_correct = 0.5;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)\r\n\r\n%%\r\nX=[1 1.5 2];\r\nY=[0 1 0];\r\ny_correct = 0.5;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)\r\n\r\n%%\r\nX=[2 3 1];\r\nY=[0 3 4];\r\ny_correct = 3.500;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)\r\n\r\n%%\r\nX=[10 12 -10];\r\nY=[-7 -3 -47];\r\ny_correct = 0;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)\r\n\r\n%%\r\nX=[0 5 0];\r\nY=[6 0 0];\r\ny_correct = 15;\r\nassert(abs(your_fcn_name(X,Y)-y_correct)\u003c1e-3)","published":true,"deleted":false,"likes_count":32,"comments_count":6,"created_by":4320,"edited_by":223089,"edited_at":"2023-02-02T09:07:51.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3428,"test_suite_updated_at":"2023-02-02T09:07:51.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-06-15T14:26:12.000Z","updated_at":"2026-04-06T23:09:50.000Z","published_at":"2012-06-15T14:26:12.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\u003eCalculate the area of a triangle between three 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\u003eP1(X1,Y1)\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\u003eP2(X2,Y2)\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\u003eP3(X3,Y3)\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\u003ethese three points are the vertices of the triangle.\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":768,"title":"Are all the three given point in the same line?","description":"In this problem the input is the coordinate of the three points in a XY plane?\r\n\r\nP1(X1,Y1)\r\n\r\nP2(X2,Y2)\r\n\r\nP3(X3,Y3)\r\n\r\nhow can we find out if all the three points are on the same line or not?\r\n\r\nfor example the points (1,1) , (-1,-1) , (0,0) are on the line y=x.","description_html":"\u003cp\u003eIn this problem the input is the coordinate of the three points in a XY plane?\u003c/p\u003e\u003cp\u003eP1(X1,Y1)\u003c/p\u003e\u003cp\u003eP2(X2,Y2)\u003c/p\u003e\u003cp\u003eP3(X3,Y3)\u003c/p\u003e\u003cp\u003ehow can we find out if all the three points are on the same line or not?\u003c/p\u003e\u003cp\u003efor example the points (1,1) , (-1,-1) , (0,0) are on the line y=x.\u003c/p\u003e","function_template":"% inputs are vectors;\r\n% X=[x1 x2 x3];\r\n% Y=[y1 y2 y3];\r\nfunction y = your_fcn_name(X,Y)\r\n  y = true;\r\nend","test_suite":"%%\r\nX = [-1 1 0];\r\nY=[-1 1 0];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(X,Y),y_correct))\r\n\r\n%%\r\nX = [0 3 6];\r\nY=[5 7 9];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(X,Y),y_correct))\r\n\r\n%%\r\nX = [0 7 14];\r\nY=[-7 -5 -3];\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(X,Y),y_correct))\r\n\r\n%%\r\nX = [10 12 -10];\r\nY=[-7 -3 47];\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(X,Y),y_correct))\r\n\r\n%%\r\nX = [0 0.8 1];\r\nY=[0.2 1 1];\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(X,Y),y_correct))\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":1,"created_by":4320,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":603,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":17,"created_at":"2012-06-15T13:30:42.000Z","updated_at":"2026-03-13T04:50:21.000Z","published_at":"2012-06-15T13:30:43.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eIn this problem the input is the coordinate of the three points in a XY plane?\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\u003eP1(X1,Y1)\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\u003eP2(X2,Y2)\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\u003eP3(X3,Y3)\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\u003ehow can we find out if all the three points are on the same line or not?\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 example the points (1,1) , (-1,-1) , (0,0) are on the line y=x.\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":637,"title":"Volume of a Parallelepiped","description":"Calculate the volume of a Parallelepiped given the vectors for three edges that meet at one vertex.\r\n\r\nA cube is a special case of a Parallelepiped.\r\n\r\nvectors=[1 0 0;0 1 0;0 0 1]; % Unity Cube\r\n\r\nV=1;\r\n\r\nvectors=[2 0 0;0 2 0;1 0 1]; % 45 degree half height Parallelepiped\r\n\r\nV=4;\r\n\r\n","description_html":"\u003cp\u003eCalculate the volume of a Parallelepiped given the vectors for three edges that meet at one vertex.\u003c/p\u003e\u003cp\u003eA cube is a special case of a Parallelepiped.\u003c/p\u003e\u003cp\u003evectors=[1 0 0;0 1 0;0 0 1]; % Unity Cube\u003c/p\u003e\u003cp\u003eV=1;\u003c/p\u003e\u003cp\u003evectors=[2 0 0;0 2 0;1 0 1]; % 45 degree half height Parallelepiped\u003c/p\u003e\u003cp\u003eV=4;\u003c/p\u003e","function_template":"function V = Parallelepiped_volume(vectors)\r\n  V=0;\r\nend","test_suite":"%%\r\nvectors=[1 0 0;0 1 0;0 0 1]; % Unity Cube\r\nV=1;\r\nassert(isequal(Parallelepiped_volume(vectors),V))\r\n%%\r\nvectors=[2 0 0;0 2 0;0 0 2]; % 2x2x2 Cube\r\nV=8;\r\nassert(isequal(Parallelepiped_volume(vectors),V))\r\n%%\r\nvectors=[2 0 0;0 2 0;1 0 1]; % Slanted one side 45 degrees, half h\r\nV=4;\r\nassert(isequal(Parallelepiped_volume(vectors),V))\r\n%%\r\nvectors=[2^0.5 2^0.5 0;-2^0.5 2^0.5 0;0 0 2]; % Rot 45,\r\nV=8;\r\nassert(V-.001\u003cParallelepiped_volume(vectors) \u0026\u0026 Parallelepiped_volume(vectors)\u003cV+.001)\r\n%%\r\nvectors=[2^0.5 2^0.5 0;-2^0.5 2^0.5 0;0 1 1]; % Rot 45, Slant 45, h/2\r\nV=4;\r\nassert(V-.001\u003cParallelepiped_volume(vectors) \u0026\u0026 Parallelepiped_volume(vectors)\u003cV+.001)\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":465,"test_suite_updated_at":"2012-04-29T18:51:39.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-04-29T18:07:38.000Z","updated_at":"2026-03-11T22:13:33.000Z","published_at":"2012-04-29T18:51:39.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eCalculate the volume of a Parallelepiped given the vectors for three edges that meet at one vertex.\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 cube is a special case of a Parallelepiped.\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\u003evectors=[1 0 0;0 1 0;0 0 1]; % Unity Cube\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\u003eV=1;\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\u003evectors=[2 0 0;0 2 0;1 0 1]; % 45 degree half height Parallelepiped\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\u003eV=4;\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":636,"title":"Spherical radius given four points","description":"Determine the radius of a sphere provided four non-coplanar points on the surface of the sphere.\r\n\r\n pts = [x1 y1 z1;\r\n        x2 y2 z2;\r\n        x3 y3 z3;\r\n        x4 y4 z4]\r\n\r\nHint: See \u003chttp://steve.hollasch.net/cgindex/geometry/sphere4pts.html\u003e\r\n\r\nExample: \r\n\r\n pts = [1 0 0;\r\n        0 1 0;\r\n        0 0 1;\r\n       -1 0 0]\r\n r=1","description_html":"\u003cp\u003eDetermine the radius of a sphere provided four non-coplanar points on the surface of the sphere.\u003c/p\u003e\u003cpre\u003e pts = [x1 y1 z1;\r\n        x2 y2 z2;\r\n        x3 y3 z3;\r\n        x4 y4 z4]\u003c/pre\u003e\u003cp\u003eHint: See \u003ca href=\"http://steve.hollasch.net/cgindex/geometry/sphere4pts.html\"\u003ehttp://steve.hollasch.net/cgindex/geometry/sphere4pts.html\u003c/a\u003e\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e pts = [1 0 0;\r\n        0 1 0;\r\n        0 0 1;\r\n       -1 0 0]\r\n r=1\u003c/pre\u003e","function_template":"function r = Sphere_radius(pts)\r\n  r = 1;\r\nend","test_suite":"%%\r\npts=[0 3 2;1 -1 1;2 1 0;5 1 3]; % c(2 1 3) r=3\r\ny_correct = 3;\r\nassert(isequal(Sphere_radius(pts),y_correct))\r\n%%\r\n pts=[1 0 0;0 1 0;0 0 1;-1 0 0]; % c(0 0 0) r=1\r\ny_correct = 1;\r\nassert(isequal(Sphere_radius(pts),y_correct))\r\n%%\r\npts=[1 0 -1;0 1 -1;0 0 0;-1 0 -1]; % c(0 0 -1) r=1\r\ny_correct = 1;\r\nassert(isequal(Sphere_radius(pts),y_correct))\r\n%%\r\npts=[2 0 -2;0 2 -2;0 0 0;-2 0 -2]; % c(0 0 -2) r=2\r\ny_correct = 2;\r\nassert(isequal(Sphere_radius(pts),y_correct))\r\n%%\r\npts=[-5 -1 -3;1 -1 -3;-2 -4 -3;-2 -1 0]; % c(-2 -1 -3) r=3\r\ny_correct = 3;\r\nassert(isequal(Sphere_radius(pts),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":254,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":17,"created_at":"2012-04-29T17:20:14.000Z","updated_at":"2026-03-13T04:56:44.000Z","published_at":"2012-04-29T17:20:14.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\u003eDetermine the radius of a sphere provided four non-coplanar points on the surface of the sphere.\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[ pts = [x1 y1 z1;\\n        x2 y2 z2;\\n        x3 y3 z3;\\n        x4 y4 z4]]]\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\u003eHint: See\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://steve.hollasch.net/cgindex/geometry/sphere4pts.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://steve.hollasch.net/cgindex/geometry/sphere4pts.html\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eExample:\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[ pts = [1 0 0;\\n        0 1 0;\\n        0 0 1;\\n       -1 0 0]\\n r=1]]\u003e\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":635,"title":"Angle between Two Vectors","description":"The dot product relationship, a dot b = | a | | b | cos(theta), can be used to determine the acute angle between vector a and vector b ( 0 to pi ).\r\n \r\nThe definition of | a | is ( a(1)a(1)+a(2)a(2)...+a(n)a(n) )^0.5. \r\n\r\nThe definition of \"a dot b\" is a(1)b(1)+a(2)b(2)...+a(n)b(n). (wikipedia)\r\n\r\nIn 3-D the angle is in the plane created by the vectors a and b. \r\n \r\nThe input may be a 2-D or a 3-D vector. These represent physical models. \r\n\r\nAn extension of this angular determination given vectors problem is to provide two points for each vector.\r\nThe practical application relates to Laser Trackers which best fit multiple points for lines, surfaces, annular surfaces, and other reference points.\r\n\r\nExamples:\r\n\r\na=[1 0] (x-axis); b=[0 1] (y-axis) which intersect at 90 degrees (pi/2)\r\n\r\ntheta=acos(a dot b/(|a||b|)=acos(0/(1*1))=pi/2 radians\r\n\r\n\r\na=[1 1 0] 45 degrees in xy plane\r\nb=[1 1 1.414] 45 degree vector in Z above a 45 degree rotation in XY plane.\r\n\r\ntheta=acos(a dot b/(|a||b|)=acos(2/(1.414*2))=pi/4 radians","description_html":"\u003cp\u003eThe dot product relationship, a dot b = | a | | b | cos(theta), can be used to determine the acute angle between vector a and vector b ( 0 to pi ).\u003c/p\u003e\u003cp\u003eThe definition of | a | is ( a(1)a(1)+a(2)a(2)...+a(n)a(n) )^0.5.\u003c/p\u003e\u003cp\u003eThe definition of \"a dot b\" is a(1)b(1)+a(2)b(2)...+a(n)b(n). (wikipedia)\u003c/p\u003e\u003cp\u003eIn 3-D the angle is in the plane created by the vectors a and b.\u003c/p\u003e\u003cp\u003eThe input may be a 2-D or a 3-D vector. These represent physical models.\u003c/p\u003e\u003cp\u003eAn extension of this angular determination given vectors problem is to provide two points for each vector.\r\nThe practical application relates to Laser Trackers which best fit multiple points for lines, surfaces, annular surfaces, and other reference points.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cp\u003ea=[1 0] (x-axis); b=[0 1] (y-axis) which intersect at 90 degrees (pi/2)\u003c/p\u003e\u003cp\u003etheta=acos(a dot b/(|a||b|)=acos(0/(1*1))=pi/2 radians\u003c/p\u003e\u003cp\u003ea=[1 1 0] 45 degrees in xy plane\r\nb=[1 1 1.414] 45 degree vector in Z above a 45 degree rotation in XY plane.\u003c/p\u003e\u003cp\u003etheta=acos(a dot b/(|a||b|)=acos(2/(1.414*2))=pi/4 radians\u003c/p\u003e","function_template":"function theta = solve_included_vector_angle(a,b)\r\n  theta=0;\r\nend","test_suite":"%%\r\na = [1 0];\r\nb = [0 1];\r\nexpected=pi/2;\r\ntheta = solve_included_vector_angle(a,b)\r\n\r\nassert(0.99*expected-.001\u003c=theta \u0026\u0026 theta\u003c=expected*1.01+.001 )\r\n% Is there a better way to allow tolerances?\r\n%%\r\na = [1 1 0];\r\nb = [1 1 2^0.5];\r\nexpected=pi/4;\r\ntheta = solve_included_vector_angle(a,b)\r\n\r\nassert(0.99*expected-.001\u003c=theta \u0026\u0026 theta\u003c=expected*1.01+.001 )\r\n%%\r\na = [2 2];\r\nb = [0 1];\r\nexpected=pi/4;\r\ntheta = solve_included_vector_angle(a,b)\r\n\r\nassert(0.99*expected-.001\u003c=theta \u0026\u0026 theta\u003c=expected*1.01+.001 )\r\n%%\r\na = [-1 1];\r\nb = [4 0];\r\nexpected=0.75*pi;\r\ntheta = solve_included_vector_angle(a,b)\r\n\r\nassert(0.99*expected-.001\u003c=theta \u0026\u0026 theta\u003c=expected*1.01+.001 )\r\n%%\r\na = [-1 2 3];\r\nb = [1 2 4];\r\nexpected=0.161*pi;\r\ntheta = solve_included_vector_angle(a,b)\r\n\r\nassert(0.99*expected-.001\u003c=theta \u0026\u0026 theta\u003c=expected*1.01+.001 )\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":527,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":17,"created_at":"2012-04-29T06:36:01.000Z","updated_at":"2026-02-27T10:33:38.000Z","published_at":"2012-04-29T06:36:01.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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 dot product relationship, a dot b = | a | | b | cos(theta), can be used to determine the acute angle between vector a and vector b ( 0 to pi ).\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\u003eThe definition of | a | is ( a(1)a(1)+a(2)a(2)...+a(n)a(n) )^0.5.\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\u003eThe definition of \\\"a dot b\\\" is a(1)b(1)+a(2)b(2)...+a(n)b(n). (wikipedia)\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 3-D the angle is in the plane created by the vectors a and b.\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\u003eThe input may be a 2-D or a 3-D vector. These represent physical models.\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\u003eAn extension of this angular determination given vectors problem is to provide two points for each vector. The practical application relates to Laser Trackers which best fit multiple points for lines, surfaces, annular surfaces, and other reference 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\u003eExamples:\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=[1 0] (x-axis); b=[0 1] (y-axis) which intersect at 90 degrees (pi/2)\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\u003etheta=acos(a dot b/(|a||b|)=acos(0/(1*1))=pi/2 radians\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=[1 1 0] 45 degrees in xy plane b=[1 1 1.414] 45 degree vector in Z above a 45 degree rotation in XY plane.\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\u003etheta=acos(a dot b/(|a||b|)=acos(2/(1.414*2))=pi/4 radians\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":554,"title":"Is the Point in a Circle?","description":"Check whether a point or multiple points is/are in a circle centered at point (x0, y0) with radius r. \r\n\r\n Points = [x, y]; \r\n circle = (x0, y0, r)\r\n\r\nReturn true or false for each point tested","description_html":"\u003cp\u003eCheck whether a point or multiple points is/are in a circle centered at point (x0, y0) with radius r.\u003c/p\u003e\u003cpre\u003e Points = [x, y]; \r\n circle = (x0, y0, r)\u003c/pre\u003e\u003cp\u003eReturn true or false for each point tested\u003c/p\u003e","function_template":"function y = your_fcn_name(Points, circle)\r\n  y = true;\r\nend","test_suite":"%%\r\ncircle = [0, 0, 1]; Points = [0, 0.5]\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(Points,circle),y_correct))\r\n\r\n%%\r\ncircle = [0, 0, 1]; Points = [0, 2]\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(Points,circle),y_correct))\r\n\r\n%%\r\ncircle = [1, 1, 1]; Points = [0, 1; 0, 0]\r\ny_correct = [1; 0];\r\nassert(isequal(your_fcn_name(Points,circle),y_correct))","published":true,"deleted":false,"likes_count":5,"comments_count":8,"created_by":2906,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":631,"test_suite_updated_at":"2012-04-03T14:19:00.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-04-03T08:03:10.000Z","updated_at":"2026-03-13T05:02:27.000Z","published_at":"2012-04-03T08:03: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\u003eCheck whether a point or multiple points is/are in a circle centered at point (x0, y0) with radius r.\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[ Points = [x, y]; \\n circle = (x0, y0, r)]]\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\u003eReturn true or false for each point tested\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":450,"title":"What is the distance from point P(x,y) to the line Ax + By + C = 0?","description":"Given a point, P(x,y), find the distance from this point to a linear line.\r\n\r\nINPUTS: x, y, A, B, C\r\n\r\nOUTPUTS: d, the distance which of course should always be positive.\r\n    \r\n  EX:\r\n  \u003e\u003ex=2; y=2; A=2; B=2; C=-4;\r\n  \u003e\u003ed = normalLen(x,y,A,B,C)\r\n  d = 1.4142\r\n\r\n\r\n","description_html":"\u003cp\u003eGiven a point, P(x,y), find the distance from this point to a linear line.\u003c/p\u003e\u003cp\u003eINPUTS: x, y, A, B, C\u003c/p\u003e\u003cp\u003eOUTPUTS: d, the distance which of course should always be positive.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eEX:\r\n\u003e\u003ex=2; y=2; A=2; B=2; C=-4;\r\n\u003e\u003ed = normalLen(x,y,A,B,C)\r\nd = 1.4142\r\n\u003c/pre\u003e","function_template":"function d = normalLen(x,y,A,B,C)\r\n  d = x+y+[A,B,C]\r\nend","test_suite":"%% test 1\r\nx=2; y=2; A=2; B=2; C=-4;\r\ny_correct = 1.4142;\r\nassert(abs(normalLen(x,y,A,B,C)-y_correct)\u003c=1e-4)\r\n%% test 2\r\nx=3; y=4; A=3; B=4; C=5;\r\ny_correct = 6;\r\nassert(normalLen(x,y,A,B,C)-y_correct==0)\r\n%% test 3\r\nx=4; y=5; A=3; B=4; C=5;\r\ny_correct = 7.4;\r\ndisplay(normalLen(x,y,A,B,C))\r\nassert(abs(normalLen(x,y,A,B,C)-y_correct)\u003c1e-1)\r\n%% test 4\r\nx=0;y=12345;A=0;B=1;C=0;\r\ny_correct = 12345;\r\ndisplay(normalLen(x,y,A,B,C))\r\nassert(abs(normalLen(x,y,A,B,C)-y_correct)==0)\r\n%% test 5\r\nx=0;y=-12345;A=0;B=1;C=0;\r\ny_correct = 12345;\r\ndisplay(normalLen(x,y,A,B,C))\r\nassert(abs(normalLen(x,y,A,B,C)-y_correct)==0)\r\n\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":2,"created_by":1103,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":560,"test_suite_updated_at":"2013-01-26T00:45:07.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-03-05T04:51:25.000Z","updated_at":"2026-03-13T05:04:32.000Z","published_at":"2012-03-06T06:29:12.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\u003eGiven a point, P(x,y), find the distance from this point to a linear line.\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\u003eINPUTS: x, y, A, B, C\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\u003eOUTPUTS: d, the distance which of course should always be positive.\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[EX:\\n\u003e\u003ex=2; y=2; A=2; B=2; C=-4;\\n\u003e\u003ed = normalLen(x,y,A,B,C)\\nd = 1.4142]]\u003e\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":417,"title":"Covering area","description":"As an extension of the problem \u003chttp://www.mathworks.com/matlabcentral/cody/problems/416-polygon-area\u003e, find the area, bounded by the border of the group of several points.\r\n\r\nExample:\r\n\r\n C = [1 -1; 1 1; -1 -1; -1 1; 0 0];\r\n \r\n \u003e\u003e cover_area(C)\r\n \r\n ans =\r\n \r\n     4","description_html":"\u003cp\u003eAs an extension of the problem \u003ca href=\"http://www.mathworks.com/matlabcentral/cody/problems/416-polygon-area\"\u003ehttp://www.mathworks.com/matlabcentral/cody/problems/416-polygon-area\u003c/a\u003e, find the area, bounded by the border of the group of several points.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e C = [1 -1; 1 1; -1 -1; -1 1; 0 0];\u003c/pre\u003e\u003cpre\u003e \u003e\u003e cover_area(C)\u003c/pre\u003e\u003cpre\u003e ans =\u003c/pre\u003e\u003cpre\u003e     4\u003c/pre\u003e","function_template":"function s=cover_area(coords)\r\ns=0;\r\nend","test_suite":"%%\r\nx = [1 1; 1 -1; -1 1; -1 -1; 0 0];\r\ny_correct = 4;\r\nassert(isequal(cover_area(x),y_correct))\r\n\r\n%%\r\nx = [1 1; 1 -2; -2 1; -1 -2; 2 -1; -3 0; 0.2*randn(4,2)];\r\ny_correct = 11;\r\nassert(isequal(cover_area(x),y_correct))\r\n\r\n%%\r\nx = [1 1; 1 -2; -1 1; -1 -2; 3 4; 0.2*randn(10,2)];\r\ny_correct = 12;\r\nassert(isequal(cover_area(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":530,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":244,"test_suite_updated_at":"2012-02-26T21:26:15.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-02-26T21:26:15.000Z","updated_at":"2026-03-13T05:07:46.000Z","published_at":"2012-02-27T02:09:55.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\u003eAs an extension of the problem\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/416-polygon-area\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://www.mathworks.com/matlabcentral/cody/problems/416-polygon-area\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, find the area, bounded by the border of the group of several 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\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[ C = [1 -1; 1 1; -1 -1; -1 1; 0 0];\\n\\n \u003e\u003e cover_area(C)\\n\\n ans =\\n\\n     4]]\u003e\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":392,"title":"Clock Hand Angle 1","description":"Given a time in HH:MM:SS, find the smallest angle (in degrees) between the hour and minute hand","description_html":"\u003cp\u003eGiven a time in HH:MM:SS, find the smallest angle (in degrees) between the hour and minute hand\u003c/p\u003e","function_template":"function theta = handAngle(HHMMSS)\r\n  theta = 0;\r\nend","test_suite":"%%\r\nassert(abs(handAngle('12:00:00')-0) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('03:28:07')-64.6416666667) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('12:26:23')-145.1083333333) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('09:50:12')-6.1000000000) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('07:06:30')-174.2500000000) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('06:08:21')-134.0750000000) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('01:11:58')-35.8166666667) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('09:24:56')-132.8666666667) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('01:50:04')-114.6333333333) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('01:49:45')-116.3750000000) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('07:04:17')-173.5583333333) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('02:24:26')-74.3833333333) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('10:32:33')-120.9750000000) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('10:26:57')-151.7750000000) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('09:40:26')-47.6166666667) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('02:38:59')-154.4083333333) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('08:18:19')-139.2583333333) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('07:26:43')-63.0583333333) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('12:01:40')-9.1666666667) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('08:60:33')-93.0250000000) \u003c 1e-9)\r\n\r\n%%\r\nassert(abs(handAngle('10:11:42')-124.3500000000) \u003c 1e-9)","published":true,"deleted":false,"likes_count":9,"comments_count":5,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":312,"test_suite_updated_at":"2012-02-23T17:23:47.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-02-23T17:02:01.000Z","updated_at":"2026-03-13T05:18:50.000Z","published_at":"2012-02-23T17:23:55.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eGiven a time in HH:MM:SS, find the smallest angle (in degrees) between the hour and minute hand\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":381,"title":"Angle between two vectors","description":"You have two vectors , determine the angle between these two vectors \r\n\r\nFor example:\r\n\r\n  u = [0 0 1];\r\n  v = [1 0 0];\r\n\r\nThe angle in degrees between u and v is 90.","description_html":"\u003cp\u003eYou have two vectors , determine the angle between these two vectors\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eu = [0 0 1];\r\nv = [1 0 0];\r\n\u003c/pre\u003e\u003cp\u003eThe angle in degrees between u and v is 90.\u003c/p\u003e","function_template":"function angle_in_degrees = vector2angle(u,v)\r\n  angle_in_degrees= 180;\r\nend","test_suite":"%%\r\nu = [0.5 0.5 0];;\r\nv = [1 0 0];\r\nangle_in_degrees = vector2angle(u,v)\r\nassert(strcmp(num2str(angle_in_degrees),'45'))\r\n\r\n%% first new test added 08-June-2012\r\nu = [0 0 1];\r\nv = [1 0 0];\r\nangle_in_degrees = vector2angle(u,v)\r\nassert(strcmp(num2str(angle_in_degrees),'90'))\r\n\r\n%% second new test\r\nu = [0 0.8 1];\r\nv = [1 0.3 0];\r\nangle_in_degrees = vector2angle(u,v)\r\nassert(strcmp(num2str(round(angle_in_degrees)),'80'))","published":true,"deleted":false,"likes_count":2,"comments_count":6,"created_by":639,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":795,"test_suite_updated_at":"2012-06-08T07:01:01.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-02-22T08:38:54.000Z","updated_at":"2026-03-13T05:21:44.000Z","published_at":"2012-02-22T08:38:58.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\u003eYou have two vectors , determine the angle between these two vectors\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 example:\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[u = [0 0 1];\\nv = [1 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\u003eThe angle in degrees between u and v is 90.\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":336,"title":"Similar Triangles - find the height of the tree","description":"Given the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\r\n\r\n\r\nInputs: h1, x1, x2\r\n\r\nOutput: h2\r\n\r\nHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\r\n\r\nEX:\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\r\n\r\n\u003e\u003eh2=findHeight(x1,x2,h1)\r\n\r\nh2=6\r\n\r\n\u003e\u003e","description_html":"\u003cp\u003eGiven the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\u003c/p\u003e\u003cp\u003eInputs: h1, x1, x2\u003c/p\u003e\u003cp\u003eOutput: h2\u003c/p\u003e\u003cp\u003eHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\u003c/p\u003e\u003cp\u003eEX:\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\u003c/p\u003e\u003cp\u003e\u003e\u003eh2=findHeight(x1,x2,h1)\u003c/p\u003e\u003cp\u003eh2=6\u003c/p\u003e\u003cp\u003e\u003e\u003e\u003c/p\u003e","function_template":"function h2 = findHeight(x1,x2,h1)\r\n  h2 = heightoftree\r\nend","test_suite":"%%\r\nx1 = 4;\r\nx2 = 4;\r\nh1 = 3;\r\ny_correct = 6;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 8;\r\nh1 = 3;\r\ny_correct = 9;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 12;\r\nh1 = 3;\r\ny_correct = 12;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 16;\r\nh1 = 3;\r\ny_correct = 15;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 20;\r\nh1 = 3;\r\ny_correct = 18;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 24;\r\nh1 = 3;\r\ny_correct = 21;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 12;\r\nh1 = 5;\r\ny_correct = 20;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 4;\r\nx2 = 16;\r\nh1 = 10;\r\ny_correct = 50;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 2;\r\nx2 = 4;\r\nh1 = 5;\r\ny_correct = 15;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n%%\r\nx1 = 3;\r\nx2 = 6;\r\nh1 = 4;\r\ny_correct = 12;\r\nassert(isequal(findHeight(x1,x2,h1),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":6,"created_by":1103,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":469,"test_suite_updated_at":"2012-02-18T04:42:47.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-02-17T22:52:21.000Z","updated_at":"2026-03-13T05:26:44.000Z","published_at":"2012-02-18T04:42:47.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eGiven the height, h1, of a power pole, shorter than a tree, a given distance, x2 away, please find h2, height of the tree. Please note that the angle, phi, is the acute angle measured from the ground to an observer's line of sight aimed to the sucessive peaks of the power pole and the tree, in that order. Also the distance from the observer to the power pole is x1, also a given. x2 is the distance between the tree and the power pole. In all tests x1 is always a multiple of x2.\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\u003eInputs: h1, x1, x2\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\u003eOutput: h2\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\u003eHINT: find phi, given h1 and x1. Phi may be measured in degrees or radians. Note that default trig functions in MATLAB operate in radians.\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\u003eEX: x1 = 4; x2 = 4; h1 = 3;\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\u003e\u003eh2=findHeight(x1,x2,h1)\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\u003eh2=6\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\u003e\u003e\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":330,"title":"Circumscribed circles","description":"Given the lengths of the 3 sides of a triangle, output the radius of the circumscribed circle.\r\n\r\nExample:\r\n\r\n[3 4 5] -\u003e 2.5","description_html":"\u003cp\u003eGiven the lengths of the 3 sides of a triangle, output the radius of the circumscribed circle.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003e[3 4 5] -\u003e 2.5\u003c/p\u003e","function_template":"function y = circle_radius(x)\r\n  y = 1;\r\nend","test_suite":"%%\r\nx = [3 4 5];\r\ny_correct = 2.5;\r\nassert(isequal(circle_radius(x),y_correct))\r\n\r\n%%\r\nx = [3 4 3];\r\ny_correct = 2.0125;\r\nassert(abs(circle_radius(x)-y_correct)\u003c.0001)\r\n\r\n%%\r\nx = [1 2 sqrt(3)];\r\ny_correct = 1.0000;\r\nassert(abs(circle_radius(x)-y_correct)\u003c.0001)","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":1022,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":519,"test_suite_updated_at":"2012-02-17T05:37:05.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-02-17T05:32:35.000Z","updated_at":"2026-03-13T05:30:16.000Z","published_at":"2012-02-17T05:40:43.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eGiven the lengths of the 3 sides of a triangle, output the radius of the circumscribed circle.\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\u003eExample:\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[3 4 5] -\u003e 2.5\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":198,"title":"Are you in or are you out?","description":"Given vertices specified by the vectors xv and yv, and a single point specified by the numbers X and Y, return \"true\" if the point lies inside (or on the boundary) of the polygon defined by the vertices.\r\n\r\nExample:\r\n\r\n % The specified point is the center of the unit square:\r\n xv = [0 1 1 0];\r\n yv = [0 0 1 1];\r\n X = 0.5;\r\n Y = 0.5;\r\n\r\n inside(xv,yv,X,Y) -----\u003e true\r\n","description_html":"\u003cp\u003eGiven vertices specified by the vectors xv and yv, and a single point specified by the numbers X and Y, return \"true\" if the point lies inside (or on the boundary) of the polygon defined by the vertices.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e % The specified point is the center of the unit square:\r\n xv = [0 1 1 0];\r\n yv = [0 0 1 1];\r\n X = 0.5;\r\n Y = 0.5;\u003c/pre\u003e\u003cpre\u003e inside(xv,yv,X,Y) -----\u003e true\u003c/pre\u003e","function_template":"function tf = inside(xv,yv,X,Y)\r\n  tf = maybe;\r\nend","test_suite":"%%\r\nxv = [0 1 0];\r\nyv = [0 0 1];\r\nX = 0.8;\r\nY = 0.8;\r\ntf_correct = false;\r\nassert(isequal(inside(xv,yv,X,Y),tf_correct))\r\n\r\n%%\r\nxv = [0 1 1 0];\r\nyv = [0 0 1 1];\r\nX = 0.5;\r\nY = 0.5;\r\ntf_correct = true;\r\nassert(isequal(inside(xv,yv,X,Y),tf_correct))\r\n\r\n\r\n%%\r\nxv = [0 1 1 0];\r\nyv = [0 0 1 1];\r\nX = 0.5;\r\nY = 0.5;\r\ntf_correct = true;\r\nassert(isequal(inside(xv,yv,X,Y),tf_correct))\r\n\r\n\r\n%%\r\nxv = [0 0.25 0.25 0];\r\nyv = [0 0 1 1];\r\nX = 0.5;\r\nY = 0.5;\r\ntf_correct = false;\r\nassert(isequal(inside(xv,yv,X,Y),tf_correct))\r\n\r\n\r\n%%\r\nxv = [0 0.25 0.25 0] + 1000;\r\nyv = [0 0 1 1] + 1000;\r\nX = 1000.1;\r\nY = 1000.1;\r\ntf_correct = true;\r\nassert(isequal(inside(xv,yv,X,Y),tf_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":3,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":384,"test_suite_updated_at":"2012-01-31T14:13:38.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-01-31T14:13:38.000Z","updated_at":"2026-03-29T20:42:27.000Z","published_at":"2012-01-31T15:52:31.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\u003eGiven vertices specified by the vectors xv and yv, and a single point specified by the numbers X and Y, return \\\"true\\\" if the point lies inside (or on the boundary) of the polygon defined by the vertices.\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\u003eExample:\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[ % The specified point is the center of the unit square:\\n xv = [0 1 1 0];\\n yv = [0 0 1 1];\\n X = 0.5;\\n Y = 0.5;\\n\\n inside(xv,yv,X,Y) -----\u003e true]]\u003e\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":194,"title":"Clockwise or Counterclockwise","description":"Given a list of 2-d points defining the vertices of a polygon, determine whether these points are sorted clockwise.\r\n\r\nThe inputs to this function are two vectors *x* and *y* (with equal size) containing the x- and y- coordinates of the polygon vertices, respectively.\r\n\r\nThe function should return true when sorted clockwise, and false when sorted counterclockwise (the polygon vertices will always be sorted either way).\r\n\r\nExample:\r\n\r\n  x = [-1,-1,1,1];\r\n  y = [-1,1,1,-1];\r\n\r\ndefines a square, the vertices are listed clockwise\r\n\r\n  d_correct = true;\r\n\r\n","description_html":"\u003cp\u003eGiven a list of 2-d points defining the vertices of a polygon, determine whether these points are sorted clockwise.\u003c/p\u003e\u003cp\u003eThe inputs to this function are two vectors \u003cb\u003ex\u003c/b\u003e and \u003cb\u003ey\u003c/b\u003e (with equal size) containing the x- and y- coordinates of the polygon vertices, respectively.\u003c/p\u003e\u003cp\u003eThe function should return true when sorted clockwise, and false when sorted counterclockwise (the polygon vertices will always be sorted either way).\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex = [-1,-1,1,1];\r\ny = [-1,1,1,-1];\r\n\u003c/pre\u003e\u003cp\u003edefines a square, the vertices are listed clockwise\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ed_correct = true;\r\n\u003c/pre\u003e","function_template":"function tf = isSortedClockwise(x,y)\r\n  tf = false;\r\nend","test_suite":"%%\r\nx = [-1,-1,1,1];\r\ny = [-1,1,1,-1];\r\nd_correct = true;\r\nassert(isequal(isSortedClockwise(x,y),d_correct))\r\n\r\n%%\r\nx = [-1,-1,-2,-2];\r\ny = [-1,1,1,-1];\r\nd_correct = false;\r\nassert(isequal(isSortedClockwise(x,y),d_correct))\r\n\r\n%%\r\nx = [-1,-1,-2,-2];\r\ny = [-1,1,1,-1];\r\nd_correct = false;\r\nassert(isequal(isSortedClockwise(x,y),d_correct))\r\n\r\n%%\r\nx = [-6,-7,-2,1,1,-2];\r\ny = [4,-7,-13,-11,0,5];\r\nd_correct = false;\r\nassert(isequal(isSortedClockwise(x,y),d_correct))\r\n\r\n%%\r\nx = [-59,-59,-55,-51,-50,-46,-45,-45,-39,-40,-40,-41,-46,-50,-50];\r\ny = [-68,-33, -5,-13,-28,-30,-20,-10, -8,-23,-34,-45,-48,-51,-51];\r\nd_correct = true;\r\nassert(isequal(isSortedClockwise(x,y),d_correct))\r\n\r\n%%\r\nx = flip([-59,-59,-55,-51,-50,-46,-45,-45,-39,-40,-40,-41,-46,-50,-50]);\r\ny = flip([-68,-33, -5,-13,-28,-30,-20,-10, -8,-23,-34,-45,-48,-51,-51]);\r\nd_correct = false;\r\nassert(isequal(isSortedClockwise(x,y),d_correct))\r\n\r\n%%\r\nx = [1,1,2,2];\r\ny = [2,1,1,2];\r\nassert(isequal(isSortedClockwise(x,y),false));\r\n\r\n%%\r\nx = flip([1,1,2,2]);\r\ny = flip([2,1,1,2]);\r\nassert(isequal(isSortedClockwise(x,y),true));\r\n\r\n%%\r\nx = [-2,-2,-4,-4];\r\ny = [1,3,1,-1];\r\nassert(isequal(isSortedClockwise(x,y),false));\r\n\r\n%%\r\nx = flip([-2,-2,-4,-4]);\r\ny = flip([1,3,1,-1]);\r\nassert(isequal(isSortedClockwise(x,y),true));\r\n\r\n%%\r\nr=rand(100,15);\r\na=2*pi*rand(100,1);\r\nd=2*(rand(100,1)\u003e.5)-1;\r\nx=r.*cos(a*ones(1,15)+d*2*pi*(0:14)/15)+randn(100,1);\r\ny=r.*sin(a*ones(1,15)+d*2*pi*(0:14)/15)+randn(100,1);\r\nassert(all(arrayfun(@(i)isequal(isSortedClockwise(x(i,:),y(i,:)),d(i)\u003c0),1:100)))\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":3,"created_by":43,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":216,"test_suite_updated_at":"2017-12-04T00:52:18.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-01-31T06:39:48.000Z","updated_at":"2026-03-31T15:28:48.000Z","published_at":"2012-02-02T02:42:52.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\u003eGiven a list of 2-d points defining the vertices of a polygon, determine whether these points are sorted clockwise.\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\u003eThe inputs to this function are two vectors\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (with equal size) containing the x- and y- coordinates of the polygon vertices, respectively.\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\u003eThe function should return true when sorted clockwise, and false when sorted counterclockwise (the polygon vertices will always be sorted either 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\u003eExample:\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[x = [-1,-1,1,1];\\ny = [-1,1,1,-1];]]\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\u003edefines a square, the vertices are listed clockwise\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[d_correct = true;]]\u003e\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":193,"title":"Smallest distance between a point and a rectangle","description":"Given two points *x* and *y* placed at opposite corners of a rectangle, find the minimal euclidean distance between another point *z* and every point within this rectangle.\r\n\r\nFor example, the two points\r\n\r\n     x = [-1,-1];\r\n     y = [1,1];\r\n\r\ndefine a square centered at the origin. The distance between the point\r\n\r\n   z = [4,5];\r\n\r\nand this square is\r\n\r\n   d = 5;\r\n\r\n(the closest point in the square is at [1,1])\r\n\r\nThe distance between the point z = [0,2] and this same square is d = 1 (closest point at [0,1])\r\n\r\nThe distance between the point z = [0,0] and this same square is d = 0 (inside the square)\r\n\r\n\r\nNotes: \r\n\r\n* you can always assume that *x* \u003c *y* (element-wise) \r\n* The function should work for points x,y,z in an arbitrary n-dimensional space (with n\u003e1)\r\n\r\n\r\n\r\n ","description_html":"\u003cp\u003eGiven two points \u003cb\u003ex\u003c/b\u003e and \u003cb\u003ey\u003c/b\u003e placed at opposite corners of a rectangle, find the minimal euclidean distance between another point \u003cb\u003ez\u003c/b\u003e and every point within this rectangle.\u003c/p\u003e\u003cp\u003eFor example, the two points\u003c/p\u003e\u003cpre\u003e     x = [-1,-1];\r\n     y = [1,1];\u003c/pre\u003e\u003cp\u003edefine a square centered at the origin. The distance between the point\u003c/p\u003e\u003cpre\u003e   z = [4,5];\u003c/pre\u003e\u003cp\u003eand this square is\u003c/p\u003e\u003cpre\u003e   d = 5;\u003c/pre\u003e\u003cp\u003e(the closest point in the square is at [1,1])\u003c/p\u003e\u003cp\u003eThe distance between the point z = [0,2] and this same square is d = 1 (closest point at [0,1])\u003c/p\u003e\u003cp\u003eThe distance between the point z = [0,0] and this same square is d = 0 (inside the square)\u003c/p\u003e\u003cp\u003eNotes:\u003c/p\u003e\u003cul\u003e\u003cli\u003eyou can always assume that \u003cb\u003ex\u003c/b\u003e \u0026lt; \u003cb\u003ey\u003c/b\u003e (element-wise)\u003c/li\u003e\u003cli\u003eThe function should work for points x,y,z in an arbitrary n-dimensional space (with n\u003e1)\u003c/li\u003e\u003c/ul\u003e","function_template":"function d = distanceRectangle2Point(x,y,z)\r\n  d = 0;\r\nend","test_suite":"%%\r\nassessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','distanceRectangle2Point.m')\r\n%%\r\nx = [-1,-1];\r\ny = [1,1];\r\nz = [4,5];\r\nassert(isequal(distanceRectangle2Point(x,y,z),5))\r\nd_correct = 5;\r\n%%\r\nx = [-2,-1];\r\ny = [3,1];\r\nz = [1,2];\r\nassert(isequal(distanceRectangle2Point(x,y,z),1))\r\nd_correct = 1;\r\n%%\r\nx = [1,2];\r\ny = [3,4];\r\nz = [-5,3];\r\nassert(isequal(distanceRectangle2Point(x,y,z),6))\r\nd_correct = 6;\r\n%%\r\nx = [2,2];\r\ny = [4,4];\r\nz = [3,4];\r\nassert(isequal(distanceRectangle2Point(x,y,z),0))\r\nd_correct = 0;\r\n%%\r\nx = [-1,0,1];\r\ny = [0,2,4];\r\nz = [4,5,3];\r\nassert(isequal(distanceRectangle2Point(x,y,z),5))\r\nd_correct = 5;\r\n%%\r\nx = [1,0,1];\r\ny = [2,3,2];\r\nz = [-1,-2,3];\r\nassert(isequal(distanceRectangle2Point(x,y,z),3))\r\nd_correct = 3;\r\n\r\n","published":true,"deleted":false,"likes_count":8,"comments_count":3,"created_by":43,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":280,"test_suite_updated_at":"2017-12-04T00:12:33.000Z","rescore_all_solutions":true,"group_id":17,"created_at":"2012-01-31T06:07:25.000Z","updated_at":"2026-03-31T15:32:49.000Z","published_at":"2012-01-31T08:50:23.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\u003eGiven two points\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e placed at opposite corners of a rectangle, find the minimal euclidean distance between another point\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and every point within this rectangle.\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 example, the two points\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[     x = [-1,-1];\\n     y = [1,1];]]\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\u003edefine a square centered at the origin. The distance between the point\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[   z = [4,5];]]\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\u003eand this square is\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[   d = 5;]]\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\u003e(the closest point in the square is at [1,1])\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\u003eThe distance between the point z = [0,2] and this same square is d = 1 (closest point at [0,1])\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\u003eThe distance between the point z = [0,0] and this same square is d = 0 (inside the square)\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\u003eNotes:\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eyou can always assume that\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026lt;\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (element-wise)\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=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe function should work for points x,y,z in an arbitrary n-dimensional space (with n\u0026gt;1)\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":190,"title":"Great Circle Distance","description":"Find shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\r\n","description_html":"\u003cp\u003eFind shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\u003c/p\u003e","function_template":"function d = sphere_distance(r,a1,p1,a2,p2)\r\n  d = 1;\r\nend","test_suite":"%%\r\nassert(isequal(round(sphere_distance(100,10,50,-20,14)*10000)/10000,75.9097));\r\n\r\n%%\r\nassert(isequal(round(sphere_distance(6371e3,-97.7430608,30.267153,-74.0244265,40.6081588)*10000)/10000,2426004.8394));\r\n\r\n%%\r\nassert(isequal(round(sphere_distance(6371e3,-97.7430608,31.267153,-74.0244265,40.6081588)*10000)/10000,2364307.7819));","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":281,"test_suite_updated_at":"2012-01-31T02:47:01.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-01-31T02:38:51.000Z","updated_at":"2026-03-31T15:30:19.000Z","published_at":"2012-01-31T02:47:01.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eFind shortest between two points on a ball given their azimuthal and polar angles (in degrees) as well as the radius of the sphere.\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":164,"title":"Right and wrong","description":"Given a vector of lengths [a b c], determines whether a triangle with those sides lengths is a right triangle: \u003chttp://en.wikipedia.org/wiki/Right_triangle\u003e.\r\n\r\nExamples:\r\n\r\n[3 4 5] ---\u003e true\r\n\r\n[5 12 13] ---\u003e true\r\n\r\n[5 5 5] ---\u003e false","description_html":"\u003cp\u003eGiven a vector of lengths [a b c], determines whether a triangle with those sides lengths is a right triangle: \u003ca href=\"http://en.wikipedia.org/wiki/Right_triangle\"\u003ehttp://en.wikipedia.org/wiki/Right_triangle\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cp\u003e[3 4 5] ---\u003e true\u003c/p\u003e\u003cp\u003e[5 12 13] ---\u003e true\u003c/p\u003e\u003cp\u003e[5 5 5] ---\u003e false\u003c/p\u003e","function_template":"function y = right(sides)\r\n  y = sides;\r\nend","test_suite":"%%\r\nsides = [3 4 5];\r\ntf_correct = true;\r\nassert(isequal(right(sides),tf_correct))\r\n%%\r\nsides = [3 5 4];\r\ntf_correct = true;\r\nassert(isequal(right(sides),tf_correct))\r\n%%\r\nsides = [5 12 13];\r\ntf_correct = true;\r\nassert(isequal(right(sides),tf_correct))\r\n%%\r\nsides = [5 5 5];\r\ntf_correct = false;\r\nassert(isequal(right(sides),tf_correct))\r\n%%\r\nsides = [113 112 15];\r\ntf_correct = true;\r\nassert(isequal(right(sides),tf_correct))\r\n%%\r\nsides = [113 110 15];\r\ntf_correct = false;\r\nassert(isequal(right(sides),tf_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":11,"comments_count":3,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1440,"test_suite_updated_at":"2013-05-25T12:43:14.000Z","rescore_all_solutions":false,"group_id":17,"created_at":"2012-01-29T15:17:31.000Z","updated_at":"2026-02-27T10:50:39.000Z","published_at":"2012-02-17T20:59:33.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\u003eGiven a vector of lengths [a b c], determines whether a triangle with those sides lengths is a right triangle:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Right_triangle\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Right_triangle\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\u003eExamples:\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[3 4 5] ---\u0026gt; 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\u003e[5 12 13] ---\u0026gt; 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\u003e[5 5 5] ---\u0026gt; false\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\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}