Cody

# Problem 1103. Right Triangle Side Lengths (Inspired by Project Euler Problem 39)

Solution 2957914

Submitted on 17 Sep 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
assert(isequal(right_triangle_sides(240),{ [15 112 113] [40 96 104] [48 90 102] [60 80 100] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test1 (line 1) assert(isequal(right_triangle_sides(240),{ [15 112 113] [40 96 104] [48 90 102] [60 80 100] }))

2   Fail
assert(isequal(right_triangle_sides(240),{ [15 112 113] [40 96 104] [48 90 102] [60 80 100] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test2 (line 1) assert(isequal(right_triangle_sides(240),{ [15 112 113] [40 96 104] [48 90 102] [60 80 100] }))

3   Fail
assert(isequal(right_triangle_sides(418),{ [57 176 185] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test3 (line 1) assert(isequal(right_triangle_sides(418),{ [57 176 185] }))

4   Fail
assert(isequal(right_triangle_sides(490),{ [140 147 203] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test4 (line 1) assert(isequal(right_triangle_sides(490),{ [140 147 203] }))

5   Fail
assert(isequal(right_triangle_sides(112),{ [14 48 50] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test5 (line 1) assert(isequal(right_triangle_sides(112),{ [14 48 50] }))

6   Fail
assert(isequal(right_triangle_sides(390),{ [52 165 173] [65 156 169] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test6 (line 1) assert(isequal(right_triangle_sides(390),{ [52 165 173] [65 156 169] }))

7   Fail
assert(isequal(right_triangle_sides(132),{ [11 60 61] [33 44 55] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test7 (line 1) assert(isequal(right_triangle_sides(132),{ [11 60 61] [33 44 55] }))

8   Fail
assert(isequal(right_triangle_sides(576),{ [64 252 260] [144 192 240] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test8 (line 1) assert(isequal(right_triangle_sides(576),{ [64 252 260] [144 192 240] }))

9   Fail
assert(isequal(right_triangle_sides(60),{ [10 24 26] [15 20 25] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test9 (line 1) assert(isequal(right_triangle_sides(60),{ [10 24 26] [15 20 25] }))

10   Fail
assert(isequal(right_triangle_sides(650),{ [25 312 313] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test10 (line 1) assert(isequal(right_triangle_sides(650),{ [25 312 313] }))

11   Fail
assert(isequal(right_triangle_sides(732),{ [183 244 305] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test11 (line 1) assert(isequal(right_triangle_sides(732),{ [183 244 305] }))

12   Fail
assert(isequal(right_triangle_sides(648),{ [162 216 270] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test12 (line 1) assert(isequal(right_triangle_sides(648),{ [162 216 270] }))

13   Fail
assert(isequal(right_triangle_sides(930),{ [155 372 403] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test13 (line 1) assert(isequal(right_triangle_sides(930),{ [155 372 403] }))

14   Fail
assert(isequal(right_triangle_sides(876),{ [219 292 365] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test14 (line 1) assert(isequal(right_triangle_sides(876),{ [219 292 365] }))

15   Fail
assert(isequal(right_triangle_sides(588),{ [84 245 259] [147 196 245] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test15 (line 1) assert(isequal(right_triangle_sides(588),{ [84 245 259] [147 196 245] }))

16   Fail
assert(isequal(right_triangle_sides(208),{ [39 80 89] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test16 (line 1) assert(isequal(right_triangle_sides(208),{ [39 80 89] }))

17   Fail
assert(isequal(right_triangle_sides(228),{ [57 76 95] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test17 (line 1) assert(isequal(right_triangle_sides(228),{ [57 76 95] }))

18   Fail
assert(isequal(right_triangle_sides(312),{ [24 143 145] [78 104 130] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test18 (line 1) assert(isequal(right_triangle_sides(312),{ [24 143 145] [78 104 130] }))

19   Fail
assert(isequal(right_triangle_sides(924),{ [42 440 442] [77 420 427] [132 385 407] [198 336 390] [231 308 385] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test19 (line 1) assert(isequal(right_triangle_sides(924),{ [42 440 442] [77 420 427] [132 385 407] [198 336 390] [231 308 385] }))

20   Fail
assert(isequal(right_triangle_sides(980),{ [280 294 406] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test20 (line 1) assert(isequal(right_triangle_sides(980),{ [280 294 406] }))

21   Fail
assert(isequal(right_triangle_sides(112),{ [14 48 50] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test21 (line 1) assert(isequal(right_triangle_sides(112),{ [14 48 50] }))

22   Fail
assert(isequal(right_triangle_sides(30),{ [5 12 13] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test22 (line 1) assert(isequal(right_triangle_sides(30),{ [5 12 13] }))

23   Fail
assert(isequal(right_triangle_sides(680),{ [102 280 298] [136 255 289] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test23 (line 1) assert(isequal(right_triangle_sides(680),{ [102 280 298] [136 255 289] }))

24   Fail
assert(isequal(right_triangle_sides(396),{ [33 180 183] [72 154 170] [99 132 165] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test24 (line 1) assert(isequal(right_triangle_sides(396),{ [33 180 183] [72 154 170] [99 132 165] }))

25   Fail
assert(isequal(right_triangle_sides(988),{ [266 312 410] }))

Error using ismember>ismemberR2012a (line 220) Inputs A and B must be matrices with the same number of columns in the 'rows' case. Error in ismember (line 154) lia = ismemberR2012a(A,B,logical(flaginds(1))); Error in right_triangle_sides (line 11) if (remainingSideA^2 + remainingSideB^2 == hypotenuse^2) & (all(sidesSorted) > 0) & ~(ismember(sidesSorted, cell2mat(c(:)), 'rows')) Error in Test25 (line 1) assert(isequal(right_triangle_sides(988),{ [266 312 410] }))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!