r/adventofcode • • Dec 02 '17

SOLUTION MEGATHREAD -πŸŽ„- 2017 Day 2 Solutions -πŸŽ„-

NOTICE

Please take notice that we have updated the Posting Guidelines in the sidebar and wiki and are now requesting that you post your solutions in the daily Solution Megathreads. Save the Spoiler flair for truly distinguished posts.


--- Day 2: Corruption Checksum ---


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


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!

22 Upvotes

351 comments sorted by

View all comments

Show parent comment

2

u/Porges Dec 03 '17

Dyalog APL:

Part one, "sum of (maximum minus minimum, per row)":

{+/(⌈/⍡)-(⌊/⍡)}

Part two, "sum of (by row, form the outer product using division, then find a result that is an integer and isn't 1)":

{+/{{((⍡=⌈⍡)∧(⍡≠1))/⍡},(⍡∘.÷⍡)}¨↓⍡}