first 13 stars
This commit is contained in:
+2500
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
# The score for a single round is the score for the shape
|
||||
# you selected (1 for Rock, 2 for Paper, and 3 for Scissors)
|
||||
# plus the score for the outcome of the round
|
||||
# (0 if you lost, 3 if the round was a draw, and 6 if you won).
|
||||
|
||||
scores = {
|
||||
"X": 1, #Rock
|
||||
"Y": 2, #Paper
|
||||
"Z": 3, #Scissors
|
||||
"A": 1, #Rock
|
||||
"B": 2, #Paper
|
||||
"C": 3 #Scissors
|
||||
}
|
||||
|
||||
score = 0
|
||||
with open("input.txt", "r") as f:
|
||||
for line in f.readlines():
|
||||
hands = line.strip("\n").split(" ")
|
||||
theirs = scores[hands[0]]
|
||||
ours = scores[hands[1]]
|
||||
score += ours
|
||||
if ours > theirs and not (ours == 3 and theirs == 1):
|
||||
score += 6
|
||||
if ours == theirs:
|
||||
score += 3
|
||||
if ours == 1 and theirs == 3:
|
||||
score += 6
|
||||
|
||||
print(score)
|
||||
@@ -0,0 +1,31 @@
|
||||
# X means you need to lose,
|
||||
# Y means you need to end the round in a draw,
|
||||
# and Z means you need to win. Good luck!"
|
||||
|
||||
scores = {
|
||||
"A": 1, #Rock
|
||||
"B": 2, #Paper
|
||||
"C": 3 #Scissors
|
||||
}
|
||||
|
||||
score = 0
|
||||
with open("input.txt", "r") as f:
|
||||
for line in f.readlines():
|
||||
strategy = line.strip("\n").split(" ")
|
||||
theirs = scores[strategy[0]]
|
||||
victory = strategy[1]
|
||||
ours = 0
|
||||
if victory == "X": # Lose
|
||||
ours = theirs-1
|
||||
elif victory == "Y": # Draw
|
||||
ours = theirs
|
||||
score += 3
|
||||
elif victory == "Z": # Win
|
||||
ours = theirs+1
|
||||
score += 6
|
||||
if ours == 0:
|
||||
ours = 3
|
||||
if ours > 3:
|
||||
ours = 1
|
||||
score += ours
|
||||
print(score)
|
||||
Reference in New Issue
Block a user