Growing pains with input on day1, will finish later
This commit is contained in:
parent
7fd1da4874
commit
e18371fcca
2250
input/day01
2250
input/day01
File diff suppressed because it is too large
Load Diff
@ -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>
|
||||
|
@ -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(); }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user