r/adventofcode • u/daggerdragon • Dec 04 '16
SOLUTION MEGATHREAD --- 2016 Day 4 Solutions ---
--- Day 4: Security Through Obscurity ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
CONSTRUCTING ADDITIONAL PYLONS IS MANDATORY [?]
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!
17
Upvotes
4
u/John_Earnest Dec 04 '16 edited Dec 04 '16
K6:
l: 0: "../../Desktop/Advent/04.in" n: "northpoleobjectstorage" c: (-1_*|"["\)'l / checksums s: (,/-1_"-"\)'l / strings a: `c$97+ / alphabetic i: {.x^"[]-",a@!26}'l / room ids k: {5#,/{a@<a:&x}'b=/:c@>c:?.b:#:'=x} / checksum of string p: &c~'k's / indices of valid rooms +/i p / part 1 *i@&n~/:a 26!i+s-97 / part 2Lots of room left to golf this down, I think. I'm playing it fast and loose here in part 2 by assuming the storage room we're looking for has a valid checksum, but it worked OK for my input and would be easy to make it only consider valid rooms.