@@ -7,160 +7,3 @@ sort: 14
7The best way to cement this knowledge in your mind is to do
7The best way to cement this knowledge in your mind is to do
8exercises. These are roughly in order of ascending difficulty,
8exercises. These are roughly in order of ascending difficulty,
9and they are intended to form a sort of primer to Hoon.
9and they are intended to form a sort of primer to Hoon.
11−## Friends of FizzBuzz
13−1. Consider the following implementation of FizzBuzz, which is
14− equivalent to the one in the [Demo](demo) section.
24− ?: =(0 (mod count 15))
26− ?: =(0 (mod count 5))
28− ?: =(0 (mod count 3))
31− $(count (add 1 count))
34− Modify this to produce "Fuzz" when the number is divisible by
35− 7, "Fuzz" when divisible by 21, "FuzzFizz" when divisble by 35,
36− and "FuzzFizzBuzz" when divisble by 105.
38−1. Modify FizzBuzz from the previous exercise to take both a
39− start and an end number.
41−1. Modify FizzBuzz from the previous exercise to count down
46−1. Write a function that produces a list of the first `n`
47− triangular numbers. The `n`th triangular number is the sum
48− of the first `n` positive integers.
50−1. Using the program from the previous exercise, write a
51− function that produces the first `n` tetrahedral numbers.
52− The `n`th tetrahedral number is the sum of the first `n`
55−## Conway's Game of Life
57−Conway's Game of Life is a zero-player game played on an `n`x`n`
58−grid of spaces, each of which is either "alive" or "dead". Every
59−iteration, some or all of the spaces change from alive to dead or
62−Specifically, for each iteration, each dead space becomes alive
63−if and only if it is adjacent to exactly three live spaces. Each
64−live remains alive if and only if it is adjacent to either two or
65−three live spaces. In this context, "adjacent to" includes the
66−eight spaces that share either a side or a corner with the space.
67−Thus, in the following map, the center space (dead) is adjacent
68−to exactly three live spaces, so it will be alive in the next
69−iteration. `#` signifies a live space and `.` signifies a dead
77−1. Write a function that takes nine loobean inputs, `nw`, `nc`,
78− `ne`, `cw`, `cc`, `ce`, `sw`, `sc`, and `se`. Produce 'yes'
79− if the center space will be alive in the next generation and
80− 'no' if it will be dead.
82−1. Write a function that takes an integer `n` and produces an
83− `n` by `n` grid of loobeans, (hereafter, "board"),
84− initialized to 'no'. This grid should be represented as a
85− list of `n` lists of length `n`.
87−1. Write a function that takes a board, a row index, and a
88− column index, and produces a new board, identical to the old
89− except that the state of the space referred to by the row and
90− column indices has been toggled.
92−1. Use the following function to pretty-print the board. For
93− bonus points, try to follow what it's doing.
97− |= board/(list (list ?))
110− If you run this function with a board, you'll get a
111− pretty-printable object (a `tang`), but it won't be
112− pretty-printed. When running the generator from the dojo,
113− run `&tang +generator arguments` to mark the result as a
114− `tang`, which will tell the dojo to intelligently
117−1. Using the functions created in the previous exercises, create
118− a 10 by 10 board, and flip the states of the spaces at
119− coordinates (counting from the top left, indexed from 0)
120− `(2,1)`, `(3,2)`, `(1,3)`, `(2,3)`, and `(3,3)`. Use the
121− pretty printer to print out the board. Your output should be
137−1. Write a function that iterates every space on the board.
138− Print out the new board. It should look like this:
153− > Note that the spaces on the edge don't have the full nine
154− > neighbors. For now, assume that they're always dead.
156−1. Write a function that runs the above function `n` times on
157− the board. Observe the board as the game progresses.
158− Congratulations, you've written Conway's Game of Life in
161−1. One common way to handle the edge of the board is to pretend
162− that it "wraps around", forming a torus. In other words, say
163− that the spaces on the left edge of the map are adjacent to
164− the ones on the right edge, and the spaces on the top edge
165− are adjacent to the spaces on the bottom edge. Pay special
166− attention to the corners.