👋 I’m really enjoying AoC this year. I only solved about half the problems last year before I got too busy, but this year I’m hoping to solve them all. By default I'm solving them in Ruby, but I’ve started learning Clojure this year so hoping to solve them all with Clojure afterwards. Day 11 had me stumped for a good while!
I've had to fall off the bandwagon; brother's wedding is coming up, so I've already fallen behind a couple days, and it'll only be more over the next week, hah.
Same here, I'm still on day 8, although i'm a bit stuck and I've got no idea what I've done wrong. The sample they give seems to work when I used reductions to spot check the translations around the edge cases and it all seemed to work, it happily wraps round with no issues etc. Short of actually manually doing the transformations one by one I'm a bit stuck. If anyone's feeling generous and got any tips I'd appreciate some advice on where to look https://github.com/feldoh/advent-2016/blob/day8/src/advent_2016/day8.clj
@dexter: The approach I took was to just have one function that could turn a particular [x y] 'pixel' on or off. Then in terms of that operation you can do the rotations. That way the same code is used for either a row or column rotation.
@cjmurphy I've done something relatively similar but I used rotating a row as my basic operation wherein I transpose -> rot row -> transpose if it's a column. To rotate a row I used cycle to build a view over that row which I reverse then just drop the first n off. I can just start over but I'd love to know what I'm missing with the solution I've got. Given that I've clearly missed an edge case that my tests aren't catching it seems likely if I start over with a new approach I'll miss the same edge case again.
Transposing then dropping off does sound tricky. I looked at your code but hard for me to see anything wrong. One thing that can help (and will help you with a later day/s), and might be better/easier than tests, is to have an actual visual representation, so like \.
and '\#
instead of :off
:on
, which won't line up nicely in a rectangle.
I've got a messy local copy where I was just trying that actually 😛
I drew it with quil
hmm, i'll try ascii art
its got pixels everywhere
You can do it with the data structure itself. See visual-validation
here: https://github.com/chrismurrph/advent-of-code/blob/master/dev/server/advent/thirteen.clj
cool
pprint
seems to understand what 'all lined up properly' means, as far as having a \n at the end of every row.
@dexter for day8 your solution and mine differ from input line 29 "rotate column x=32 by 1"
and as a shameless plug: using clojure.spec to parse instructions might help: http://thegeez.net/2016/12/09/parsing_clojure_spec_advent_of_code.html
oooh, thanks @thegeez
interestingly it seems to be mutating rows other than the one I'm changing which is really bizzare, ah well at least I have something to investigate. thanks for the pointers guys
day 11 was a bear, but you can reduce the computational complexity immensely, hit me up if you have questions
Your representation of the generators and chips is very, very cool
@mnespor thanks 🙂 getting the next states from it is harder but it reduces the number of next states dramatically