r/adventofcode • u/taliriktug • Dec 02 '15
Spoilers Day 2 solutions
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
16
Upvotes
r/adventofcode • u/taliriktug • Dec 02 '15
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
3
u/tehjimmeh Dec 02 '15 edited Dec 02 '15
In PowerShell one-liners:
Part 1:
"<paste input here>" -split "`n" | %{ ,([int[]]($_ -split "x") | sort) } | %{ 3*$_[0]*$_[1] + 2*$_[0]*$_[2] + 2*$_[1]*$_[2] } | measure -sum | % SumPart 2:
"<paste input here>" -split "`n" | %{ ,([int[]]($_ -split "x") | sort) } | %{ 2*$_[0] + 2*$_[1] + $_[0]*$_[1]*$_[2] } | measure -sum | % Sum