add day 2

main
lub 2 years ago
parent d68a135177
commit b0c0ea9880

2500
2/input

File diff suppressed because it is too large Load Diff

@ -0,0 +1,68 @@
# A = Rock
# B = Paper
# C = Scissors
# X = Rock 1 points
# Y = Paper 2 points
# Z = Scissors 3 points
# Loss 0 points
# Draw 3 points
# Win 6 points
$scoring = @{
# rock
X = 1
# paper
Y = 2
# scissors
Z = 3
loss = 0
draw = 3
win = 6
}
$shapes = @{
# rock
A = @{
# rock
X = $scoring.draw
# paper
Y = $scoring.win
# scissors
Z = $scoring.loss
}
# paper
B = @{
# rock
X = $scoring.loss
# paper
Y = $scoring.draw
# scissors
Z = $scoring.win
}
# scissors
C = @{
# rock
X = $scoring.win
# paper
Y = $scoring.loss
# scissors
Z = $scoring.draw
}
}
$points = 0
Get-Content input
| ForEach-Object {
$shape,$response = $_.Split(' ')
$points += $scoring.$response
$points += $shapes.$shape.$response
}
$points

@ -0,0 +1,65 @@
# A = Rock
# B = Paper
# C = Scissors
# Rock 1 points
# Paper 2 points
# Scissors 3 points
# X = Loss 0 points
# Y = Draw 3 points
# Z = Win 6 points
$scoring = @{
rock = 1
paper = 2
scissors = 3
X = 0
Y = 3
Z = 6
}
$shapes = @{
# rock
A = @{
# loss
X = 'scissors'
# draw
Y = 'rock'
# win
Z = 'paper'
}
# paper
B = @{
# loss
X = 'rock'
# draw
Y = 'paper'
# win
Z = 'scissors'
}
# scissors
C = @{
# loss
X = 'paper'
# draw
Y = 'scissors'
# win
Z = 'rock'
}
}
$points = 0
Get-Content input
| ForEach-Object {
$shape,$result = $_.Split(' ')
$points += $scoring.($shapes.$shape.$result)
$points += $scoring.$result
}
$points