Last active
December 15, 2015 19:18
-
-
Save wende/dc32bc28bca78f30f263 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enum.take_while( IO.stream(:stdio, :line), fn | |
"\n" -> false | |
_ -> true | |
end) | |
|> Enum.map(fn line -> | |
String.split(line, "x") | |
|> Enum.map(&Integer.parse/1) | |
|> (fn [{a,_},{b,_},{c,_}] -> | |
2*(a*b + a*c + b*c) + ( | |
Enum.sort([a,b,c]) | |
|> Enum.take(2) | |
|> (fn [a,b] -> a*b end).() | |
) | |
end).() | |
end) | |
|> Enum.sum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
println(io.Source.stdin.getLines.map { line => | |
val nums = line.split("x").map(_.toInt) | |
val Array(a, b, c) = nums | |
2*(a*b + a*c + b*c) + nums.sorted.take(2).product | |
}.sum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment