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
2018-12-16T00:01:48.609400Z

When I'm debugging these problems, especially with a loop, I'll do a println of each loop parameter and run through the first ~5 iterations manually checking that everything looks right. Usually I'll use the small sample data set from the problem description too. Would have caught this typo.

2018-12-16T00:02:04.609600Z

Glad I could help you fix it!

markw 2018-12-16T00:03:12.609800Z

Thanks for the help … yeah belive it or not i did do several runs with the sample input

markw 2018-12-16T00:03:21.610Z

i had helper functions not shown in the gist for printing the track

markw 2018-12-16T00:03:41.610200Z

but no collisions happened on the first tick so I didn’t notice

2018-12-16T00:05:27.610400Z

I mean print c, cs, full? and new-cars inside your loop, to ensure you got the mechanics of the loop correct. Often mistakes will not manifest obviously in the intended output, but if you look directly at the internal implementation the problem will be more obvious.

markw 2018-12-16T00:07:43.610600Z

yeah fair point … printing full? i would have noticed the nil at the start

markw 2018-12-16T00:07:59.610800Z

i was focusing on printing all the wrong things

markw 2018-12-16T00:08:22.611Z

thanks for the help, who knows how long i would have stared at that aimlessly

🎅 1
misha 2018-12-16T01:21:14.612200Z

dude, 2015 molecules are awful, but interesting! but today's one is just zzz

misha 2018-12-16T01:21:25.612400Z

GC overhead limit exceeded

misha 2018-12-16T01:21:32.612600Z

:opieop:

fellshard 2018-12-16T02:01:24.613300Z

This feels like a day 24 one in previous years, but day 15? yikes

fellshard 2018-12-16T02:01:34.613700Z

Maybe the assumption is that the weekend is a good time for a big one

Average-user 2018-12-16T02:12:24.614600Z

I might do day 15, but if there is other problem like this one this year I may quit the whole thing

2018-12-16T02:24:50.614900Z

same^ — or at the very least skip it

markw 2018-12-16T02:39:47.615200Z

this is by far the most difficult year… at least for me

markw 2018-12-16T02:40:44.616Z

I think it’s a combination of just more difficult puzzles, but also I’ve noticed that compared to prior years where part 2 is usually a layup, this year that is not always the case

misha 2018-12-16T03:04:45.616300Z

(assert (= (f1 input) 196200))
"Elapsed time: 4399.123038 msecs"

misha 2018-12-16T03:05:49.616900Z

p2? I'll just let it run overnight and submit result. totally not worth it, although I have an optimization in mind.

misha 2018-12-16T03:13:44.617700Z

p2 "Elapsed time: 538665.073576 msecs"

Average-user 2018-12-16T03:33:00.617900Z

thats day15?

benoit 2018-12-16T03:37:34.618900Z

Day 15: https://github.com/benfle/advent-of-code-2018/blob/master/day15.clj I am not sure why my Part Two does not work. Probably something stupid because it worked on all the examples.

benoit 2018-12-16T03:38:22.619600Z

Functional programming is not the best for simulations 🙂

misha 2018-12-16T03:39:53.619800Z

@lucaspolymeris 15

fellshard 2018-12-16T04:36:31.622400Z

Okay, not deleting this time. data.priority-map is definitely busted 😞

fellshard 2018-12-16T04:38:12.623200Z

Specifically, it really seems to behave oddly with the way I'm using it, and I'm not sure what about my keys and values is causing pop / dissoc to break

2018-12-16T04:39:05.623900Z

@fellshard Can you use sorted-set-by instead, where the set contents are the items and the sort fn is the item->priority fn?

fellshard 2018-12-16T04:39:31.624Z

Looks like I'll have to. Was trying to avoid resorting each time 😞

fellshard 2018-12-16T04:40:08.624200Z

Going for a classic priority queue sorted-heap approach, but that doesn't seem to be something anyone has implemented reliably in Clojure, at least not with any of those key words.

fellshard 2018-12-16T04:40:25.624400Z

Maybe an issue in getting a persistent impl? Dunno.

2018-12-16T06:52:00.625900Z

I guess day 15 really took a toll on people.

2018-12-16T07:09:01.627700Z

Well, hope to see some renewed activity here for day17.

fellshard 2018-12-16T08:19:35.628300Z

I jumped ship to 16, that was much more fun 🙂

➕ 1
1️⃣ 1
fellshard 2018-12-16T08:20:18.629100Z

Maybe I'll see about continuing 15 tomorrow, my brain's happily fried. The wrinkle in this problem was a fun one to figure out, it took me a few attempts to find a working algorithm.

markw 2018-12-16T08:37:53.630Z

16 wasn’t too bad… but I took the lazy way out on part two and just one by one eliminated anything that didn’t have a unique result

markw 2018-12-16T08:38:56.631Z

manually that is… maybe tomorrow i’ll code it.. i always feel dirty/guilty doing it by hand

uneman 2018-12-16T08:57:01.634500Z

@markw same here 😅 I'm thinking of it to solve with core.logic later.

uneman 2018-12-17T08:47:20.703400Z

great! i'll have to dig into your code 🙂

markw 2018-12-16T09:01:04.635Z

I’ve been meaning to play around with that at some point.. never done any logic / prolog stuff before

markw 2018-12-16T09:01:29.635400Z

yeah tonight i needed a quick win after the past couple puzzles…

gklijs 2018-12-16T09:48:14.637400Z

Anyone stuck on day 15, there is a corner case I ran into which is not tested in the examples. When there are multiple targets at the same distance, you should pick the path to the enemy closest in reading order and not the part starting with a step closer in reading order.

fellshard 2018-12-16T10:33:32.637800Z

I believe that is stated in the problem definition, if not in the examples, though. This is definitely the kind of problem where it'd help to have a good catalogue of examples to run through, though.

gklijs 2018-12-16T10:37:54.638Z

It is, but there are so many rules, it's easy to miss one and have the priority a little different. For my data the difference was only 12 HP the elf's had less.

pesterhazy 2018-12-16T15:53:57.638900Z

And my day 16: https://github.com/pesterhazy/advent2018/blob/master/src/advent/puzzle16.clj

pesterhazy 2018-12-16T15:56:08.640300Z

Skipped a day and took me a while to catch up - I didn't want to open up Slack again before being all caught up, to avoid spoilers

pesterhazy 2018-12-16T16:06:57.641500Z

I thought the roguelike was a lot of fun, but it takes some time

pesterhazy 2018-12-16T16:09:27.642100Z

Wow, only 2200 people finished day 15, down from 6000+

pesterhazy 2018-12-16T16:11:33.643100Z

In day 16 I was bitten by partition again, which silently drops the last group if it isn't complete. I really feel partition-all should be the default

pesterhazy 2018-12-16T16:22:31.643500Z

10 people finished day 15 in less than an hour !

uosl 2018-12-16T16:45:12.644200Z

i'm glad day 16 was a fun problem, in comparison to the previous one which I didn't even read through after seeing the comments here...

2018-12-16T16:46:29.644500Z

ha

2018-12-16T16:47:42.646600Z

People get frustrated easily. I don’t love the problem, and ended up finishing part1 in the morning. It was a bit more fun without the “I need to figure this out so I can get to bed” pressure

☝️ 1
2018-12-16T16:48:46.648100Z

It really wasn’t hard, it was just annoying to figure out what the problem was asking. (and annoying when you didn’t have a test case that demonstrated what you were doing wrong)

☝️ 1
uosl 2018-12-16T16:50:26.650400Z

maybe i'll give it an attempt next year. i just don't feel like spending 6 hours on that this weekend ^^

2018-12-16T16:51:48.652Z

1/3 of that is coding 2/3 of that is figuring out the instructions. If you can find a good restatement of the problem into english, I bet you can get it quickly

uosl 2018-12-16T16:53:32.653Z

i guess it's a bit like the flower pot problem then? i spent a lot of time rewriting that as i gradually learned how those rules applied

2018-12-16T16:55:10.654900Z

Maybe. I thought that one was very clear. I never had any doubt about what to do - just how to do it. For day 15, I often didn’t understand what the problem was asking to do

pesterhazy 2018-12-16T16:58:57.656400Z

FWIW I think the instructions have been clear for most (all?) days almost to a fault

☝️ 1
pesterhazy 2018-12-16T16:59:29.657Z

Which doesn't mean that I didn't misread them - but that's on me for being hasty

2018-12-16T17:00:12.657500Z

Obviously some people understood 15 out of the gate and got it relatively quickly.

uosl 2018-12-16T17:00:51.658500Z

i gave core.logic a try with solving day 7, but I don't think it was much improvement. (and I still couldn't figure out how to get the ordered steps without using elimination with everyg) https://github.com/uosl/advent-of-code/blob/master/src/aoc2018/07.clj let me know if you use it so I can check it out!

pesterhazy 2018-12-16T17:02:43.659500Z

I think this type of problem will be hard to phrase unequivocally, no matter how good of a writer you are

pesterhazy 2018-12-16T17:04:19.661Z

Day 15 was almost too verbose - in some places the description felt like it was reiterating what it just said. But of course in other places, I needed to have the logic repeated to me to get it into my head

2018-12-16T17:39:48.662500Z

I might be odd but I enjoyed day 15. It was a ton of work, granted, but I had fun and learned a lot. I guess for more experienced people it felt more like homework…. Day 16 was cool because I knew exactly what I wanted to do

2018-12-16T17:40:30.662600Z

And it helped me with a problem on 4clojure that I hadn’t done before

quoll 2018-12-19T06:09:08.778800Z

The problem with falling behind (Xmas parties are a thing at this time of year) is that I think I’m doing something clever only to discover that someone else did it a few days before I did

quoll 2018-12-19T06:10:26.779Z

I nearly used a fixpoint, but decided it was easier to see when I’d cleared all of the ambiguities

quoll 2018-12-19T06:14:37.779300Z

well… sort of the same. I kept reversing my map, because each time I did, new singletons emerged. Bijective mappings are like that 😄

pesterhazy 2018-12-16T18:20:56.663500Z

Nice use of fixed-point

uosl 2018-12-16T18:29:48.663700Z

first defmacro i've seen here [=

pesterhazy 2018-12-16T18:32:04.664900Z

BTW I came up with a pattern. I have emacs running on the left half of the screen and a terminal with rebel-readline on the right. Whenever I reload the namespace, my test function gets re-run automatically: https://github.com/pesterhazy/advent2018/blob/master/src/advent/puzzle16.clj#L140

mfikes 2018-12-16T18:33:59.665200Z

Hah. And, if you look closely, you will see that I'm using defmacro in ClojureScript. :thinking_face:

🤯 1
pesterhazy 2018-12-16T18:35:27.665400Z

The fixpoint trick reminds me of sickpea

mfikes 2018-12-16T18:37:00.665600Z

@pesterhazy I got stuck on that part (not seeing how to proceed), but took a peek at your solution to get unstuck

😀 1
mfikes 2018-12-16T18:37:57.665800Z

(I was stuck on the point that my intersections were doing nothing, but I failed to see there was a singleton that could be leveraged.)

fellshard 2018-12-16T18:44:57.666100Z

The more I think about it, the tighter the pathfinding could be. It really does turn into a simple BFS, priority sorting by [distance, position, ancestor] (where ancestor is the tile you would move to in order to approach position)

pesterhazy 2018-12-16T18:47:07.667100Z

I took it as an opportunity to learn how A* works

pesterhazy 2018-12-16T18:47:34.667900Z

Which was fun - it’s an elegant algorithm

pesterhazy 2018-12-16T18:49:45.669600Z

Got to use java.util.HashMap and j.u.PriorityQueue for the first time

👌 1
misha 2018-12-16T23:58:21.671Z

reduce all the things!

misha 2018-12-16T23:59:58.672600Z

did anyone actually use core.logic for day16? I spent half of the day neck-deep in tutorials and videos, and implemented solved "mapping" with a loop and a bunch of recurs instead :kappa: