There is also a triangular variation in the Numberphile video. Your function will help a lot with different sequence pattern and different starting point. I found a Medium article reveals some chaos nature of this problem: https://maartenmortier.medium.com/the-trapped-knight-revisited-132c034a8a28