I'd like to think my parsing for it ended up fairly clean. The different arities of map are major helps in this.
the heck
My second program ended up being absurdly easy - I went with a very dumb initial heuristic thinking it would show me the next failed test, but nope, that was it
low level mutability :eew:
trying to write fn to translate sexpressions line (and a (not b))
into AND A J...
and those 2 mutable registers are a world of pain
either api forces you to frame sexp from particular point of view, or infinite pain
You can translate boolean expressions...
using de morgan's laws to change (and (not x) (not y))
to (not (or x y))
to save register space
Any expression that has more than one non-trivial operand is going to take up both of your registers
So simplify the operands of any binary op until at least one of them is a trivial register. Unary ops can be computed with a single mutable register.
all of this is true. I wanted user not to worry about shape of the tree. But reshaping a tree with a bunch of substitution rules is not an easy task as well. but yeah, can be done for sure.
I read half the book and threw this together: https://github.com/alper/aoc2019/blob/master/3.clj Itβs a bit slow so suggestions of how to speed it up are very much welcome.
Just removing last
and concat
resulted in a 20x speed gain:
Elapsed time: 7390.580613 msecs Elapsed time: 372.936439 msecs
Thanks for that and the other hints.
It turns out that all time is spent in generate_points_from_steps
.If anybody has a solution for this I can take a look at that would also be appreciated.