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.
Glad I could help you fix it!
Thanks for the help … yeah belive it or not i did do several runs with the sample input
i had helper functions not shown in the gist for printing the track
but no collisions happened on the first tick so I didn’t notice
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.
yeah fair point … printing full? i would have noticed the nil at the start
i was focusing on printing all the wrong things
thanks for the help, who knows how long i would have stared at that aimlessly
dude, 2015 molecules are awful, but interesting! but today's one is just zzz
GC overhead limit exceeded
:opieop:
This feels like a day 24 one in previous years, but day 15? yikes
Maybe the assumption is that the weekend is a good time for a big one
I might do day 15, but if there is other problem like this one this year I may quit the whole thing
same^ — or at the very least skip it
this is by far the most difficult year… at least for me
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
(assert (= (f1 input) 196200))
"Elapsed time: 4399.123038 msecs"
p2? I'll just let it run overnight and submit result. totally not worth it, although I have an optimization in mind.
p2 "Elapsed time: 538665.073576 msecs"
thats day15?
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.
Functional programming is not the best for simulations 🙂
Okay, not deleting this time. data.priority-map is definitely busted 😞
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
@fellshard Can you use sorted-set-by
instead, where the set contents are the items and the sort fn is the item->priority fn?
Looks like I'll have to. Was trying to avoid resorting each time 😞
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.
Maybe an issue in getting a persistent impl? Dunno.
I guess day 15 really took a toll on people.
Well, hope to see some renewed activity here for day17.
I jumped ship to 16, that was much more fun 🙂
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.
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
manually that is… maybe tomorrow i’ll code it.. i always feel dirty/guilty doing it by hand
@markw same here 😅 I'm thinking of it to solve with core.logic
later.
great! i'll have to dig into your code 🙂
I’ve been meaning to play around with that at some point.. never done any logic / prolog stuff before
yeah tonight i needed a quick win after the past couple puzzles…
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.
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.
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.
My day 15: https://github.com/pesterhazy/advent2018/blob/master/src/advent/puzzle15.clj
And my day 16: https://github.com/pesterhazy/advent2018/blob/master/src/advent/puzzle16.clj
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
I thought the roguelike was a lot of fun, but it takes some time
Wow, only 2200 people finished day 15, down from 6000+
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
10 people finished day 15 in less than an hour !
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...
ha
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
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)
maybe i'll give it an attempt next year. i just don't feel like spending 6 hours on that this weekend ^^
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
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
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
FWIW I think the instructions have been clear for most (all?) days almost to a fault
Which doesn't mean that I didn't misread them - but that's on me for being hasty
Obviously some people understood 15 out of the gate and got it relatively quickly.
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!
I think this type of problem will be hard to phrase unequivocally, no matter how good of a writer you are
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
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
And it helped me with a problem on 4clojure that I hadn’t done before
Day 16: https://github.com/mfikes/advent-of-code/blob/master/src/advent_2018/day_16.cljc
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
I nearly used a fixpoint, but decided it was easier to see when I’d cleared all of the ambiguities
well… sort of the same. I kept reversing my map, because each time I did, new singletons emerged. Bijective mappings are like that 😄
Nice use of fixed-point
first defmacro i've seen here [=
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
Hah. And, if you look closely, you will see that I'm using defmacro
in ClojureScript. :thinking_face:
The fixpoint trick reminds me of sickpea
@pesterhazy I got stuck on that part (not seeing how to proceed), but took a peek at your solution to get unstuck
(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.)
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
)
I took it as an opportunity to learn how A* works
Which was fun - it’s an elegant algorithm
Got to use java.util.HashMap and j.u.PriorityQueue for the first time
reduce all the things!
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 recur
s instead :kappa: