Completed Day1
This commit is contained in:
parent
e18371fcca
commit
43a925864a
@ -152,7 +152,6 @@
|
||||
<ClCompile Include="src\days\day23.cpp" />
|
||||
<ClCompile Include="src\days\day24.cpp" />
|
||||
<ClCompile Include="src\days\day25.cpp" />
|
||||
<ClCompile Include="src\days\Source.cpp" />
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -18,9 +18,6 @@
|
||||
<ClCompile Include="src\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\Source.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day01.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -18,8 +18,8 @@ struct SDay {
|
||||
SDay(std::string name);
|
||||
~SDay();
|
||||
|
||||
virtual Output part1() const = 0;
|
||||
virtual Output part2() const = 0;
|
||||
virtual Output part1() = 0;
|
||||
virtual Output part2() = 0;
|
||||
};
|
||||
|
||||
template <typename Output>
|
||||
|
@ -1,11 +0,0 @@
|
||||
#include "../aoc2022.h"
|
||||
|
||||
template <typename Output>
|
||||
struct SDay0 : public SDay<Output> {
|
||||
//Class constructor
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
};
|
@ -5,25 +5,38 @@ struct SDay01 : public SDay<Output> {
|
||||
//Class constructor
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final {
|
||||
std::vector<int> elfs;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() override final {
|
||||
orderCalories(elfs);
|
||||
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}, maxElf{0};
|
||||
int currentElf{ 0 };
|
||||
|
||||
while (std::getline(this->input, line))
|
||||
{
|
||||
if (line == "")
|
||||
{//Break to a new elf
|
||||
if (currentElf > maxElf)
|
||||
maxElf = currentElf;
|
||||
elfs.push_back(currentElf);
|
||||
currentElf = 0;
|
||||
continue;
|
||||
}
|
||||
//Add the new line to the current elf
|
||||
currentElf += std::stoi(line);
|
||||
}
|
||||
return maxElf;
|
||||
//Push the final elf
|
||||
elfs.push_back(currentElf);
|
||||
return std::sort(elfs.begin(), elfs.end());
|
||||
}
|
||||
Output part2() const override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay02 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay03 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay04 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay05 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay06 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay07 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay08 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay09 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay10 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay11 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay12 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay13 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay14 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay15 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay16 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay17 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay18 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay19 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay20 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay21 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay22 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay23 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay24 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -6,6 +6,6 @@ struct SDay25 : public SDay<Output> {
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() const override final { return Output(); }
|
||||
Output part2() const override final { return Output(); }
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ void runSolutions() {
|
||||
new SDay22<Output>("day22"),
|
||||
new SDay23<Output>("day23"),
|
||||
new SDay24<Output>("day24"),
|
||||
new SDay25<Output>("day25"),
|
||||
new SDay25<Output>("day25")
|
||||
};
|
||||
|
||||
for (auto& solution : solutions)
|
||||
|
Loading…
Reference in New Issue
Block a user