[Community Puzzle] Halting sequences


Send your feedback or ask for help here!

Created by @Waffle3z,validated by @java_coffee_cup,@Alain-Delpuch and @R2B2.
If you have any issues, feel free to ping them.

Is there some kind of trick to figuring out if something will end up looping? Because I don’t get how to solve this without some brute forcing. I get that you should keep track of the answers from the previous pairs, but on the larger number sets I get stack overflow error.

Yes, there is definitely a trick :slight_smile:
Some of the testcases involve huge numbers and the length of the loop can be quite large so I don’t think a simple simulation could work here. This puzzle is more math than coding.
Try to figure out what specific property a and b have if they result halt. The example in the description and the other IDE test cases help a lot!


I found the solution by exploring properties of the halts. But it would be interessing for me to get the math explication for the rule.
How can i get it ?

@Rirelus I have given such an explanation in comment in the solution codes I published (in Python, Ruby & C++). If you’ve solved the problem in one of these languages, you have access to it. Otherwise, I can either publish a solution in your language or send the explanation to you in PM.

I’ve only done it Java. But doesn’t matter if i don’t have the mathematic solution …

@Rirelus Ok, I’ve just published my solution in Java.

Thx @Niako !
I did’nt have the same solution, but it’s the same relflexion.
Thx for your answer :slight_smile:

I managed to pass all tests and almost all validations (“Random small validators” fails), which seems odd.
Although, I am using mathematical properties of halting sequences, I can’t get a 100% score. Is it possible to pass all tests, but still fail to validate a solution?

It’s possible that there is an edge case not covered in the IDE tests that you don’t handle well.
Here’s the validator:


6 58
1 7
15 17
16 88
48 82
21 87



Indeed! The pair (21, 87) brings to light a corner case I didn’t account for. Challenge unlocked!
Thanks for the assist! (^_^)b

1 Like