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
mfikes 2017-12-22T00:30:22.000271Z

Hah. I forgot core has even?—no need to (zero? (mod x 2))

mfikes 2017-12-22T00:45:13.000022Z

On a more interesting note, I sorted out how to transduce all the way through with no intermediate data structures

mfikes 2017-12-22T00:45:44.000094Z

This results in it processing an arbitrary number of iterations without blowing out memory

mfikes 2017-12-22T00:46:56.000057Z

The mind bending bit is to replace an (into [] ...) in the core of the algorithm with an (eduction ..) which causes all the steps to complete immediately, followed by a long phase of another transduce at the end where it does all the calculations essentially lazily.

mfikes 2017-12-22T00:47:17.000138Z

The learning: you can iterate where each step returns an eduction. Cool!

ihabunek 2017-12-22T10:35:15.000194Z

that's impressive

ihabunek 2017-12-22T10:35:58.000347Z

i need to study your code, it's way above my current understanding of clojure 🙂

orestis 2017-12-22T12:08:26.000262Z

Bah. Day 21 is so fiddly.

orestis 2017-12-22T12:09:45.000279Z

You can have both rotations and flips?

orestis 2017-12-22T12:09:47.000354Z

Arg.

orestis 2017-12-22T12:13:59.000001Z

Phew, I had the rotations/flips logic wrong, I got a hint from @borkdude and now my code works for both parts, even though I didn’t take into account any ordering or whatever.

👍 1
orestis 2017-12-22T12:14:04.000126Z

Now to read other code.

orestis 2017-12-22T12:18:18.000057Z

@bhauman Ahh, fantastic transpose/flip/rotate functions.

👍 2
mfikes 2017-12-22T13:02:03.000341Z

The motivation is that if you do it this way in ClojureScript, you work around the lack of locals clearing. In other words, in CloureScript you are always holding head.

mfikes 2017-12-22T13:55:48.000286Z

The patch that helps tremendously in ClojureScript for problems involving reducing over large amounts of iterate, repeat and cycle (which a lot of the AoC problems seem to do) is now in https://dev.clojure.org/jira/browse/CLJS-2445

borkdude 2017-12-22T15:22:29.000485Z

Day 22: https://github.com/borkdude/aoc2017/blob/master/src/day22.clj

bhauman 2017-12-22T15:55:29.000267Z

just increase the complexity of the state transitions and it will have to take more time

bhauman 2017-12-22T15:55:52.000084Z

this seems to be their strategy this year

borkdude 2017-12-22T16:00:36.000419Z

is that different than last year? I stopped at day 7 or so last year

bhauman 2017-12-22T16:11:46.000577Z

if I remember correctly they had more stumpers in the last two advents

borkdude 2017-12-22T16:19:32.000138Z

maybe they’re trying to make it more mainstream now? 😉

borkdude 2017-12-22T16:20:57.000169Z

if you’re bored with today’s ant, here’s another game: https://github.com/wouter-swierstra/ants/blob/master/ants.pdf

2017-12-22T16:41:28.000373Z

I remember last year to be more about best first searching, this year iterate seems to always suffice

orestis 2017-12-22T17:21:13.000216Z

Last year there was A* and other graph search algorithms.

spfeiffer 2017-12-22T17:22:11.000243Z

Still being at '15 day 22 you guys won't motivate me to look into '16 and '17 ☺️

orestis 2017-12-22T17:26:48.000099Z

’17 feels much easier. Usually the last couple of days are simple, what with people solving the puzzle over the holidays.

orestis 2017-12-22T17:32:06.000251Z

This year for some reason I really don’t want to refactor any code. I wonder if Clojure is scaring me.

mfikes 2017-12-22T18:27:36.000298Z

FWIW, I refactor heavily. The first version I write works but is garbage. 🙂

borkdude 2017-12-22T18:34:57.000268Z

Same for me.

bhauman 2017-12-22T19:25:08.000412Z

is there an ascicinema like way to record what happens in an emacs buffer?

bhauman 2017-12-22T19:26:05.000276Z

well i guess I could run in the terminal

bhauman 2017-12-22T19:26:25.000195Z

which shouldn't be too hard