[S3 A-Maths: Combinatorics] Kept you waiting, huh? Haha.
This puzzle, in itself, can be solved by taking advantage of combinatorics. By associating pattern cycles to these numbers, it's banking on the odds that the number chains are relatively small. If they are small enough to give multiple chains of maximum length 5, then it is a stable strategy that allows the prisoners to be freed and saved.
Here's a video to explain the process fully! Check it out: