Canadian Computing Competition: 2011 Stage 1, Junior #3
In a sumac sequence,
For example, if we have
This is a sumac sequence of length
Input Specification
The input will be two positive numbers
Output Specification
The output will be the length of the sumac sequence given by the starting numbers
Sample Input
Copy
120
71
Output for Sample Input
Copy
5
Comments
Why does this year feel so much easier than the rest lol
it's just this question
Test case 4: 610 377 Note: equal or bigger instead of bigger
I didn't need to use equal or bigger and I didn't run into any problems either. https://dmoj.ca/submission/4727992
Idk why so many people are failing test 4 :(
(sorry for the ton of edits, correct me if I'm stupid)
probably because you used the smaller than operator for comparing the second last number to the last number:
(a = sumaclist[-2] - sumaclist[-1]), and (if sumaclist[-1] < a:)
detecting if the sumac number was found.
other people made their code repeat if the number wasn't found, so they had to use the >= sign between the numbers instead
Smaller or equal to for ppl who got 4 wrong
Thanks)
Can someone help me with my code, I failed test case 4. Thanks.
sankeeth_ganeswaran. I believe there is a minor error in your code. As a reference, try:
610 and 377
Output should be 17, and not 15
Edit: Hint, this can be done recursively and iteratively
Thanks. I've meet the same question and this text helps me alot.
IDK what my python code did wrong, why is test case 4 incorrect
Your while loop condition is ignoring a key case... compare the "termination condition" in the problem statement to when your loop terminates.
Thank you! Merry Christmas :)