2023 Day 1 now tidied

This commit is contained in:
2023-12-02 09:10:43 +00:00
parent 7a0226e83f
commit 86d9f2d22e
3 changed files with 75 additions and 3 deletions

View File

@@ -1,7 +1,10 @@
#include <array>
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <string>
#include <utility>
using UInt = std::uint64_t;
@@ -44,8 +47,8 @@ auto find_last_digit(std::string const& line) -> int
auto main() -> int
{
UInt sum1{0};
UInt sum2{0};
int sum1{0};
int sum2{0};
std::string line;
while (std::getline(std::cin, line)) {
@@ -54,7 +57,7 @@ auto main() -> int
assert(first != std::string::npos);
assert(last != std::string::npos);
sum1 += (line[first] - '0') * 10;
sum1 += (line[last] - '0');
sum1 += line[last] - '0';
sum2 += find_first_digit(line) * 10;
sum2 += find_last_digit(line);
}