Initial commit

This commit is contained in:
2021-12-01 20:31:53 +00:00
commit 2f44ccc3a7
106 changed files with 9333 additions and 0 deletions

32
2020/puzzle-10-01.cc Normal file
View File

@@ -0,0 +1,32 @@
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <list>
#include <map>
#include <regex>
#include <string>
using Jolt = unsigned long;
int main(int argc, char **argv) {
std::vector<Jolt> jolts;
for (std::string line; std::getline(std::cin, line);) {
jolts.push_back(std::stoul(line));
}
std::sort(jolts.begin(), jolts.end());
std::array<unsigned, 4> gaps = {};
Jolt last = 0;
for (auto j : jolts) {
++gaps[j - last];
last = j;
}
// and the gap to our voltage
++gaps[3];
std::cout << gaps[1] << " * " << gaps[3] << " = " << gaps[1] * gaps[3]
<< "\n";
return 0;
}