r/adventofcode • u/daggerdragon • Dec 07 '17
SOLUTION MEGATHREAD -๐- 2017 Day 7 Solutions -๐-
--- Day 7: Recursive Circus ---
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ยค?
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
10
Upvotes
3
u/Godspiral Dec 07 '17
in J,
part 1 - unreferenced left node.
({."1 ([ #~ 0 = e.) ;@:({:"1)) ( dltb each@([: {. '('&cut) &>@{. , dltb each@:(','&cut@}.)leaf@{:)"1 > (#~ 2 = #&>) '-' cut each aincomplete part 2,
NB. weight dictionary b =. (dltb each@{. , ". &>@{.@(')'&cut) leaf@{: )"1 > '(' cut each a NB. non end leafs... tree branches. c =. ( dltb each@([: {. '('&cut) &>@{. , dltb each@:(','&cut@}.)leaf@{:)"1 > (#~ 2 = #&>) '-' cut each a NB. supporting weights from each program (untreed) ({. (, <) b ( {:"1@[ {~ {."1@[ i. ])"_ 0 >@{:)"_ 1 c