Advent of Code, Days 11 and 12

Getting down to marking, so these may get sparse.

Day 11

Easy. Convert the passwords to integer lists and write code to increment them, then write some more code to test each password for validity (sometimes converting back to strings and doing a regex, but leaving that as the last case for speed). The only irritating part was having to write a function to test the equality of three values:

Day 12

The first part of this was easy, once I realised that strings never contained numbers. I could just parse all the numbers and add them up:

For second part there was no way around actually parsing the JSON, so I wrote a JSON parser. This is really pushing the limit of what it’s sensible to do in a language like Angort, which, while a full functional language, has no clever optimisation tricks to make it faster. I had to considerably increase the size of the both the return stack and the variable stack, and it runs like a dog. But it does work:

This certainly pushed the language to its limits, and helped me find an awful lot of bugs!

Copyright © Found
Jim Finnis' personal blog

Built on Notes Blog Core
Powered by WordPress