[Community Puzzle] Length of Syracuse Conjecture Sequence



Send your feedback or ask for help here!

Created by @Silmaen,validated by @bbb000bbbyyy,@JBM and @Jamproject.
If you have any issues, feel free to ping them.


Hi @Silmaen, @JBM, @Jamproject, @bbb000bbbyyy
Would you know why I pass all test cases but not the validators? Really weird, I have nothing hard coded…
Is it a Long/Int loss of precision thing?


hard to tell without your code. But you might be on the right track because the “You can assume that no operation overflows a 32-bit integer” is misleading, it’s actually 32-bit unsigned integer. And so if you are for example coding in java, the Integer is not enough as it is a signed integer.


If I share you my code in private, would you be able to tell :stuck_out_tongue:? I’m using Scala, types are the same as in Java but I already tried moving to Long and it doesn’t work?


Actually 32-bit signed integers should be enough to prevent from overflows in all tests & validators (the maximum sequence value to compute overall is ~1.5e9).


which validator you don’t pass? the last one?
a 32bit integer is enough to pass all the tests.

it could be because of a timeout (the last validator is a ‘big’ one if you don’t use memoisation)


I already use memoisation, and I pass all test cases. However, I don’t pass validators 1, 3 and 4…

Basically what I do is either I take the first tournament and I have r-1 consecutive days left but I have the reward or I don’t and I still have r consecutive days left. If r <= 0 then I just move to the next. Hope this is not too much details.

Am I missing something?


Sure, since I am above level 20, I can retrieve the validators files and run your code to see what’s wrong.


What? Are you talking about The Grand Festival puzzle?


Thanks I sent it to you via private message. Let me know :wink: Thanks


Oooohhhh yes sorry :stuck_out_tongue:

For this one I simply did it straight forward (1 + solveProblem(n-1)) with a little bit of memoïzation. Then a loop to iterate over all n to fetch its Syracuse sequence length.


Hey @bbb000bbbyyy any news on that? Thanks :wink: !


Well damn, I replied 4 days ago but I guess there was a problem.
Anyway, yes I know where the issue is in your code. You need to make sure that it returns the “lowest integer that leads to the longest cycle-length”.


Thanks that solved my issue :wink: