Growing pains with input on day1, will finish later

This commit is contained in:
Luke Else 2022-12-01 07:56:57 +00:00
parent 7fd1da4874
commit e18371fcca
3 changed files with 2270 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ struct SDay {
template <typename Output>
SDay<Output>::SDay(std::string name) {
this->name = name;
input.open("input/" + name, std::ios::in);
input.open("input/" + name);
}
template <typename Output>

View File

@ -6,6 +6,24 @@ struct SDay01 : public SDay<Output> {
using SDay<Output>::SDay;
//Solutions to both days
Output part1() const override final { return Output(); }
Output part1() const override final {
std::string line{""};
int currentElf{0}, maxElf{0};
while (std::getline(this->input, line))
{
if (line == "")
{//Break to a new elf
if (currentElf > maxElf)
maxElf = currentElf;
currentElf = 0;
continue;
}
//Add the new line to the current elf
currentElf += std::stoi(line);
}
return maxElf;
}
Output part2() const override final { return Output(); }
};