r/adventofcode • • Dec 24 '17

SOLUTION MEGATHREAD -๐ŸŽ„- 2017 Day 24 Solutions -๐ŸŽ„-

--- Day 24: Electromagnetic Moat ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Need a hint from the Hugely* Handyโ€  Haversackโ€ก of Helpfulยง Hints^ยค?

Spoiler


[Update @ 00:18] 62 gold, silver cap

  • Been watching Bright on Netflix. I dunno why reviewers are dissing it because it's actually pretty cool. It's got Will Smith being grumpy jaded old man Will Smith, for the love of FSM...

[Update @ 00:21] Leaderboard cap!

  • One more day to go in Advent of Code 2017... y'all ready to see Santa?

This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

9 Upvotes

108 comments sorted by

View all comments

Show parent comment

2

u/streetster_ Dec 24 '17 edited Dec 24 '17

Had to stop for breakfast but managed 1024/994, my best result to date.

Tidied up the solution:

bridge:{
  w:y~\:2#-1#x;
  res:.z.s'[x,/:y where w;y _/:where w],
      .z.s'[x,/:y where a;y _/:where a:not[w] and (last last x)=y[;0]],
      .z.s'[x,/:reverse each y where a;y _/:where a:not[w] and (last last x)=y[;1]];
  $[count res;res;x]
  };
flat:{ (raze .z.s each x where t),x where not t:0h=type each x };
max sum each res:flat bridge[0;] "J"$"/"vs'read0 `:input/24.txt / part 1
max sum each res where c=max c:count each res                   / part 2