2023 Day 1 now tidied
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user