Cody

Problem 2024. Triangle sequence

Solution 1860929

Submitted on 28 Jun 2019 by James Browne
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   Pass
n = 1; area_correct = 25; tolerance = 1e-12; assert(abs(triangle_sequence(n)-area_correct)<tolerance)

s1 = 5 prevSides = 3 4 s2 = 4 hyp = 6.4031 prevSides = 6.4031 5.0000 4.0000

2   Pass
n = 2; area_correct = 41; tolerance = 1e-12; assert(abs(triangle_sequence(n)-area_correct)<tolerance)

s1 = 5 prevSides = 3 4 s2 = 4 hyp = 6.4031 prevSides = 6.4031 5.0000 4.0000 s1 = 6.4031 prevSides = 5 4 s2 = 5 hyp = 8.1240 prevSides = 8.1240 6.4031 5.0000

3   Pass
n = 3; area_correct = 66; tolerance = 1e-12; assert(abs(triangle_sequence(n)-area_correct)<tolerance)

s1 = 5 prevSides = 3 4 s2 = 4 hyp = 6.4031 prevSides = 6.4031 5.0000 4.0000 s1 = 6.4031 prevSides = 5 4 s2 = 5 hyp = 8.1240 prevSides = 8.1240 6.4031 5.0000 s1 = 8.1240 prevSides = 6.4031 5.0000 s2 = 6.4031 hyp = 10.3441 prevSides = 10.3441 8.1240 6.4031

4   Pass
n = 50; area_correct = 439116598409; tolerance = 1e-3; assert(abs(triangle_sequence(n)-area_correct)<tolerance)

s1 = 5 prevSides = 3 4 s2 = 4 hyp = 6.4031 prevSides = 6.4031 5.0000 4.0000 s1 = 6.4031 prevSides = 5 4 s2 = 5 hyp = 8.1240 prevSides = 8.1240 6.4031 5.0000 s1 = 8.1240 prevSides = 6.4031 5.0000 s2 = 6.4031 hyp = 10.3441 prevSides = 10.3441 8.1240 6.4031 s1 = 10.3441 prevSides = 8.1240 6.4031 s2 = 8.1240 hyp = 13.1529 prevSides = 13.1529 10.3441 8.1240 s1 = 13.1529 prevSides = 10.3441 8.1240 s2 = 10.3441 hyp = 16.7332 prevSides = 16.7332 13.1529 10.3441 s1 = 16.7332 prevSides = 13.1529 10.3441 s2 = 13.1529 hyp = 21.2838 prevSides = 21.2838 16.7332 13.1529 s1 = 21.2838 prevSides = 16.7332 13.1529 s2 = 16.7332 hyp = 27.0740 prevSides = 27.0740 21.2838 16.7332 s1 = 27.0740 prevSides = 21.2838 16.7332 s2 = 21.2838 hyp = 34.4384 prevSides = 34.4384 27.0740 21.2838 s1 = 34.4384 prevSides = 27.0740 21.2838 s2 = 27.0740 hyp = 43.8064 prevSides = 43.8064 34.4384 27.0740 s1 = 43.8064 prevSides = 34.4384 27.0740 s2 = 34.4384 hyp = 55.7225 prevSides = 55.7225 43.8064 34.4384 s1 = 55.7225 prevSides = 43.8064 34.4384 s2 = 43.8064 hyp = 70.8802 prevSides = 70.8802 55.7225 43.8064 s1 = 70.8802 prevSides = 55.7225 43.8064 s2 = 55.7225 hyp = 90.1610 prevSides = 90.1610 70.8802 55.7225 s1 = 90.1610 prevSides = 70.8802 55.7225 s2 = 70.8802 hyp = 114.6865 prevSides = 114.6865 90.1610 70.8802 s1 = 114.6865 prevSides = 90.1610 70.8802 s2 = 90.1610 hyp = 145.8835 prevSides = 145.8835 114.6865 90.1610 s1 = 145.8835 prevSides = 114.6865 90.1610 s2 = 114.6865 hyp = 185.5667 prevSides = 185.5667 145.8835 114.6865 s1 = 185.5667 prevSides = 145.8835 114.6865 s2 = 145.8835 hyp = 236.0445 prevSides = 236.0445 185.5667 145.8835 s1 = 236.0445 prevSides = 185.5667 145.8835 s2 = 185.5667 hyp = 300.2532 prevSides = 300.2532 236.0445 185.5667 s1 = 300.2532 prevSides = 236.0445 185.5667 s2 = 236.0445 hyp = 381.9280 prevSides = 381.9280 300.2532 236.0445 s1 = 381.9280 prevSides = 300.2532 236.0445 s2 = 300.2532 hyp = 485.8199 prevSides = 485.8199 381.9280 300.2532 s1 = 485.8199 prevSides = 381.9280 300.2532 s2 = 381.9280 hyp = 617.9725 prevSides = 617.9725 485.8199 381.9280 s1 = 617.9725 prevSides = 485.8199 381.9280 s2 = 485.8199 hyp = 786.0732 prevSides = 786.0732 617.9725 485.8199 s1 = 786.0732 prevSides = 617.9725 485.8199 s2 = 617.9725 hyp = 999.9005 prevSides = 999.9005 786.0732 617.9725 s1 = 999.9005 prevSides = 786.0732 617.9725 s2 = 786.0732 hyp = 1.2719e+03 prevSides = 1.0e+03 * 1.2719 0.9999 0.7861 s1 = 1.2719e+03 prevSides = 999.9005 786.0732 s2 = 999.9005 hyp = 1.6179e+03 prevSides = 1.0e+03 * 1.6179 1.2719 0.9999 s1 = 1.6179e+03 prevSides = 1.0e+03 * 1.2719 0.9999 s2 = 1.2719e+03 hyp = 2.0580e+03 prevSides = 1.0e+03 * 2.0580 1.6179 1.2719 s1 = 2.0580e+03 prevSides = 1.0e+03 * 1.6179 1.2719 s2 = 1.6179e+03 hyp = 2.6178e+03 prevSides = 1.0e+03 * 2.6178 2.0580 1.6179 s1 = 2.6178e+03 prevSides = 1.0e+03 * 2.0580 1.6179 s2 = 2.0580e+03 hyp = 3.3299e+03 prevSides = 1.0e+03 * 3.3299 2.6178 2.0580 s1 = 3.3299e+03 prevSides = 1.0e+03 * 2.6178 2.0580 s2 = 2.6178e+03 hyp = 4.2356e+03 prevSides = 1.0e+03 * 4.2356 3.3299 2.6178 s1 = 4.2356e+03 prevSides = 1.0e+03 * 3.3299 2.6178 s2 = 3.3299e+03 hyp = 5.3878e+03 prevSides = 1.0e+03 * 5.3878 4.2356 3.3299 s1 = 5.3878e+03 prevSides = 1.0e+03 * 4.2356 3.3299 s2 = 4.2356e+03 hyp = 6.8534e+03 prevSides = 1.0e+03 * 6.8534 5.3878 4.2356 s1 = 6.8534e+03 prevSides = 1.0e+03 * 5.3878 4.2356 s2 = 5.3878e+03 hyp = 8.7177e+03 prevSides = 1.0e+03 * 8.7177 6.8534 5.3878 s1 = 8.7177e+03 prevSides = 1.0e+03 * 6.8534 5.3878 s2 = 6.8534e+03 hyp = 1.1089e+04 prevSides = 1.0e+04 * 1.1089 0.8718 0.6853 s1 = 1.1089e+04 prevSides = 1.0e+03 * 8.7177 6.8534 s2 = 8.7177e+03 hyp = 1.4106e+04 prevSides = 1.0e+04 * 1.4106 1.1089 0.8718 s1 = 1.4106e+04 prevSides = 1.0e+04 * 1.1089 0.8718 s2 = 1.1089e+04 hyp = 1.7942e+04 prevSides = 1.0e+04 * 1.7942 1.4106 1.1089 s1 = 1.7942e+04 prevSides = 1.0e+04 * 1.4106 1.1089 s2 = 1.4106e+04 hyp = 2.2823e+04 prevSides = 1.0e+04 * 2.2823 1.7942 1.4106 s1 = 2.2823e+04 prevSides = 1.0e+04 * 1.7942 1.4106 s2 = 1.7942e+04 hyp = 2.9032e+04 prevSides = 1.0e+04 * 2.9032 2.2823 1.7942 s1 = 2.9032e+04 prevSides = 1.0e+04 * 2.2823 1.7942 s2 = 2.2823e+04 hyp = 3.6929e+04 prevSides = 1.0e+04 * 3.6929 2.9032 2.2823 s1 = 3.6929e+04 prevSides = 1.0e+04 * 2.9032 2.2823 s2 = 2.9032e+04 hyp = 4.6974e+04 prevSides = 1.0e+04 * 4.6974 3.6929 2.9032 s1 = 4.6974e+04 prevSides = 1.0e+04 * 3.6929 2.9032 s2 = 3.6929e+04 hyp = 5.9752e+04 prevSides = 1.0e+04 * 5.9752 4.6974 3.6929 s1 = 5.9752e+04 prevSides = 1.0e+04 * 4.6974 3.6929 s2 = 4.6974e+04 hyp = 7.6006e+04 prevSides = 1.0e+04 * 7.6006 5.9752 4.6974 s1 = 7.6006e+04 prevSides = 1.0e+04 * 5.9752 4.6974 s2 = 5.9752e+04 hyp = 9.6681e+04 prevSides = 1.0e+04 * 9.6681 7.6006 5.9752 s1 = 9.6681e+04 prevSides = 1.0e+04 * 7.6006 5.9752 s2 = 7.6006e+04 hyp = 1.2298e+05 prevSides = 1.0e+05 * 1.2298 0.9668 0.7601 s1 = 1.2298e+05 prevSides = 1.0e+04 * 9.6681 7.6006 s2 = 9.6681e+04 hyp = 1.5643e+05 prevSides = 1.0e+05 * 1.5643 1.2298 0.9668 s1 = 1.5643e+05 prevSides = 1.0e+05 * 1.2298 0.9668 s2 = 1.2298e+05 hyp = 1.9899e+05 prevSides = 1.0e+05 * 1.9899 1.5643 1.2298 s1 = 1.9899e+05 prevSides = 1.0e+05 * 1.5643 1.2298 s2 = 1.5643e+05 hyp = 2.5311e+05 prevSides = 1.0e+05 * 2.5311 1.9899 1.5643 s1 = 2.5311e+05 prevSides = 1.0e+05 * 1.9899 1.5643 s2 = 1.9899e+05 hyp = 3.2196e+05 prevSides = 1.0e+05 * 3.2196 2.5311 1.9899 s1 = 3.2196e+05 prevSides = 1.0e+05 * 2.5311 1.9899 s2 = 2.5311e+05 hyp = 4.0955e+05 prevSides = 1.0e+05 * 4.0955 3.2196 2.5311 s1 = 4.0955e+05 prevSides = 1.0e+05 * 3.2196 2.5311 s2 = 3.2196e+05 hyp = 5.2095e+05 prevSides = 1.0e+05 * 5.2095 4.0955 3.2196 s1 = 5.2095e+05 prevSides = 1.0e+05 * 4.0955 3.2196 s2 = 4.0955e+05 hyp = 6.6266e+05 prevSides = 1.0e+05 * 6.6266 5.2095 4.0955 s1 = 6.6266e+05 prevSides = 1.0e+05 * 5.2095 4.0955 s2 = 5.2095e+05 hyp = 8.4291e+05 prevSides = 1.0e+05 * 8.4291 6.6266 5.2095

Suggested Problems

More from this Author10

Community Treasure Hunt

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

Start Hunting!