[racket] Using Racket to solve Professor Layton puzzles
Two minutes ago, Danny Yoo wrote:
> > Speaking about puzzles, here's another cute one: find how to continue
> > this sequence of numbers:
> >
> > 1 1 2 1 1 2 2 1 2 2 1 1 2 2 2 1 3 2 ...
>
> Cute. It's self-describing, no? The next few numbers would be
>
> > 1 1 2 1 1 2 2 1 2 2 1 1 2 2 2 1 3 2 ...
>
> 1 1 1 3 1 2 3 1 1 3 1 1 1 2 1 3 2 1 1 3 3 1
Yes. Now for the cuter thing, do it in lazy racket. The obvious code
fails in an interesting way. When you see that, it leads to an
interesting question of whether you *can* produce this sequence
infinitely or if there's a point where you won't be able to continue.
A related question is whether printing the sequence in a loop will
ever make you run out of memory.
(I think that the answers to both questions is "yes", but that
requires a proper proof...)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!