Mercurial > lbo > hg > aoc22
changeset 2:5bf75b17187c
Improvement to day 02 solution
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 02 Dec 2022 20:01:44 +0100 |
parents | a83e493cb7f4 |
children | c1b35ab5d10e |
files | 02/02.jl |
diffstat | 1 files changed, 3 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/02/02.jl Fri Dec 02 19:57:31 2022 +0100 +++ b/02/02.jl Fri Dec 02 20:01:44 2022 +0100 @@ -38,15 +38,8 @@ if loseshape < 0 loseshape += 3 end - if il.choice == 'X' - (loseshape+1) + winscore - elseif il.choice == 'Y' - Int(il.opponent-'A')+1 + winscore - elseif il.choice == 'Z' - (winshape+1) + winscore - else - @assert false - end + shape = (if il.choice == 'X'; loseshape elseif il.choice == 'Y'; Int(il.opponent-'A') else winshape end); + shape+1 + winscore end function calc(v::Vector{InputLine})::Tuple{Int, Int} @@ -60,3 +53,4 @@ end end +print(run_02(input))