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-13T06:33:51.490100Z

That was refreshingly fun after yesterday

fellshard 2018-12-13T06:45:50.490600Z

Nice, relaxing one.

taylor 2018-12-13T06:45:53.490700Z

really frustrating for me 😕 sample input works, real input fails

taylor 2018-12-13T07:11:09.492100Z

gah finally got it after finding all my dumb bugs. felt like I wrote way too much code for this one

borkdude 2018-12-13T07:31:46.492500Z

are there any people doing Advent of CLJC and using Windows?

mrmcc3 2018-12-13T07:54:25.494300Z

Yeah i did my last solution from a windows machine

borkdude 2018-12-13T07:59:16.494800Z

@mrmcc3 does tools.deps work fine for you on Windows?

borkdude 2018-12-13T07:59:43.495500Z

I’m considering using Planck or Lumo for scripting instead of bash, but I’m wondering if this would be problematic for some people. It’s not strictly necessary

mrmcc3 2018-12-13T08:01:24.497100Z

Ah i just use the tools.deps built into cursive/intellij. Once I solved the problem in clojure from the repl I run the scripts in WSL ubuntu

borkdude 2018-12-13T08:02:10.497700Z

@mrmcc3 would it be reasonable to assume just about every developer on Windows uses WSL?

mrmcc3 2018-12-13T08:04:04.499200Z

Ha no idea I only just started trying on AOC

borkdude 2018-12-13T08:06:37.499400Z

I’m glad to hear the scripts work in WSL 😉

borkdude 2018-12-13T08:10:50.500100Z

I wonder if Planck works under WSL

mrmcc3 2018-12-13T08:13:48.500500Z

I can try it out don't see why not

2018-12-13T12:34:10.501700Z

day 13, quite fiddly - I had a bug that had trains going completely the wrong way at the junctions, but cleverly and annoyingly it managed to get the right answer on the test input.

benoit 2018-12-13T12:50:29.502Z

My solution for Day 13 https://github.com/benfle/advent-of-code-2018/blob/master/day13.clj

mfikes 2018-12-13T12:56:11.503200Z

@borkdude Planck does work under WSL. There is an upstream WebKit issue that has a workaround (not sure if that issue has been fixed and the fix widely deployed; I haven't looked at it in a while). https://github.com/planck-repl/planck/issues/746

borkdude 2018-12-13T12:57:50.504700Z

@mfikes cool! I haven’t made my mind up about it yet, since I think most of the stuff works, but it would be more maintainer friendly if some bash was replaced with clojure. on the other hand, I’m forcing an extra installation step on advent-of-cljc users

borkdude 2018-12-13T12:58:26.504900Z

but good to know it’s an option

borkdude 2018-12-13T13:15:20.505200Z

btw, if you want to trigger recording of the scores for certain days, all you have to do now is create a PR to a branch named yyyy/dd/rescore, then I’ll accept it, and all the changed namespaces will be recorded. I did that here: https://github.com/borkdude/advent-of-cljc/tree/2018/01/rescore these changes won’t have to be applied to master, just being in a branch in my repo is enough

borkdude 2018-12-13T13:15:41.505500Z

I might make a script that does this automatically per day

Average-user 2018-12-13T16:21:24.508Z

I just read day 13, seems fun. But I don't know if I'll have time to implement it today

taylor 2018-12-13T17:01:38.508800Z

I'm too ashamed to commit my solution :biohazard_sign:

helios 2018-12-13T17:17:34.510Z

@borkdude replying to something of a few days ago: https://github.com/lambdaisland/trikl a new project to make terminal UIs in clojure. It might be good for some of the visualizations of the AoC

borkdude 2018-12-13T17:23:56.510600Z

@helios I think you’re replying to something that was a reply to that lib 😉

helios 2018-12-13T17:26:02.511Z

whoops 😛 it happens when they are discussions of days ago 😄 sry!

pesterhazy 2018-12-13T17:42:01.511400Z

I'm getting an "incorrect answer" on day13 part 2

pesterhazy 2018-12-13T17:42:42.512200Z

But I'm not sure it's incorrect or how it could be wrong - it works on part 1 and on the extra sample input provided for part 2

pesterhazy 2018-12-13T17:44:27.512400Z

Here's my attempt: https://github.com/pesterhazy/advent2018/blob/master/src/advent/puzzle13.clj#L120

ccann 2018-12-13T17:44:35.513100Z

that is the worst feeling

pesterhazy 2018-12-13T17:45:02.513600Z

Haven't encountered that in any previous day

2018-12-13T18:06:27.513800Z

https://www.twitch.tv/timpote

gklijs 2018-12-13T18:23:58.514Z

That's cheating ;)

pesterhazy 2018-12-13T18:45:31.516100Z

Found the bug - now it works https://github.com/pesterhazy/advent2018/blob/master/src/advent/puzzle13.clj#L78

pesterhazy 2018-12-13T18:47:49.518400Z

It's not that the puzzle description was unclear - but I still failed to grasp the rules for collision detection. Somehow I feel an imperative solution would have been more obvious

pesterhazy 2018-12-13T18:50:08.519800Z

I made multiple mistakes of conception when choosing the pairs for collision comparison - which sadly worked for p1 but gave an incorrect answer for p2

pesterhazy 2018-12-13T18:50:40.520300Z

I wonder what conclusions to draw from this, other than the fact that I'm dense 🙂

borkdude 2018-12-13T18:51:03.520400Z

cool!

benoit 2018-12-13T18:51:58.520800Z

debugging is part of the process 😉

borkdude 2018-12-13T18:53:55.520900Z

is this live btw?

pesterhazy 2018-12-13T19:02:51.521400Z

@me1740 always look on the bright side...

2018-12-13T19:12:55.521600Z

Yeah when I post it’s live.

2018-12-13T19:13:02.521800Z

VODs are available for 14 days

pesterhazy 2018-12-13T19:13:19.522Z

sounds fun, this was my first Twitch experience

borkdude 2018-12-13T19:13:22.522200Z

VOD?

pesterhazy 2018-12-13T19:13:29.522400Z

i thought it was only for games!!

2018-12-13T19:13:48.522600Z

Video On Demand

2018-12-13T19:13:53.522800Z

sry gamer term 😛

2018-12-13T19:14:03.523Z

Yeah, no. Twitch is pretty great actually.

borkdude 2018-12-13T19:14:07.523200Z

I’m not a gamer, sorry 🙂 why not post these to Youtube then?

➕ 1
1️⃣ 1
borkdude 2018-12-13T19:14:31.523400Z

btw, very cool and inspiring. can’t wait to hack something mutable now in Clojure 😛

2018-12-13T19:14:53.523600Z

Uhh, so I’m thinking about posting to youtube or self-hosting

2018-12-13T19:14:57.523800Z

haven’t decided yet

2018-12-13T19:15:07.524Z

Thanks for the feedback! It’s much appreciated!

borkdude 2018-12-13T19:15:26.524200Z

cool. valuable tutorial. I think I might try day 9b in the Christmas break.

borkdude 2018-12-13T19:16:03.524400Z

I first saw this mutable approach here. Very similar solution I think: https://github.com/kolov/adventofcode2018/blob/master/day9-marbles/src/main/scala/example/Main.scala

borkdude 2018-12-13T19:16:40.524700Z

case class Marble(var left: Marble, var right: Marble, value: Int)

2018-12-13T19:17:23.524900Z

I honestly don’t know how to do it efficiently w/o mutability. I’m sure there’s plenty of higher polynomial solutions.

borkdude 2018-12-13T19:17:45.525100Z

These dequeue data structures do exactly this? I didn’t look into those

borkdude 2018-12-13T19:18:08.525300Z

I tried it with plain vectors first. it works, but sloooow

2018-12-13T19:18:14.525500Z

Almost. You have to build a rotation fn in. But they’re structured so this operation is pretty efficient.

2018-12-13T19:18:45.525700Z

Yeah, I saw immediately that was an issue. Went off and thought about it for a while before starting.

2018-12-13T19:19:02.525900Z

Then come to find out java has a much better solution built-in 😛

borkdude 2018-12-13T19:19:27.526100Z

yeah, but advent of cljc has to work on Node as well 🙂

borkdude 2018-12-13T19:19:37.526300Z

maybe node also has something like this, but may require a lib

borkdude 2018-12-13T19:19:55.526500Z

your solution probably works out of the box

taylor 2018-12-13T19:35:32.527100Z

I went with an imperative solution b/c it seemed most straightforward late at night

fellshard 2018-12-13T19:38:31.527800Z

It's not too bad w/ pure functional code, either; I usually end up with tagged results, e.g. [:ok carts] or [:collided colls]

fellshard 2018-12-13T19:38:48.528100Z

Not much different than using reduced

2018-12-13T19:53:15.528400Z

Was fun. Thanks a lot!

2018-12-13T19:54:03.529Z

This day was a big piece of work. Not hard. Just tiring and long. But fun 😄 Finally something that even I can manage

markw 2018-12-13T20:10:43.529300Z

I've burned too much time on this problem... this code works on the sample input and a few others I created but chokes on the actual input - I can't find the bug.

pesterhazy 2018-12-13T20:37:50.530Z

A "concise" solution for day12: https://www.reddit.com/r/adventofcode/comments/a5eztl/2018_day_12_solutions/ebmfcqc/

😅 2
gklijs 2018-12-13T20:44:42.530300Z

With java you can work with 'native' intarrays and get the solution down to 33 ms.

gklijs 2018-12-13T20:45:56.531Z

Wouldn't surprise me if there was an even faster way to calculate it using some mathematical model.

markw 2018-12-13T20:45:57.531200Z

Figures... i struggle for hours, post, and 30 min later find the bug

markw 2018-12-13T20:47:02.531300Z

fellshard 2018-12-13T20:50:50.531700Z

Ahhh, APL; ever a source of delight and horror. To be fair, it's probably a fantastic fit for a number of these problems.

2018-12-13T21:34:54.532800Z

@pesterhazy Had the exact same problem - it worked for the example, but took three attempts at getting the collision detection exactly as described to make it work for the actual puzzle.

fellshard 2018-12-13T22:34:59.534300Z

It made the recursion annoying, because you really can't solely update carts in-place, since each cart depends on the result of the cart before it. I ended up using straight loop-recur over reduce this time because of that.

benoit 2018-12-13T22:38:01.535900Z

Yes, that was my main bug too. A cart might have disappeared because of a collision. I solved it by checking that the cart was still around before trying to move it. So I could continue to reduce.

fellshard 2018-12-13T23:17:53.536800Z

You know, you're right. Could've done it by just flagging the collided carts instead of removing them. Would've made some things easier.

pesterhazy 2018-12-13T23:23:09.537900Z

That’s what I did - set a flag and clean up in a second pass

fellshard 2018-12-13T23:29:05.538400Z

I might give that a shot, much cleaner than the index fiddling I'm doing.