good for brain !
The best problem of the CUP challenge.
I think that thematic challenge is a wonderful idea. I solved this one with a great pleasure.
Great problem. So many ways to solve it. It was fun trying different methods to see which scored the best.
The connection of this problem with the Fibonacci sequence is most interesting.
indeed: like!
Very interesting problem!
Interesting problem....!
Interesting!!
Good one :)
Combining the Fibonacci sequence and the Pythagorean theorem is a nice idea
I thought I had the right code and it didn't work. Then I realized that the area of the first triangle (n=1 case) should be 0.5*4*3 = 6. But is given in the solution as 25. Am I understanding this wrong? I thought the three sides of the first triangle (n=1) was 3,4,5 and we go on from there. Please let me know if my understanding is wrong and then I can proceed Otherwise I have a general code.
@ Dhaval: Try reading the last sentence of the problem very carefully.
@Milan Petrovic: Thank you, I completely missed that; silly me. Now I got it to work :)
Good problem. Kinda fun too.
Definitely needed to read that last line carefully. Like at least one other here, I misread it.
can someone help me with this problem?
tough but fun... had issues with assertion at first through
Does Cody not recognize the Fibonacci function?
Can anybody PLEASE send me the solution of this problem? My e-mail is: anthonydavid72@hotmail.com
so interesting!
Nice one! Makes you think, and then the solution is simple and elegant.
It was a really great problem to solve. For me doing the steps as mentioned on paper helped a lot for proper visualization of the problem, and to understand the flow.
Thanks Tanya Morton for the problem exercise.
Very elegantly done!
Very very interesting problem. It introduces the importance of integer sequences.
Why I cannot use the matlab's fibonacci function here? It was Introduced in R2017a. My local PC's matlab and moble matlab can work it out well. Kind of strange.
@Jaya Lee: Cody does not support toolbox functions.
Interesting way to solve
function area = triangle_sequence(n)
y(1)=3;
y(2)=4;
for i=1:n
y(i+2)=sqrt(y(i)^2+y(i+1)^2)
end
area = y(n+2)^2;
end
C=[3,4,5];
for i=2:n
C(end+1,1,1)=C(end,2,1);
C(end,2,1)=C(end-1,3,1);
C(end,3,1)=sqrt(C(end,1,1)^2+C(end,2,1)^2);
end
C= [C(end,:,1)]
area=C(3)^2
Dear Cody Team,
solutions like mine shall be not allowed.
Elegant brain teaser and a good reminder to always read the question carefully...
And now, nobody will ever see it. You should have, at least, posted it.
Can you please delete this answer?
When I click on "leading solution", I get this solution, which is of no use.
Seems broken, when using Fibonacci ratio it won't work so I have botched it instead
So Exciting !
Finally made it :D ... Fibonacci sequence !
please help me out in understanding the problem
Didn't understand question
very hard example
R_T=[3 4 5];
if (n>1)
for i=1:(n-1)
R_T=[R_T(2) R_T(3) (R_T(2)^2+R_T(3)^2)^0.5]
Attention to the last line!
Double fibonacci sequence, subtle! I love this problem!
If anyone cares to point out why this is wrong, I'm open to hearing.
Note that the ratio of consecutive areas is asymptotically the golden ratio, i.e., phi=(1+sqrt(5))/2.
Weak! My recursion solution should work just fine, but the server is unable to evaluate it properly. I'm going to count it.
Its the best way that I found :)
I think it is the only way to solve this Problem. We Need to get the sides of nth triangle and ist done.
I consider my answer as a cheat
Yeah, you have just copied the required values of the test suits.
Interesting... (not a reflection on this particular solution but cody in general) - most of the lowest scored answers could be entries in an "obfuscated code" contest.
I'm curious how all these "Size 10" solutions look like. I don't get even close to this value. I terms of education, it would be great to see example codes which are able to go this low.
Brilliant !
I join you @Eugen, it would be great to share some "Size 10" solutions samples.
yes, this is probably cheating
Extract leading non-zero digit
1167 Solvers
Matrix indexing with two vectors of indices
474 Solvers
337 Solvers
315 Solvers
251 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!