aocpp/2017/10.cpp

27 lines
644 B
C++
Raw Permalink Normal View History

2022-11-24 12:10:08 -08:00
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <doctest.h>
#include <aocpp/Startup.hpp>
#include <aocpp/Parsing.hpp>
#include <knothash.hpp>
2023-01-31 09:15:15 -08:00
auto Main(std::istream & in, std::ostream & out) -> void
2023-01-31 08:58:42 -08:00
{
2022-11-24 12:10:08 -08:00
std::string line;
2023-01-31 08:58:42 -08:00
std::getline(in, line);
2022-11-24 12:10:08 -08:00
std::vector<std::uint8_t> lengths1;
for (auto && x : aocpp::SplitOn(line, ",")) {
lengths1.push_back(std::stoul(x));
}
auto result = knothash::hash_ex<256>(1, lengths1.begin(), lengths1.end());
2023-01-31 09:15:15 -08:00
out << "Part 1: " << long{result[0]} * long{result[1]} << std::endl;
2022-11-24 12:10:08 -08:00
2023-01-31 09:15:15 -08:00
out << "Part 2: " << knothash::render(knothash::hash(line)) << std::endl;
2023-01-31 08:58:42 -08:00
}