Langton's ant ASCII art. Draw the path of Langton's ant.

Description


  Squares on a plane are colored variously either black or white. We arbitrarily identify one square as the "ant". The ant can travel in any of the four cardinal directions at each step it takes. The ant moves according to the rules below:
  
  
  At a white square, turn 90° right, flip the color of the square, move forward one unit
  At a black square, turn 90° left, flip the color of the square, move forward one unit
  


Specifications


Input: an integer N between 0 and 725 (inclusive).
Output: a 17 by 17 grid representing the "path" of the ant as of step N.


Rules


The ant starts facing right (3 o' clock).
The ant starts at the center of the grid.
Use _#@ for white squares, black squares and the ant respectively.
The grid is initially completely white.
You may make either a complete program or a function on an interpreted language.
Input by stdin or argument.


Examples

Update: case's N = 450 output was wrong.

N = 0

_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
________@________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________


N = 1

_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
________#________
________@________
_________________
_________________
_________________
_________________
_________________
_________________
_________________


N = 450

_________________
_________________
___________##____
____##______##___
___#__##___##_#__
__###_#@#__#__#__
__#_#_#_#__#_#___
_____###___#_____
_____#___________
_____#__###______
___#_#_#__#_#_#__
__#__#_#____###__
__#_##__##___#___
___##______##____
____##___________
_________________
_________________
GolfScript - 67 chars

~17.'_'*n+*\153:|;{|/()[124^.2/6+:6.1&amp;17*)\2&amp;(*|+:|;]@++}*|/();'@'@


hallvabo's Python solution is the most similar to this, so I'll only describe the main differences.

The board is stored as a string instead of an array. This is so we can update a value on the board with less characters (as strings are always flat), and so getting it to the desired output format is easy.

The ant position is incremented by the formula ((d&amp;1)*17+1)*((d&amp;2)-1) (i.e. .1&amp;17*)\2&amp;(*), where d is the direction. We use the variable 6 so we can skip initialization.