This commit is contained in:
Logan G 2022-12-02 16:39:08 -07:00
parent 1081dde9f3
commit fbc8ad4812
Signed by untrusted user: logan
GPG key ID: E328528C921E7A7A
5 changed files with 5149 additions and 0 deletions

2500
day2/12586 Normal file

File diff suppressed because it is too large Load diff

69
day2/day2.cpp Normal file
View file

@ -0,0 +1,69 @@
#include <iostream>
#include <fstream>
#include <string>
int main() {
int score = 0;
int games = 0;
std::ifstream file;
file.open("input");
std::string line;
while (std::getline(file, line)) {
games += 1;
std::cout << games << std::endl;
if (line[2] == 'X') {
score += 1;
switch(line[0]) {
case 'A':
std::cout << "Tie " << line[0] << " " << line[2] << std::endl;
score += 3;
break;
case 'C':
std::cout << "Win " << line[0] << " " << line[2] << std::endl;
score += 6;
break;
default:
std::cout << "Loss " << line[0] << " " << line[2] << std::endl;
break;
}
} else if (line[2] == 'Y') {
score += 2;
switch(line[0]) {
case 'B':
std::cout << "Tie " << line[0] << " " << line[2] << std::endl;
score += 3;
break;
case 'A':
std::cout << "Win " << line[0] << " " << line[2] << std::endl;
score += 6;
break;
default:
std::cout << "Loss " << line[0] << " " << line[2] << std::endl;
break;
}
} else if (line[2] == 'Z') {
score += 3;
switch(line[0]) {
case 'C':
std::cout << "Tie " << line[0] << " " << line[2] << std::endl;
score += 3;
break;
case 'B':
std::cout << "Win " << line[0] << " " << line[2] << std::endl;
score += 6;
break;
default:
std::cout << "Loss " << line[0] << " " << line[2] << std::endl;
break;
}
}
//std::cout << line[0] << std::endl;
}
std::cout << score << std::endl;
return 0;
}

77
day2/day2part2.cpp Normal file
View file

@ -0,0 +1,77 @@
#include <iostream>
#include <fstream>
#include <string>
int main() {
int score = 0;
int games = 0;
std::ifstream file;
file.open("input");
std::string line;
while (std::getline(file, line)) {
games += 1;
std::cout << games << std::endl;
if (line[0] == 'A') { // Rock
switch(line[2]) {
case 'X':
std::cout << "Loss" << std::endl;
score += 3; // Scissors
break;
case 'Y':
std::cout << "Tie" << std::endl;
score += 3; // Tie
score += 1; // Rock
break;
case 'Z':
std::cout << "Win" << std::endl;
score += 6; // Win
score += 2; // Paper
break;
}
} else if (line[0] == 'B') { // Paper
switch(line[2]) {
case 'X':
std::cout << "Loss" << std::endl;
score += 1; // Rock
break;
case 'Y':
std::cout << "Tie" << std::endl;
score += 3; // Tie
score += 2; // Paper
break;
case 'Z':
std::cout << "Win" << std::endl;
score += 6; // Win
score += 3; // Scissors
break;
}
} else if (line[0] == 'C') { // Scissors
switch(line[2]) {
case 'X':
std::cout << "Loss" << std::endl;
score += 2; // Paper
break;
case 'Y':
std::cout << "Tie" << std::endl;
score += 3; // Tie
score += 3; // Scissors
break;
case 'Z':
std::cout << "Win" << std::endl;
score += 6; // Win
score += 1; // Rock
break;
}
}
//std::cout << line[0] << std::endl;
}
std::cout << score << std::endl;
return 0;
}

2500
day2/input Normal file

File diff suppressed because it is too large Load diff

3
day2/input2 Normal file
View file

@ -0,0 +1,3 @@
A Y
B X
C Z