Add .clang-format and apply it

This commit is contained in:
2021-12-02 07:18:16 +00:00
parent e58dede1b6
commit cd5e2538df
103 changed files with 2714 additions and 2132 deletions

View File

@@ -9,12 +9,14 @@
using NumMap = std::map<int, int>;
int add_to_map(NumMap &nums, int num, int turn) {
int add_to_map(NumMap& nums, int num, int turn)
{
auto [it, success] = nums.insert({num, turn});
if (success) {
// std::cout << "Turn " << turn << ": " << num << " (new)\n";
return 0;
} else {
}
else {
int r = turn - it->second;
// std::cout << "Turn " << turn << ": " << num << " (previous seen turn "
// << it->second << " dist = " << r << ")\n";
@@ -23,7 +25,8 @@ int add_to_map(NumMap &nums, int num, int turn) {
}
}
int run(std::string const &s, int num_turns) {
int run(std::string const& s, int num_turns)
{
NumMap seen;
std::size_t pos = 0;
std::size_t len;
@@ -47,7 +50,8 @@ int run(std::string const &s, int num_turns) {
return next_num;
}
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
std::string line;
while (std::getline(std::cin, line)) {
int r = run(line, 2020);