Compare commits

..

No commits in common. "56c9032aabd5381918f3d47885f7be9e6704da68" and "0a755fe32432badfeb8114f2f4fc0458dfa7613f" have entirely different histories.

2 changed files with 0 additions and 2591 deletions

View File

@ -1,91 +0,0 @@
import { readFileSync } from "fs";
const input = readFileSync("rps.txt", "utf-8");
let totalScore = 0;
// A X rock 1
// B Y paper 2
// C Z scissors 3
// lose 0
// draw 3
// win 6
input.split("\n").forEach(line => {
const arr = line.split(" ");
totalScore += getScore(arr[0], arr[1]);
});
console.log(totalScore);
function getScore(opponent, player) {
let score = 0;
switch(player) {
case "X":
//score += 1;
score += 0;
break;
case "Y":
//score += 2;
score += 3;
break;
case "Z":
//score += 3;
score += 6;
break;
}
switch(opponent) {
case "A":
switch(player) {
case "X":
//score += 3;
score += 3;
break;
case "Y":
//score += 6;
score += 1;
break;
case "Z":
//score += 0;
score += 2;
break;
}
break;
case "B":
switch(player) {
case "X":
score += 1;
break;
case "Y":
score += 2;
break;
case "Z":
score += 3;
break;
}
break;
case "C":
switch(player) {
case "X":
//score += 6;
score += 2;
break;
case "Y":
//score += 0;
score += 3;
break;
case "Z":
//score += 3;
score += 1;
break;
}
break;
}
return score;
}

File diff suppressed because it is too large Load Diff