|
|
@ -13,7 +13,7 @@ int Day02::getScore(char opponent, char me) { |
|
|
|
|
|
|
|
|
|
|
|
Result Day02::Task1() { |
|
|
|
Result Day02::Task1() { |
|
|
|
int score = 0; |
|
|
|
int score = 0; |
|
|
|
for (string line : input){ |
|
|
|
for (string line: input) { |
|
|
|
char predict = line.at(0); |
|
|
|
char predict = line.at(0); |
|
|
|
char answer = char(line.at(2) - 23); |
|
|
|
char answer = char(line.at(2) - 23); |
|
|
|
score += getScore(predict, answer); |
|
|
|
score += getScore(predict, answer); |
|
|
@ -23,19 +23,19 @@ Result Day02::Task1() { |
|
|
|
|
|
|
|
|
|
|
|
Result Day02::Task2() { |
|
|
|
Result Day02::Task2() { |
|
|
|
int score = 0; |
|
|
|
int score = 0; |
|
|
|
for (string line : input){ |
|
|
|
for (string line: input) { |
|
|
|
char predict = line.at(0); |
|
|
|
char predict = line.at(0); |
|
|
|
char outcome = line.at(2); |
|
|
|
char outcome = line.at(2); |
|
|
|
|
|
|
|
|
|
|
|
char answer; |
|
|
|
char answer; |
|
|
|
if (outcome == 'X'){ |
|
|
|
if (outcome == 'X') { |
|
|
|
if (predict > 'A') answer = char(predict - 1); |
|
|
|
if (predict > 'A') answer = char(predict - 1); |
|
|
|
else answer = 'C'; |
|
|
|
else answer = 'C'; |
|
|
|
} |
|
|
|
} |
|
|
|
if (outcome == 'Y'){ |
|
|
|
if (outcome == 'Y') { |
|
|
|
answer = predict; |
|
|
|
answer = predict; |
|
|
|
} |
|
|
|
} |
|
|
|
if (outcome == 'Z'){ |
|
|
|
if (outcome == 'Z') { |
|
|
|
if (predict < 'C') answer = char(predict + 1); |
|
|
|
if (predict < 'C') answer = char(predict + 1); |
|
|
|
else answer = 'A'; |
|
|
|
else answer = 'A'; |
|
|
|
} |
|
|
|
} |
|
|
|