# [Community Puzzle] Halting sequences

https://www.codingame.com/training/medium/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
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!

2 Likes

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

Hi,
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:

Input

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

Output:

``````halts
halts
halts
loops
loops
loops``````

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