26 lines
799 B
Lua
26 lines
799 B
Lua
io.input("test")
|
|
io.input("input")
|
|
|
|
-- Rock, paper, scisors
|
|
own_scores = { X=1, Y=2, Z=3 }
|
|
game_scores = { X = { A=3, B=0, C=6},
|
|
Y = { A=6, B=3, C=0},
|
|
Z = { A=0, B=6, C=3}}
|
|
|
|
-- lose, draw, win
|
|
own_scores_2 = { X=0, Y=3, Z=6 }
|
|
game_moves = { X = { A=3, B=1, C=2}, -- lose
|
|
Y = { A=1, B=2, C=3}, -- draw
|
|
Z = { A=2, B=3, C=1}} -- win
|
|
score = 0
|
|
score_2 = 0
|
|
for line in io.lines() do
|
|
other, you = string.match(line, "(%a+) (%a+)")
|
|
score = own_scores[you] + game_scores[you][other] + score
|
|
score_2 = own_scores_2[you] + game_moves[you][other] + score_2
|
|
-- print(you, own_scores[you], game_scores[you][other], other)
|
|
-- print(you, own_scores_2[you], game_moves[you][other], other)
|
|
end
|
|
print("part 1", score)
|
|
print("part 2", score_2)
|