r/programming • • Dec 01 '15

Daily programming puzzles at Advent of Code

http://adventofcode.com/
320 Upvotes

179 comments sorted by

View all comments

Show parent comment

3

u/Syrrim Dec 01 '15

Did it in 11:

sm?qd\(1_1z

s              sum
| m            map
| | ?          ternary
| | | q        equality
| | | | d      current item of list
| | | | \(     parenthesis literal
| | | 1        1 literal  (if equality is true)
| | | _1       -1 literal (if equality is false)
| | z          the input 

1

u/Pwntheon Dec 02 '15

Nice solution. I was trying to do something like this but kept getting errors when doing loops and\or branching. Didn't think of using map.

Did you try the second one?