Files
hacklab/2/queen1/test
2025-12-15 13:31:12 +01:00

18 lines
839 B
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
solve with HSgpt:
TL;DR
The program is a tiny “Collatzstep” challenge.
main creates two random numbers:
N=1000000+random() a large (≈1million) starting value.
k=abs( (random() & 0xFF) ) a small nonnegative integer (0255).
func0 prints “Challenge: N k\n>>> ”, reads an integer answer from stdin, calls func1(N,k), and checks whether the returned value equals answer. If it does, it prints “Correct.” and returns0; otherwise it prints “Wrong.” and returns1.
func1 implements k iterations of the Collatz (3n+1) map on the value n that is passed in w0.
Challenge: 524465851 157
The result after performing 157 Collatzsteps on the starting value 524465851 is: 526
Challenge: 1871541254 68
Result after 68 Collatz steps:30046216