Langton’s Ant

Langton’s Ant moves on a grid of squares that can be either black or white. The grid begins as fully white and the ant can only face left, right, down or up. It then moves in accordance to the following two rules:

  • If the ant is on a black square, it changes the colour of the square to white, rotates 90 degrees anticlockwise and moves forward one square.
  • If the ant is on a white square, it changed the colour of the square to black, rotates 90 degrees clockwise and move forward one square.

Find the total number of black squares on the grid after the ant moves 1000 times.

Remember, to solve this puzzle and appear on the leaderboard, email both your solution and your source code (in any language) to Good luck!!

View all puzzles »