Skip to content

Instantly share code, notes, and snippets.

@tech-zombie
Created December 2, 2022 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tech-zombie/4b55cd4d50f16e92474ce6fe91a02a0b to your computer and use it in GitHub Desktop.
Save tech-zombie/4b55cd4d50f16e92474ce6fe91a02a0b to your computer and use it in GitHub Desktop.
$allGames = gc .\input.txt
$score = 0
#Rock = A X 1
#Paper = B Y 2
#scissors = C Z 3
#(0 if you lost, 3 if the round was a draw, and 6 if you won).
forEach ($game in $allGames)
{
switch ($game) {
"A X" {$score += 3 ; $score += 1}#draw RR
"A Y" {$score += 6 ; $score += 2}#win RP
"A Z" {$score += 0 ; $score += 3}#loss RS
"B X" {$score += 0 ; $score += 1}#loss PR
"B Y" {$score += 3 ; $score += 2}#draw PP
"B Z" {$score += 6 ; $score += 3}#win PS
"C X" {$score += 6 ; $score += 1}#win SR
"C Y" {$score += 0 ; $score += 2}#loss SP
"C Z" {$score += 3 ; $score += 3}#draw SS
}
}
$score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment