day 1 + 2
This commit is contained in:
commit
6a2ccb8c93
|
@ -0,0 +1,16 @@
|
|||
|
||||
index = 0
|
||||
current = 0
|
||||
biggest = 0
|
||||
with open("input.txt") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line == "":
|
||||
if current > biggest:
|
||||
biggest = current
|
||||
index += 1
|
||||
current = 0
|
||||
else:
|
||||
current += int(line)
|
||||
|
||||
print(index, biggest)
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
elves = []
|
||||
with open("input.txt") as f:
|
||||
current = 0
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line == "":
|
||||
elves.append((len(elves), current, ))
|
||||
current = 0
|
||||
else:
|
||||
current += int(line)
|
||||
|
||||
elves.sort(key=lambda x: x[1], reverse=True)
|
||||
|
||||
|
||||
print(sum([elves[0][1], elves[1][1], elves[2][1]]))
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,14 @@
|
|||
1000
|
||||
2000
|
||||
3000
|
||||
|
||||
4000
|
||||
|
||||
5000
|
||||
6000
|
||||
|
||||
7000
|
||||
8000
|
||||
9000
|
||||
|
||||
10000
|
|
@ -0,0 +1,42 @@
|
|||
# A for Rock, B for Paper, and C for Scissors.
|
||||
# X for Rock, Y for Paper, and Z for Scissors.
|
||||
|
||||
# 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).
|
||||
|
||||
|
||||
|
||||
|
||||
points = {
|
||||
"X": 1,
|
||||
"Y": 2,
|
||||
"Z": 3,
|
||||
}
|
||||
|
||||
convert = dict(X="A", Y="B", Z="C")
|
||||
|
||||
|
||||
def win(a, b):
|
||||
return (a == "A" and b == "Y") or (a == "B" and b == "Z") or (a == "C" and b == "X")
|
||||
|
||||
|
||||
|
||||
score = 0
|
||||
with open("input.txt") as f:
|
||||
for line in f:
|
||||
c1, c2 = line.split()
|
||||
score += points[c2]
|
||||
if c1 == convert[c2]:
|
||||
# print("draw")
|
||||
score += 3
|
||||
elif win(c1, c2):
|
||||
# print("win")
|
||||
score += 6
|
||||
else:
|
||||
# print("lose")
|
||||
pass
|
||||
|
||||
# print(score)
|
||||
|
||||
|
||||
print(score)
|
|
@ -0,0 +1,46 @@
|
|||
# A for Rock, B for Paper, and C for Scissors.
|
||||
# X for Rock, Y for Paper, and Z for Scissors.
|
||||
|
||||
# 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).
|
||||
|
||||
points = {
|
||||
"X": 1,
|
||||
"Y": 2,
|
||||
"Z": 3,
|
||||
}
|
||||
|
||||
convert = dict(A="X", B="Y", C="Z")
|
||||
|
||||
win = dict(A="Y", B="Z", C="X")
|
||||
lose = dict(A="Z", B="X", C="Y")
|
||||
|
||||
# def win(a, b):
|
||||
# return (a == "A" and b == "Y") or (a == "B" and b == "Z") or (a == "C" and b == "X")
|
||||
|
||||
|
||||
# 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!"
|
||||
|
||||
|
||||
score = 0
|
||||
|
||||
|
||||
with open("input.txt") as f:
|
||||
for line in f:
|
||||
c1, c2 = line.split()
|
||||
|
||||
if c2 == "X": # lose
|
||||
pick = lose[c1]
|
||||
elif c2 == "Y": # draw
|
||||
pick = convert[c1]
|
||||
score += 3
|
||||
elif c2 == "Z": # win
|
||||
pick = win[c1]
|
||||
score += 6
|
||||
|
||||
score += points[pick]
|
||||
|
||||
|
||||
print(score)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
|||
A Y
|
||||
B X
|
||||
C Z
|
Loading…
Reference in New Issue