I’ve done Everybody Codes, back in November.

The Song of Ducks and Dragons [ 2025 ] ![]()
AaAaa
AaAaa
AaAaa
AaAaa
AaAaa
Quest 6. Given a list of letters, find all pairs of e.g. “A*a” (part 1 and 2). Repeating the list 1000 times, do it again (part 3).
Part 1 was nice actually. Going through the list, there’s a counter for how many “A”s I’ve seen so far. And when I encounter an “a”, I add that counter value to the running sum. Part 2 was a little more sophisticated, where it had to work without me knowing what letter I was actually looking at. And using ctype_upper() and strtoupper(). Oh, part 3. Here I could use the knowledge, that repeating the list also meant repeating the numbers. With 1000 repetitions, 998 of them are “in the middle”. Count 1 of these and multiply by 998. Then count the 1st and the last. It was a little fiddly. For some reason I didn’t just create my own example data and work on that.
Oronris,Urakris,Oroneth,Uraketh
r > a,i,o
i > p,w
n > e,r
o > n,m
k > f,r
...
Quest 7. Given a list of names and a list of rules, which names follow all the rules (part 1 and 2)? Like, Oronris is out, because s can’t follow i. Then construct all names possible with the rules (part 3).
For part 1 and 2, look at each pair of letters and check whether that exists as a rule. For part 3, oh, recursion. Given part of a name, add all the possible next letters. And check uniqueness, which I didn’t at first!
1,5,2,6,8,4,1,7,3
Quest 8. Given a list of numbers, interpret these as the numbers of nails. So in this list, there’s a string between 1 and 5, between 5 and 2 etc. How many times does a string pass through the center of the circle of nails (part 1)? How many times does a string cross another string (part 2)? Which extra string would cross the most existing strings (part 3)?
The 1st one is easy. Calculate the distance between the 2 nails. If the distance is the same as halfway around the circle, the string will go through the center. In part 2 I use this knowledge: If 2 strings, 1 -> 5 and 7 -> 3, cross each other, it’s because 1 < 3 < 5, but not 1 < 7 < 3. I also have to take care of the edge case, where “both strings use the same nail in 1 end” isn’t counted as crossing. In part 3 I use some of my existing program, but also create all the possible strings. The one I’m looking for might not already exist.
1:CAAGCGCTAAGTTCGCTGGATGTGTGCCCGCG
2:CTTGAATTGGGCCGTTTACCTGGTTTAACCAT
3:CTAGCGCTGAGCTGGCTGCCTGGTTGACCGCG
Quest 9. So called DNA sequences. We have 3 of these, 2 parents and 1 child. For each letter in the sequence, the child should have the same letter as 1 of the parents. Which 1 is the child (part 1 and 2)? Construct a family tree for a lot of people, and measure the largest family (part 3).
Pretty straight forward coding. Can this person be the child of these 2 persons, yes or no? With more than 3 persons, have a 2d array, $children[$parent1][$parent2] = $child. In part 3 I begin by saying all triples are small families. Then I combine these into larger families, until they can’t grow anymore. I got to use “break 3”.
....... ...X... ......D ....... .......
..X.X.. .D..... ....X.. ....... ....X.X
.X...X. ...X... .....X. ....... ...X...
...D... X.X.... ....... ....... .....D.
.X...X. ....... ....... ..X.X.. ...X...
..X.X.. ....... ....... .X...X. ....X.X
....... ....... ....... ...D... .......
Quest 10. Given a map, that’s actually sort of a chessboard, with D marking a dragon moving like a knight, and S marking sheep (no sheep shown above), how many sheep can the dragon reach and eat (part 1)? Add that the sheep can also move and can hide (part 2). Find all games where the dragon eats all the sheep (part 3).
I can see in part 3 I added memoization. And I borrowed code heavily from a colleague. It was hard to keep it straight in my head, where did the dragon go, where did the sheep go, when did a game end with all sheep eaten. On, there’s also recursion.