Re: The Turing Machine (#162)
by Matthew Moss other posts by this author
May 13 2008 10:03AM messages near this date
Re: The Turing Machine (#162)
|
Re: [QUIZ] The Turing Machine (#162)
> > Looks like a pretty nice solution, except I think (but didn't confirm)
> > there is one problem:
>
> > > @head += (dir == 'R') ? 1 : -1
>
> > Doing this could cause the head to wrap around, since array[-1] in
> > Ruby is the last element of the array. It's likely the examples won't
> > exercise this constraint, but the tape should not loop...
>
> That could be a problem, but I cheated: @tape is actually a hash. (I
> was lazy and didn't want to make a Tape class or add extra logic to
> deal with going past the front of the tape.)
Ah, well played, sir. I concede the point. :)
Thread:
Matthew Moss
Adam Shelly
James Koppel
Alpha Chen
Matthew Moss
Alpha Chen
Alpha Chen
Matthew Moss
Robert Dober
Alpha Chen
Matthew Moss
Chiyuan Zhang
Juanger
Mike Stok
jgabrielygalan
Marcelo
Chiyuan Zhang
James Gray
Juanger
Matthew Moss
ThoML
Chris Shea
Chris Carter
Andrew Thompson
Sandro Paganotti
Chris Shea
ThoML
Chris Shea
Chris Shea
Glen F. Pankow
Adam Shelly
Matthew Moss
Chris Carter
Adam Shelly
|