parent
56580a1af0
commit
8fa4e90613
50 changed files with 135 additions and 134 deletions
@ -1,46 +1,46 @@ |
||||
#include "Day02.h" |
||||
|
||||
int Day02::getScore(char opponent, char me) { |
||||
int outcome; |
||||
if (opponent == me) |
||||
outcome = 3; |
||||
else if (opponent == me + 1 || opponent == me - 2) |
||||
outcome = 0; |
||||
else |
||||
outcome = 6; |
||||
return outcome + me - 64; |
||||
int outcome; |
||||
if (opponent == me) |
||||
outcome = 3; |
||||
else if (opponent == me + 1 || opponent == me - 2) |
||||
outcome = 0; |
||||
else |
||||
outcome = 6; |
||||
return outcome + me - 64; |
||||
} |
||||
|
||||
Result Day02::Task1() { |
||||
int score = 0; |
||||
for (string line : input){ |
||||
char predict = line.at(0); |
||||
char answer = char(line.at(2) - 23); |
||||
score += getScore(predict, answer); |
||||
} |
||||
return to_string(score); |
||||
int score = 0; |
||||
for (string line: input) { |
||||
char predict = line.at(0); |
||||
char answer = char(line.at(2) - 23); |
||||
score += getScore(predict, answer); |
||||
} |
||||
return to_string(score); |
||||
} |
||||
|
||||
Result Day02::Task2() { |
||||
int score = 0; |
||||
for (string line : input){ |
||||
char predict = line.at(0); |
||||
char outcome = line.at(2); |
||||
int score = 0; |
||||
for (string line: input) { |
||||
char predict = line.at(0); |
||||
char outcome = line.at(2); |
||||
|
||||
char answer; |
||||
if (outcome == 'X'){ |
||||
if (predict > 'A') answer = char(predict - 1); |
||||
else answer = 'C'; |
||||
} |
||||
if (outcome == 'Y'){ |
||||
answer = predict; |
||||
} |
||||
if (outcome == 'Z'){ |
||||
if (predict < 'C') answer = char(predict + 1); |
||||
else answer = 'A'; |
||||
} |
||||
char answer; |
||||
if (outcome == 'X') { |
||||
if (predict > 'A') answer = char(predict - 1); |
||||
else answer = 'C'; |
||||
} |
||||
if (outcome == 'Y') { |
||||
answer = predict; |
||||
} |
||||
if (outcome == 'Z') { |
||||
if (predict < 'C') answer = char(predict + 1); |
||||
else answer = 'A'; |
||||
} |
||||
|
||||
score += getScore(predict, answer); |
||||
} |
||||
return to_string(score); |
||||
score += getScore(predict, answer); |
||||
} |
||||
return to_string(score); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day03.h" |
||||
|
||||
Result Day03::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day03::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day04.h" |
||||
|
||||
Result Day04::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day04::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day05.h" |
||||
|
||||
Result Day05::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day05::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day06.h" |
||||
|
||||
Result Day06::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day06::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day07.h" |
||||
|
||||
Result Day07::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day07::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day08.h" |
||||
|
||||
Result Day08::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day08::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day09.h" |
||||
|
||||
Result Day09::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day09::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day10.h" |
||||
|
||||
Result Day10::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day10::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day11.h" |
||||
|
||||
Result Day11::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day11::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day12.h" |
||||
|
||||
Result Day12::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day12::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day13.h" |
||||
|
||||
Result Day13::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day13::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day14.h" |
||||
|
||||
Result Day14::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day14::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day15.h" |
||||
|
||||
Result Day15::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day15::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day16.h" |
||||
|
||||
Result Day16::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day16::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day17.h" |
||||
|
||||
Result Day17::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day17::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day18.h" |
||||
|
||||
Result Day18::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day18::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day19.h" |
||||
|
||||
Result Day19::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day19::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day20.h" |
||||
|
||||
Result Day20::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day20::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day21.h" |
||||
|
||||
Result Day21::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day21::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day22.h" |
||||
|
||||
Result Day22::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day22::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day23.h" |
||||
|
||||
Result Day23::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day23::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day24.h" |
||||
|
||||
Result Day24::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day24::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
@ -1,9 +1,9 @@ |
||||
#include "Day25.h" |
||||
|
||||
Result Day25::Task1() { |
||||
return Day::Task1(); |
||||
return Day::Task1(); |
||||
} |
||||
|
||||
Result Day25::Task2() { |
||||
return Day::Task2(); |
||||
return Day::Task2(); |
||||
} |
Loading…
Reference in new issue