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
2020-12-25T05:33:48.150500Z

Day 25 answers thread - Post your answers here

2020-12-25T10:06:14.172300Z

For the fun of it: added baby-step giant-step logarithm computation and exponentiation as mentioned by @vincent.cantin to bring the runtime for part 1 from 1300 to 1.3 ~13 msecs πŸ™‚ https://github.com/next-mad-hatter/adventofcode/blob/master/src/aoc_2020/day_25.clj

πŸš€ 3
benoit 2020-12-25T13:52:57.178100Z

Solution to part1. https://github.com/benfle/advent-of-code-2020/blob/main/day25.clj

πŸŽ‰ 3
2020-12-25T15:33:01.179500Z

For the last step you can just use .modPow. This (mod-pow pubkey loop-size module) returns an answer instantly!

πŸ‘ 3
πŸ“Ž 1
2020-12-25T05:35:10.151200Z

For those interested by the topic, today’s puzzle was related to https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange

πŸ‘ 4
rjray 2020-12-25T05:39:13.151600Z

Kind of feeling let down by the day 25 puzzle. I expected to find that a brute-force approach wouldn’t be feasible. But hey, at least I can tell my wife that it’s over…

😁 4
βž• 2
euccastro 2020-12-25T05:40:59.153Z

I couldn't get part 2 because I started AoC at day 16 so I'm missing stars. here is my solution to part 1: https://github.com/euccastro/advent-of-code-2020/blob/master/src/advent/day25.clj

πŸŽ‰ 3
2020-12-25T05:43:52.153800Z

The optimization was to choose the smaller loop-size when calculating the solution.

πŸ™Œ 1
euccastro 2020-12-25T05:46:16.154300Z

I guess I lucked out then, since mine runs fast enough without worrying about that

euccastro 2020-12-25T05:48:23.154900Z

I even 'cracked' both values unnecessarily

2020-12-25T05:51:17.155800Z

The stats are funny … so many people trying to find a way to get a problem for part2

euccastro 2020-12-26T03:08:34.184Z

OK, I just finished bingeing on 1-15, to see the true ending. disclaimer: I'd seen Lambda Island's AoC 2020 videos and I had seen the Chinese Remainder Theorem spoiler https://github.com/euccastro/advent-of-code-2020/tree/master/src/advent

euccastro 2020-12-25T05:51:18.156100Z

@vincent.cantin come to think about it, why is that an optimization? shouldn't you perform the same number of steps no matter which key you choose to 'crack' (i.e., find the loop size of)? [P.S.: it seems that at least in my implementation it matters which one you pick, because finding the loop size happens to be more expensive than transforming a number by that number of loops]

πŸ‘ 1
☝️ 2
Andrew Byala 2020-12-25T05:51:57.156300Z

Pretty straightforward Day 25. https://github.com/abyala/advent-2020-clojure/blob/master/src/advent_2020_clojure/day25.clj

πŸ‘ 2
πŸŽ‰ 6
2020-12-25T05:52:33.156700Z

@euccastro The optimization is for the last step, to find the β€œshared secret”.

2020-12-25T05:53:09.156900Z

Last year I was one of them

2020-12-25T05:53:30.157100Z

I was also wondering … because it is my first year, I wanted to know how to do everything and not miss something.

2020-12-25T05:56:30.157600Z

oh … wait … it is probably people who did not finish all the previous puzzles.

euccastro 2020-12-25T05:57:57.157900Z

but to find the smallest loop size you need to find the loop size of both the door and key, which is actually slower than picking either arbitrarily, find the loop size of that one only, and transform the other with that

2020-12-25T05:59:29.158100Z

yes, you are right.

euccastro 2020-12-25T06:00:00.158500Z

;; 2437 msecs
(time
 (transform (first input) (crack (second input))))

;; 1751 msecs
(time
 (transform (second input) (crack (first input))))

;; 2980 msecs
(time (do (crack (first input)) (crack (second input))))

;; 3450 msecs
(time
 (do
   (crack (second input))
   (transform (second input) (crack (first input)))))

πŸ‘ 3
euccastro 2020-12-25T06:03:33.159700Z

yep πŸ™‚

2020-12-25T06:04:13.159900Z

β€œβ€¦ day 20, you again” :rolling_on_the_floor_laughing:

euccastro 2020-12-25T06:04:49.160100Z

heheh, in my case I'm missing all up to 15. I'll do them at a more leisurely pace

Alexandre Grison 2020-12-25T06:15:11.160300Z

Yes you need 49 stars so that they give you the 50th for free

Alexandre Grison 2020-12-25T06:15:28.160500Z

but there are people who don't know they need to click

Alexandre Grison 2020-12-25T06:16:51.160700Z

Took me 7 seconds to click but I was faster than 29 other peoples. Going from rank 206 to 177 :face_with_cowboy_hat:

πŸŽ‰ 3
2020-12-25T06:26:00.161Z

> Yes you need 49 stars so that they give you the 50th for free Yes, last year I didn’t have all of them. So I just couldn’t click it.

2020-12-25T06:50:58.162500Z

There is an optimization possible for the last step. It looks like: β€’ If the loop-size is even, square the subject-number, then modulo it. Half the loop-size. β€’ If it is even, do one step as usual.

πŸ’ͺ 3
2020-12-25T06:52:08.162800Z

It will run in O(log_2(loop-size))

Average-user 2020-12-25T07:00:41.163300Z

But saddly, that is not the bottleneck

2020-12-25T07:01:50.163500Z

Only part 1 for me today πŸ™‚ https://github.com/next-mad-hatter/adventofcode/blob/master/src/aoc_2020/day_25.clj

πŸŽ‰ 3
nbardiuk 2020-12-25T07:18:54.163900Z

https://github.com/nbardiuk/adventofcode/blob/master/2020/src/day25.clj

πŸ‘ 2
πŸŽ‰ 3
erwinrooijakkers 2020-12-25T08:59:40.167100Z

Thank you! πŸ™‚ Merry Christmas :mother_christmas:

erwinrooijakkers 2020-12-25T09:00:20.167400Z

was a joy to learn from your solutions

erwinrooijakkers 2020-12-25T09:02:23.168600Z

and to be part of this community

πŸŽ„ 5
nbardiuk 2020-12-25T09:05:51.170400Z

Marry Christmas 🦌 It was fun journey

5
Alexandre Grison 2020-12-25T09:05:52.170500Z

are the solutions archived somewhere ? I'd like to read some of them in a month or so, since I didn't solved the challenges with Clojure this year

nbardiuk 2020-12-25T09:07:31.170600Z

we have a pinned solution thread per day https://app.slack.com/client/T03RZGPFR/C0GLTDB2T/details/pins

Alexandre Grison 2020-12-25T09:14:11.170900Z

thanks!

peterc 2020-12-25T10:04:15.172Z

Thanks to everyone for their code solutions and feedback. It was a wonderful learning experience and see you all next year!

βž• 3
2020-12-25T10:59:04.175400Z

they won't be there in a month, I am afraid.

Joe 2020-12-25T11:11:52.176400Z

I haven't finished yet, but it was fun solving all the problems, and great seeing how other people did things. I learned a lot, thank you!

❀️ 2
βž• 5
2020-12-25T11:40:46.176900Z

https://clojurians-log.clojureverse.org/ for rescue

πŸ‘ 3
Alexandre Grison 2020-12-25T12:58:26.177800Z

awesome!

misha 2020-12-25T19:12:17.182100Z

and as usual "never again" :opieop:

πŸ˜€ 2
misha 2020-12-25T19:31:10.183400Z

@a.grison https://akovantsev.github.io/corpus/clojure-slack/adventofcode.html#t1608887152 piggybacking on clojureverse's logs: all 5 years of logs in a single offline html page with filtering

πŸ™ 1