Trains the technique from
LeetCode 202Happy NumberThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A field probe stores one positive integer reading and runs a self-test on it.
On each tick of the self-test the firmware throws away the stored value and writes back a new one: take every decimal digit of the old value, square each digit, and add those squares together.
The probe declares itself healthy as soon as the stored value becomes 1, because 1 maps to itself and the value can never move again. For every other starting value that never lands on 1, the firmware walks around a fixed ring of values and keeps circling it forever.
Given the starting value reading, return true when the self-test eventually declares the probe healthy, and false when the firmware circles forever.
Example 1
The stored value moves 7 -> 49 -> 97 -> 130 -> 10 -> 1, so the probe declares itself healthy on the fifth tick.
Example 2
The value walks 4 -> 16 -> 37 -> 58 -> 89 -> 145 -> 42 -> 20 -> 4 and is back where it began, so it will circle that ring forever.
Example 3
Only one digit is non-zero, so the very first tick stores 1 and the probe is healthy immediately.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def reading_settles(reading: int) -> bool:public boolean readingSettles(int reading)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.