day02
This commit is contained in:
parent
b3c7780376
commit
877d795692
2500
02/input.txt
Normal file
2500
02/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
02/input_sample.txt
Normal file
3
02/input_sample.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
A Y
|
||||||
|
B X
|
||||||
|
C Z
|
28
02/solve01.py
Normal file
28
02/solve01.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#/usr/bin/env python
|
||||||
|
|
||||||
|
# AX, 1, Rock
|
||||||
|
# BY, 2,Paper
|
||||||
|
# CZ, 3, Scissors
|
||||||
|
# loss, 0
|
||||||
|
# draw, 3
|
||||||
|
# win, 6
|
||||||
|
|
||||||
|
SCORE = {
|
||||||
|
'AX': 4, # Rock, Rock, Draw
|
||||||
|
'AY': 8, # Rock, Paper, Win
|
||||||
|
'AZ': 3, # Rock, Scissors, Loss
|
||||||
|
'BX': 1, # Paper, Rock, Loss
|
||||||
|
'BY': 5, # Paper, Paper, Draw
|
||||||
|
'BZ': 9, # Paper, Scissors, Win
|
||||||
|
'CX': 7, # Scissors, Rock, Win
|
||||||
|
'CY': 2, # Scissors, Paper, Loss
|
||||||
|
'CZ': 6, # Scissors, Scissors, Draw
|
||||||
|
}
|
||||||
|
|
||||||
|
score = 0
|
||||||
|
with open("input.txt", "r") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.replace(" ", "").strip()
|
||||||
|
score += SCORE[line]
|
||||||
|
|
||||||
|
print(score)
|
35
02/solve02.txt
Normal file
35
02/solve02.txt
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#/usr/bin/env python
|
||||||
|
|
||||||
|
# A, 1, Rock
|
||||||
|
# B, 2,Paper
|
||||||
|
# C, 3, Scissors
|
||||||
|
# loss, X, 0
|
||||||
|
# draw, Y, 3
|
||||||
|
# win, Z, 6
|
||||||
|
|
||||||
|
SCORE = {
|
||||||
|
'A': 1,
|
||||||
|
'B': 2,
|
||||||
|
'C': 3,
|
||||||
|
'X': 0,
|
||||||
|
'Y': 3,
|
||||||
|
'Z': 6,
|
||||||
|
'AX': 'C', # Rock, loose, Scissors
|
||||||
|
'AY': 'A', # Rock, Draw, Rock
|
||||||
|
'AZ': 'B', # Rock, Win, Paper
|
||||||
|
'BX': 'A', # Paper, loose, Rock
|
||||||
|
'BY': 'B', # Paper, Draw, Paper
|
||||||
|
'BZ': 'C', # Paper, Win, Scissors
|
||||||
|
'CX': 'B', # Scissors, loose, Paper
|
||||||
|
'CY': 'C', # Scissors, Draw, Scissors
|
||||||
|
'CZ': 'A', # Scissors, Win, Rock
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
score = 0
|
||||||
|
with open("input.txt", "r") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.replace(" ", "").strip()
|
||||||
|
score += SCORE[line[1]] + SCORE[SCORE[line]]
|
||||||
|
|
||||||
|
print(score)
|
Loading…
x
Reference in New Issue
Block a user