|
|
|
|
|
by alisey
4130 days ago
|
|
I gave this question to a friend and she came up with what I think is a beautiful answer. Remember min and max X and Y coordinates seen so far, and count the number of steps. When this number gets larger than (maxX - minX)*(maxY - minY) we know we're in a cycle. It's an extension of your idea of counting the total number of visited positions. What I like most about it is that it can work with streamed data. |
|