Skip to content

Instantly share code, notes, and snippets.

@tfwright

tfwright/1.exs Secret

Last active December 3, 2022 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfwright/bfab5e3105c027e4a52f52ae06031e2a to your computer and use it in GitHub Desktop.
Save tfwright/bfab5e3105c027e4a52f52ae06031e2a to your computer and use it in GitHub Desktop.
System.argv()
|> List.first()
|> File.stream!()
|> Enum.reduce(0, fn
"A X" <> _, total -> total + 3 + 1
"B X" <> _, total -> total + 0 + 1
"C X" <> _, total -> total + 6 + 1
"A Y" <> _, total -> total + 6 + 2
"B Y" <> _, total -> total + 3 + 2
"C Y" <> _, total -> total + 0 + 2
"A Z" <> _, total -> total + 0 + 3
"B Z" <> _, total -> total + 6 + 3
"C Z" <> _, total -> total + 3 + 3
end)
|> IO.inspect
System.argv()
|> List.first()
|> File.stream!()
|> Enum.reduce(0, fn
"A X" <> _, total -> total + 0 + 3
"B X" <> _, total -> total + 0 + 1
"C X" <> _, total -> total + 0 + 2
"A Y" <> _, total -> total + 3 + 1
"B Y" <> _, total -> total + 3 + 2
"C Y" <> _, total -> total + 3 + 3
"A Z" <> _, total -> total + 6 + 2
"B Z" <> _, total -> total + 6 + 3
"C Z" <> _, total -> total + 6 + 1
end)
|> IO.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment