Updated repository and removed day01 to make it clean

This commit is contained in:
Luke Else 2022-12-01 23:05:33 +00:00
parent 43a925864a
commit 28c7d44666
3 changed files with 3 additions and 2285 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,38 +5,7 @@ struct SDay01 : public SDay<Output> {
//Class constructor //Class constructor
using SDay<Output>::SDay; using SDay<Output>::SDay;
std::vector<int> elfs;
//Solutions to both days //Solutions to both days
Output part1() override final { Output part1() override final { return Output(); }
orderCalories(elfs); Output part2() override final { return Output(); }
return elfs[elfs.size()-1];
}
Output part2() override final {
//If elfs has been populated (by part 1)
if (elfs.size() > 0)
return (elfs[elfs.size() - 1] + elfs[elfs.size() - 2] + elfs[elfs.size() - 3]);
return 0;
}
void orderCalories(std::vector<int> &elfs) {
this->input.seekg(0);
std::string line{ "" };
int currentElf{ 0 };
while (std::getline(this->input, line))
{
if (line == "")
{//Break to a new elf
elfs.push_back(currentElf);
currentElf = 0;
continue;
}
//Add the new line to the current elf
currentElf += std::stoi(line);
}
//Push the final elf
elfs.push_back(currentElf);
return std::sort(elfs.begin(), elfs.end());
}
}; };

View File

@ -50,7 +50,6 @@ void runSolutions() {
//Free memory for heap allocated solution //Free memory for heap allocated solution
delete solution; delete solution;
} }
} }