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

@@ -2,31 +2,31 @@
// Created by Matthew Gretton-Dann on 02/12/2021.
//
#include <string>
#include <iostream>
#include <string>
int main()
{
using namespace std::string_literals;
using namespace std::string_literals;
static const auto fwd{"forward "s};
static const auto down{"down "s};
static const auto up{"up "s};
static const auto fwd{"forward "s};
static const auto down{"down "s};
static const auto up{"up "s};
std::string line;
unsigned long horiz{0};
unsigned long depth{0};
while (std::getline(std::cin, line)) {
if (line.size() > fwd.size() && line.substr(0,fwd.size()) == fwd) {
horiz += std::stoul(line.substr(fwd.size()));
}
if (line.size() > down.size() && line.substr(0,down.size()) == down) {
depth += std::stoul(line.substr(down.size()));
}
if (line.size() > up.size() && line.substr(0,up.size()) == up) {
depth -= std::stoul(line.substr(up.size()));
}
std::string line;
unsigned long horiz{0};
unsigned long depth{0};
while (std::getline(std::cin, line)) {
if (line.size() > fwd.size() && line.substr(0, fwd.size()) == fwd) {
horiz += std::stoul(line.substr(fwd.size()));
}
if (line.size() > down.size() && line.substr(0, down.size()) == down) {
depth += std::stoul(line.substr(down.size()));
}
if (line.size() > up.size() && line.substr(0, up.size()) == up) {
depth -= std::stoul(line.substr(up.size()));
}
}
std::cout << "Distance * depth: " << horiz << " * " << depth << " = " << horiz * depth << '\n';
std::cout << "Distance * depth: " << horiz << " * " << depth << " = " << horiz * depth << '\n';
}