Problem 6 · Snakes, rats and scorpions
Working backwards from the last rat.
Integer answer, at most 4 digitsIn a desert there are snakes, rats and scorpions. Every morning, each snake kills a rat. Every noon, each scorpion kills a snake. Every night, each rat kills a scorpion. After five days, at night, only one rat was left. How many rats were there at the start of the first morning?
Reasoned solution
Key idea: each day: $r \to r - s$ (morning), $s \to s - e$ (noon), $e \to e - r_{\text{new}}$ (night). We work backwards: if the day ends at $(s', r', e')$, before the day we had $e = e' + r'$, $s = s' + e$, $r = r' + s$.
At the end of day five: $(s, r, e) = (0, 1, 0)$. Undoing day by day:
Forward check from $(129, 189, 88)$: day 1 → $(41,60,28)$; day 2 → $(13,19,9)$; day 3 → $(4,6,3)$; day 4 → $(1,2,1)$; day 5 → $(0,1,0)$ ✓ — exactly one rat remains (and no snakes or scorpions).