master-blaster
Matthew Butterick 9 years ago
parent e486128438
commit b73b988213

@ -15,7 +15,7 @@
The puzzle asks us to compute the @italic{look and say} sequence invented by mathematician John Conway. Each iteration of the sequence is the description of the last step if you said it in numbers. So @racket[1] becomes ``one 1'', written @racket[11]; @racket[11] becomes ``two ones'', or @racket[21], then @racket[1211], @racket[111221], and so on. The puzzle asks us to compute the @italic{look and say} sequence invented by mathematician John Conway. Each iteration of the sequence is the description of the last step if you said it in numbers. So @racket[1] becomes ``one 1'', written @racket[11]; @racket[11] becomes ``two ones'', or @racket[21], then @racket[1211], @racket[111221], and so on.
As in @secref{Day_1}, this puzzle relies on cumulative state, so we'll loop using @racket[for/fold]. To generate the new string for each pass of the loop, we'll use @racket[regexp-match*] to find every contiguous run of digits. Each digit run will be converted into a list with the number of digits and then digit. Then all these lists of numbers are concatenated into a new string, and the process repeats. As in @secref{Day_1}, this puzzle relies on cumulative state, so we'll loop using @racket[for/fold]. To generate the new string for each pass of the loop, we'll use @racket[regexp-match*] to find every contiguous run of digits. Each digit run will be converted into a list with the number of digits and the digit. Then all these lists are concatenated into a new string, and the process repeats.
The second part of the puzzle is just going to change the number of iterations. So we'll make one function that we can use for both parts. The second part of the puzzle is just going to change the number of iterations. So we'll make one function that we can use for both parts.