Created
December 2, 2022 11:07
-
-
Save tech-zombie/4b55cd4d50f16e92474ce6fe91a02a0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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