adventofcode

Happy Advent 2020! Please put answers in the pinned threads or create one if it does not exist yet. | https://github.com/adventofcode-clojurians/adventofcode-clojurians | Join the private leaderboard with code 217019-4a55b8eb
raspygold 2016-12-14T02:19:53.000410Z

👋 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!

fellshard 2016-12-14T02:23:56.000411Z

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.

dexter 2016-12-14T09:35:23.000412Z

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

cjmurphy 2016-12-14T09:57:24.000414Z

@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.

dexter 2016-12-14T10:48:52.000415Z

@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.

cjmurphy 2016-12-14T11:16:27.000417Z

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.

dexter 2016-12-14T11:27:24.000418Z

I've got a messy local copy where I was just trying that actually 😛

dexter 2016-12-14T11:27:33.000419Z

I drew it with quil

dexter 2016-12-14T11:30:02.000420Z

hmm, i'll try ascii art

dexter 2016-12-14T11:30:22.000421Z

its got pixels everywhere

cjmurphy 2016-12-14T11:32:20.000422Z

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

dexter 2016-12-14T11:34:14.000424Z

cool

cjmurphy 2016-12-14T11:34:39.000425Z

pprint seems to understand what 'all lined up properly' means, as far as having a \n at the end of every row.

2016-12-14T11:38:35.000426Z

@dexter for day8 your solution and mine differ from input line 29 "rotate column x=32 by 1"

2016-12-14T11:39:36.000427Z

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

dexter 2016-12-14T11:54:04.000428Z

oooh, thanks @thegeez

dexter 2016-12-14T15:21:24.000429Z

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

bhauman 2016-12-14T17:19:49.000430Z

day 11 was a bear, but you can reduce the computational complexity immensely, hit me up if you have questions

mnespor 2016-12-14T17:31:48.000431Z

Your representation of the generators and chips is very, very cool

bhauman 2016-12-14T20:16:23.000432Z

@mnespor thanks 🙂 getting the next states from it is harder but it reduces the number of next states dramatically