Skip to content

Instantly share code, notes, and snippets.

@paulohp
Created November 23, 2016 15:04
Show Gist options
  • Save paulohp/6ba1aafeaa327c39ce958ad1b03507ef to your computer and use it in GitHub Desktop.
Save paulohp/6ba1aafeaa327c39ce958ad1b03507ef to your computer and use it in GitHub Desktop.
defmodule Solution do
line = "10 12 50
20 20 10"
#line = IO.read :stdio, :all
[a1, a2, a3, b1, b2, b3] = String.split line
initial_points = %{alice: 0, bob: 0}
points_round_one =
case a1 > b1 do
true -> %{initial_points | alice: initial_points.alice + 1}
false -> %{initial_points | bob: initial_points.bob + 1}
end
IO.inspect points_round_one
points_round_two =
case a2 == b2 do
true -> points_round_one
false ->
case a2 < b2 do
true -> %{points_round_one | alice: points_round_one.alice + 1 }
false -> %{points_round_one | bob: points_round_one.bob + 1 }
end
end
IO.inspect points_round_two
points_round_three =
case a3 < b3 do
true -> %{points_round_two | alice: points_round_two.alice + 1}
false -> %{points_round_two | bob: points_round_two.bob + 1}
end
IO.inspect points_round_three
alice = Map.get(points_round_three, :alice)
bob = Map.get(points_round_three, :bob)
IO.write(alice)
IO.write(" ")
IO.write(bob)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment