Compare commits
11 Commits
109d333341
...
323e2ade2f
Author | SHA1 | Date | |
---|---|---|---|
323e2ade2f | |||
927b7ee529 | |||
273384c8e7 | |||
1681640aaa | |||
ec4d60142d | |||
51f04a4647 | |||
35d509754f | |||
38004618a6 | |||
a892885241 | |||
8a1eb79841 | |||
425f2dd052 |
@ -7,7 +7,7 @@ find_package(PkgConfig REQUIRED)
|
|||||||
|
|
||||||
pkg_check_modules(Jemalloc REQUIRED jemalloc)
|
pkg_check_modules(Jemalloc REQUIRED jemalloc)
|
||||||
|
|
||||||
set(LINKER_OPTIONS -Wl,--sort-common,--as-needed,--gc-sections,--strip-all)
|
set(LINKER_OPTIONS -Wl,--sort-common,--as-needed#[[,--gc-sections,--strip-all]])
|
||||||
|
|
||||||
set(COMPILE_FLAGS
|
set(COMPILE_FLAGS
|
||||||
-pipe
|
-pipe
|
||||||
@ -18,42 +18,52 @@ set(COMPILE_FLAGS
|
|||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra
|
||||||
-Wpedantic
|
-Wpedantic
|
||||||
-ffunction-sections
|
|
||||||
-fdata-sections
|
|
||||||
-funroll-loops
|
-funroll-loops
|
||||||
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
|
-fuse-ld=gold
|
||||||
|
|
||||||
)
|
)
|
||||||
set(LINKER_OPTIONS
|
set(LINKER_OPTIONS
|
||||||
${LINKER_OPTIONS}
|
${LINKER_OPTIONS}
|
||||||
-fuse-ld=gold
|
-fuse-ld=gold
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
set(LINKER_FLAGS stdc++)
|
||||||
set(COMPILE_FLAGS -stdlib=libc++ -Wmove ${COMPILE_FLAGS} -fwhole-program-vtables)
|
|
||||||
set(LINKER_OPTIONS ${LINKER_OPTIONS} -fwhole-program-vtables)
|
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||||
set(LINKER_FLAGS ${LINKER_FLAGS} c++)
|
set(COMPILE_FLAGS
|
||||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
${COMPILE_FLAGS}
|
||||||
set(COMPILE_FLAGS ${COMPILE_FLAGS} -fuse-ld=gold -fdevirtualize-at-ltrans)
|
-ffunction-sections
|
||||||
|
-fdata-sections
|
||||||
|
-fdevirtualize-at-ltrans
|
||||||
|
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
|
||||||
|
)
|
||||||
set(LINKER_OPTIONS ${LINKER_OPTIONS} -fdevirtualize-at-ltrans)
|
set(LINKER_OPTIONS ${LINKER_OPTIONS} -fdevirtualize-at-ltrans)
|
||||||
set(LINKER_FLAGS ${LINKER_FLAGS} stdc++)
|
set(LINKER_FLAGS ${LINKER_FLAGS} ${Jemalloc_LIBRARIES})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
add_executable(AdventOfCode2023 main.cpp)
|
add_executable(AdventOfCode2023 main.cpp)
|
||||||
|
|
||||||
add_library(pb_1 STATIC pb_1/problem_1.cpp pb_1/problem_1.hpp)
|
add_subdirectory(common)
|
||||||
|
|
||||||
|
add_subdirectory(pb_1)
|
||||||
|
|
||||||
set_target_properties(AdventOfCode2023 pb_1 PROPERTIES
|
add_subdirectory(pb_2)
|
||||||
|
|
||||||
|
add_subdirectory(pb_4)
|
||||||
|
|
||||||
|
set_target_properties(AdventOfCode2023 pb_1 pb_2 pb_4 PROPERTIES
|
||||||
CXX_STANDARD 20
|
CXX_STANDARD 20
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
CXX_EXTENSIONS OFF
|
CXX_EXTENSIONS OFF
|
||||||
INTERPROCEDURAL_OPTIMIZATION ON
|
# INTERPROCEDURAL_OPTIMIZATION ON
|
||||||
UNITY_BUILD ON
|
# UNITY_BUILD ON
|
||||||
)
|
)
|
||||||
target_compile_definitions(AdventOfCode2023 PUBLIC $<$<AND:$<CONFIG:Debug>,$<STREQUAL:$<CXX_COMPILER_ID>,GNU>>:_GLIBCXX_DEBUG>)
|
|
||||||
target_compile_definitions(pb_1 PUBLIC $<$<AND:$<CONFIG:Debug>,$<STREQUAL:$<CXX_COMPILER_ID>,GNU>>:_GLIBCXX_DEBUG>)
|
#target_compile_definitions(AdventOfCode2023 PUBLIC $<$<AND:$<CONFIG:Debug>,$<STREQUAL:$<CXX_COMPILER_ID>,GNU>>:_GLIBCXX_DEBUG>)
|
||||||
target_compile_options(AdventOfCode2023 PUBLIC ${COMPILE_OPTIONS})
|
|
||||||
target_link_options(AdventOfCode2023 PUBLIC ${LINKER_OPTIONS})
|
#target_compile_options(AdventOfCode2023 PUBLIC ${COMPILE_FLAGS})
|
||||||
target_link_libraries(AdventOfCode2023 PUBLIC pb_1 ${Jemalloc_LIBRARIES})
|
|
||||||
target_link_libraries(pb_1 PUBLIC ${Jemalloc_LIBRARIES})
|
#target_link_options(AdventOfCode2023 PUBLIC ${LINKER_OPTIONS})
|
||||||
|
|
||||||
|
target_link_libraries(AdventOfCode2023 PUBLIC pb_1 pb_2 pb_4 ${LINKER_FLAGS})
|
||||||
|
9
common/CMakeLists.txt
Normal file
9
common/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
project(common_lib CXX)
|
||||||
|
|
||||||
|
add_library(common SHARED common_functions.cpp common_functions.hpp)
|
||||||
|
|
||||||
|
target_compile_definitions(common PUBLIC $<$<AND:$<CONFIG:Debug>,$<STREQUAL:$<CXX_COMPILER_ID>,GNU>>:_GLIBCXX_DEBUG>)
|
||||||
|
|
||||||
|
target_compile_options(common PUBLIC ${COMPILE_FLAGS})
|
||||||
|
|
||||||
|
target_link_options(common PUBLIC ${LINKER_OPTIONS})
|
34
common/common_functions.cpp
Normal file
34
common/common_functions.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// Created by postaron on 31/07/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "common_functions.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
std::optional<std::ifstream> common::read_file(const std::filesystem::path &problemFile) noexcept {
|
||||||
|
std::ifstream file(problemFile);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
const auto error_state = file.rdstate();
|
||||||
|
switch (error_state) {
|
||||||
|
case std::ios::badbit:
|
||||||
|
std::cerr << "Fatal I/O error occurred.\n";
|
||||||
|
break;
|
||||||
|
case std::ios::eofbit:
|
||||||
|
std::cerr << "End of file reached.\n";
|
||||||
|
break;
|
||||||
|
case std::ios::failbit:
|
||||||
|
std::cerr << "Non-fatal I/O error occurred.\n";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cerr << "impossible to reach.\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const auto path_string = problemFile.string();
|
||||||
|
const auto msg = std::format("Failed to open file {}: ", path_string);
|
||||||
|
std::perror(msg.c_str());
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
|
||||||
|
}
|
18
common/common_functions.hpp
Normal file
18
common/common_functions.hpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// Created by postaron on 31/07/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef ADVENTOFCODE2023_COMMON_FUNCTIONS_HPP
|
||||||
|
#define ADVENTOFCODE2023_COMMON_FUNCTIONS_HPP
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
namespace common {
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
std::optional<std::ifstream> read_file(const fs::path &problemFile) noexcept;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //ADVENTOFCODE2023_COMMON_FUNCTIONS_HPP
|
@ -1,6 +1,6 @@
|
|||||||
abcone2threexyz
|
|
||||||
two1nine
|
|
||||||
eightwothree
|
eightwothree
|
||||||
|
two1ninethr
|
||||||
|
abcone2threexyz
|
||||||
xtwone3four
|
xtwone3four
|
||||||
4nineeightseven2
|
4nineeightseven2
|
||||||
zoneight234
|
zoneight234
|
||||||
|
100
inputs/pb2.txt
Normal file
100
inputs/pb2.txt
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
Game 1: 2 blue, 3 red; 3 green, 3 blue, 6 red; 4 blue, 6 red; 2 green, 2 blue, 9 red; 2 red, 4 blue
|
||||||
|
Game 2: 4 red, 1 green; 3 red; 13 green, 5 red, 3 blue; 3 green, 2 red; 3 blue, 5 red, 3 green; 2 red, 3 blue, 12 green
|
||||||
|
Game 3: 4 red, 1 green, 1 blue; 1 red, 1 blue; 6 red, 1 green; 6 red, 3 blue, 1 green; 4 red
|
||||||
|
Game 4: 4 blue, 12 red, 4 green; 6 green, 3 blue, 19 red; 3 blue, 2 red, 2 green
|
||||||
|
Game 5: 1 red, 5 blue, 16 green; 1 red, 6 green, 3 blue; 2 red, 12 blue; 17 blue, 3 green; 7 green, 2 red, 6 blue
|
||||||
|
Game 6: 3 green, 1 blue, 5 red; 5 green, 5 red; 2 green, 2 blue, 3 red; 5 green, 2 red; 3 green, 6 red, 3 blue; 5 green, 4 red
|
||||||
|
Game 7: 15 blue, 1 red, 6 green; 4 blue, 7 green, 2 red; 14 blue, 5 green, 2 red
|
||||||
|
Game 8: 6 blue, 3 green, 10 red; 2 blue, 1 green, 5 red; 6 blue, 3 green, 12 red; 11 red, 1 green, 1 blue; 5 blue, 14 red, 3 green; 3 red
|
||||||
|
Game 9: 15 red, 3 blue; 1 blue, 16 red; 1 red, 3 blue; 1 blue, 1 green, 9 red
|
||||||
|
Game 10: 1 red; 1 blue, 7 green; 1 green, 5 blue; 3 blue, 3 green; 1 green
|
||||||
|
Game 11: 19 blue, 13 green; 19 blue, 2 green; 10 blue, 3 red, 12 green; 11 blue, 1 red, 6 green
|
||||||
|
Game 12: 7 green, 5 blue; 6 green, 3 red, 6 blue; 2 red, 5 blue, 15 green; 2 red, 1 blue, 1 green; 4 red, 4 green, 2 blue; 3 blue, 6 green
|
||||||
|
Game 13: 9 red, 2 blue, 2 green; 1 blue, 2 red, 15 green; 9 green, 2 blue, 9 red; 5 blue, 8 green, 5 red; 2 blue, 11 green, 5 red
|
||||||
|
Game 14: 9 blue, 1 red; 10 blue, 4 green, 3 red; 2 red, 6 blue; 4 green, 2 blue, 1 red; 5 green, 2 red, 11 blue; 12 blue, 2 red, 1 green
|
||||||
|
Game 15: 9 blue, 7 green, 12 red; 9 red, 17 green, 8 blue; 6 red, 4 blue, 4 green; 5 red, 17 green
|
||||||
|
Game 16: 5 green, 4 red; 3 blue, 3 red, 14 green; 6 red, 5 blue, 12 green
|
||||||
|
Game 17: 8 blue, 5 green, 2 red; 6 red, 6 blue; 9 red; 5 blue, 2 green, 8 red; 13 red, 4 blue, 4 green; 9 blue, 3 green, 5 red
|
||||||
|
Game 18: 8 green, 1 red, 2 blue; 4 green, 4 red, 1 blue; 6 blue, 2 red
|
||||||
|
Game 19: 3 green, 9 blue; 4 blue, 10 red; 6 red, 3 green, 3 blue; 6 red, 4 green, 9 blue
|
||||||
|
Game 20: 11 green, 3 blue; 6 green; 3 green, 6 blue; 1 red, 5 green; 6 blue, 7 green
|
||||||
|
Game 21: 1 green, 1 blue, 12 red; 6 red, 2 blue; 5 green, 4 red, 2 blue; 11 red, 8 green, 1 blue
|
||||||
|
Game 22: 10 red; 1 red, 13 green, 9 blue; 6 blue, 12 red, 12 green; 10 red, 8 blue, 11 green; 2 green, 1 red, 3 blue; 7 red, 1 blue, 8 green
|
||||||
|
Game 23: 11 red, 15 blue; 10 blue, 16 red, 1 green; 14 blue, 5 red; 1 green, 9 red, 9 blue; 1 red, 7 blue, 3 green; 6 red, 2 green, 3 blue
|
||||||
|
Game 24: 6 blue, 11 red; 16 green, 2 red, 1 blue; 8 red, 7 blue; 14 blue, 9 green, 9 red; 13 green, 4 red, 8 blue; 2 red, 7 blue, 1 green
|
||||||
|
Game 25: 2 green, 12 blue, 1 red; 10 blue, 5 red, 5 green; 2 blue, 9 red, 3 green; 5 blue, 4 red, 2 green
|
||||||
|
Game 26: 7 blue, 6 red, 1 green; 2 blue, 3 green, 12 red; 2 blue, 6 red, 5 green
|
||||||
|
Game 27: 2 green, 3 red; 4 green; 2 red, 1 blue, 1 green; 2 red, 1 green, 2 blue
|
||||||
|
Game 28: 11 blue, 1 red, 5 green; 2 blue, 2 red, 4 green; 10 blue, 4 red, 1 green
|
||||||
|
Game 29: 6 blue, 17 red, 1 green; 8 blue, 4 red; 14 blue, 1 red, 3 green
|
||||||
|
Game 30: 2 blue, 4 green; 7 green, 1 blue, 1 red; 1 blue, 8 green
|
||||||
|
Game 31: 15 blue, 9 green, 2 red; 5 green, 4 blue, 1 red; 1 green, 15 red, 7 blue; 5 red, 2 blue
|
||||||
|
Game 32: 1 blue, 5 red, 3 green; 3 green, 8 red, 1 blue; 5 green, 1 red; 4 green, 3 blue, 15 red; 2 green, 1 blue; 4 blue, 15 red, 4 green
|
||||||
|
Game 33: 3 red, 10 blue; 4 red, 9 blue; 1 green, 10 blue
|
||||||
|
Game 34: 3 blue, 1 green, 9 red; 4 green, 2 red, 9 blue; 7 blue, 3 red; 6 blue, 13 red; 4 green, 13 blue, 9 red
|
||||||
|
Game 35: 14 red, 1 green; 1 red, 2 green, 4 blue; 3 blue, 10 red, 6 green; 5 blue, 6 red, 7 green; 7 blue, 5 red
|
||||||
|
Game 36: 2 blue, 8 red, 9 green; 9 green, 3 red, 10 blue; 6 red, 8 blue, 1 green; 6 green, 8 red, 4 blue
|
||||||
|
Game 37: 10 green, 3 red, 6 blue; 2 blue, 9 red, 5 green; 13 green, 9 red, 10 blue; 2 blue, 4 green, 9 red
|
||||||
|
Game 38: 4 red, 14 blue, 12 green; 6 red, 12 green, 18 blue; 6 green, 1 blue, 1 red
|
||||||
|
Game 39: 5 red, 1 blue, 3 green; 1 blue, 3 green, 8 red; 15 red, 1 blue, 5 green; 3 green, 5 red; 1 blue, 14 red; 3 green, 1 blue, 12 red
|
||||||
|
Game 40: 8 green, 4 blue; 5 blue, 7 red, 8 green; 5 blue, 8 green; 6 green, 3 red, 12 blue; 14 blue, 7 green, 2 red; 1 green, 7 red, 5 blue
|
||||||
|
Game 41: 7 red, 10 green; 10 red, 6 green; 9 red, 7 green, 1 blue; 3 red, 1 blue
|
||||||
|
Game 42: 3 green, 2 blue, 13 red; 1 blue, 3 red; 11 green, 16 red; 3 green, 1 blue, 16 red; 5 red, 8 green
|
||||||
|
Game 43: 12 blue, 9 red; 16 blue, 2 red, 7 green; 4 red, 1 blue, 11 green; 15 blue, 4 red, 9 green
|
||||||
|
Game 44: 17 green, 5 blue, 2 red; 9 green, 11 blue, 1 red; 20 green, 3 blue, 8 red; 2 red, 13 green, 9 blue; 15 green, 12 blue; 4 blue, 7 green, 9 red
|
||||||
|
Game 45: 5 green; 5 green, 1 red; 3 green, 2 blue; 1 green, 1 blue, 1 red
|
||||||
|
Game 46: 10 red, 11 green; 16 green, 8 blue, 12 red; 9 green, 9 blue
|
||||||
|
Game 47: 20 green, 17 red, 1 blue; 16 red, 2 blue, 11 green; 3 blue, 19 red, 1 green; 3 blue, 17 red, 17 green; 12 green, 2 blue, 7 red
|
||||||
|
Game 48: 1 red, 4 blue, 6 green; 19 green, 1 red, 1 blue; 16 green, 3 blue, 1 red; 3 blue, 17 green; 4 blue, 12 green
|
||||||
|
Game 49: 13 green, 2 blue, 1 red; 1 green, 8 red, 2 blue; 11 red, 11 green, 3 blue; 7 red, 8 green, 4 blue
|
||||||
|
Game 50: 11 blue, 1 red, 2 green; 1 green, 10 blue; 1 blue; 6 blue; 1 green, 2 blue
|
||||||
|
Game 51: 3 red, 3 green, 1 blue; 3 green, 3 red; 10 green, 4 red; 3 red, 2 green
|
||||||
|
Game 52: 1 red, 4 blue; 1 green, 11 blue; 1 green, 3 red, 6 blue; 4 red, 1 green, 4 blue; 9 blue, 1 green; 10 blue, 1 green
|
||||||
|
Game 53: 2 blue, 4 green, 1 red; 8 blue, 4 red, 7 green; 9 red, 7 blue, 6 green; 3 red, 7 green, 1 blue; 2 red, 9 blue, 5 green; 1 green, 7 red, 10 blue
|
||||||
|
Game 54: 1 red, 1 blue, 5 green; 2 red, 1 green, 2 blue; 3 green, 3 blue, 2 red; 4 red; 12 red, 5 green, 2 blue
|
||||||
|
Game 55: 2 red, 11 blue; 16 green, 7 red, 16 blue; 4 blue, 11 green, 7 red; 8 green, 18 blue, 8 red
|
||||||
|
Game 56: 2 blue, 2 green, 1 red; 1 red, 1 green; 1 red; 4 green; 1 blue; 1 blue, 7 green
|
||||||
|
Game 57: 4 blue, 3 green; 16 green, 2 red, 5 blue; 1 red, 13 green, 2 blue; 3 blue, 12 green, 2 red; 2 red, 5 blue, 4 green; 10 green, 2 blue
|
||||||
|
Game 58: 3 blue, 8 green; 4 green, 3 blue; 7 green, 5 blue, 5 red; 8 green; 3 red, 6 blue, 9 green; 2 red, 10 green, 4 blue
|
||||||
|
Game 59: 7 blue, 6 green, 5 red; 7 red, 2 blue; 5 red, 11 green, 14 blue; 8 green, 17 red
|
||||||
|
Game 60: 3 green, 8 blue, 2 red; 4 green, 7 blue, 6 red; 13 blue, 8 green, 2 red; 10 red, 6 blue, 5 green; 11 green, 3 blue, 4 red; 9 red, 5 green, 9 blue
|
||||||
|
Game 61: 4 red, 18 blue, 13 green; 9 green, 5 red, 3 blue; 4 green, 3 blue, 4 red; 8 red, 4 green, 7 blue; 8 red, 4 blue, 6 green; 10 green, 5 red, 14 blue
|
||||||
|
Game 62: 12 red, 14 blue, 9 green; 9 blue, 6 red, 4 green; 2 red, 5 blue; 1 red, 12 blue
|
||||||
|
Game 63: 11 blue, 13 red, 11 green; 4 blue, 9 green; 8 blue, 9 red; 7 red, 11 green, 7 blue
|
||||||
|
Game 64: 10 blue, 8 red, 12 green; 10 red, 12 blue, 9 green; 3 green, 17 red; 12 green, 15 blue, 16 red; 6 green, 15 blue, 1 red; 9 red, 6 blue, 10 green
|
||||||
|
Game 65: 7 red, 7 blue; 3 blue, 1 red, 1 green; 3 red, 8 blue
|
||||||
|
Game 66: 1 blue, 3 red; 10 green, 5 blue; 4 green; 3 red, 11 green; 3 blue, 15 green, 3 red
|
||||||
|
Game 67: 1 red; 2 blue, 2 green, 1 red; 6 green, 1 blue
|
||||||
|
Game 68: 7 red, 4 blue; 4 blue, 6 red, 7 green; 2 green, 19 red, 11 blue; 11 green, 9 red
|
||||||
|
Game 69: 4 blue, 3 green, 1 red; 7 blue, 1 red, 3 green; 5 blue, 1 green; 2 blue, 10 green, 2 red; 2 red, 6 green, 5 blue; 1 red, 4 green, 2 blue
|
||||||
|
Game 70: 9 blue, 7 red, 6 green; 19 blue, 4 red, 5 green; 6 blue, 7 red, 4 green; 3 blue, 4 red, 2 green
|
||||||
|
Game 71: 6 green, 12 blue, 4 red; 11 red, 10 green, 11 blue; 3 red, 14 blue, 13 green; 4 blue, 3 green
|
||||||
|
Game 72: 2 green, 1 blue, 9 red; 10 red, 3 green, 1 blue; 11 red, 2 green; 2 green, 1 blue, 5 red; 1 red, 1 blue, 3 green; 13 red, 4 blue, 1 green
|
||||||
|
Game 73: 11 green, 6 blue; 7 green, 6 blue, 7 red; 12 green, 8 blue, 11 red; 4 red, 2 blue, 9 green; 4 green, 7 blue, 2 red
|
||||||
|
Game 74: 3 blue, 7 red; 3 blue, 5 green, 2 red; 5 red, 1 green, 3 blue; 8 green, 2 blue, 11 red; 3 blue, 8 green, 10 red
|
||||||
|
Game 75: 2 green; 5 blue; 1 blue, 1 red; 1 red, 9 blue, 2 green; 2 blue, 2 green
|
||||||
|
Game 76: 12 blue, 13 green; 5 red, 11 blue, 9 green; 12 green, 6 red
|
||||||
|
Game 77: 1 blue, 15 green, 12 red; 15 green, 5 blue; 14 green, 3 blue, 8 red
|
||||||
|
Game 78: 11 green, 8 blue, 1 red; 9 green, 8 blue, 1 red; 13 green, 5 red, 6 blue; 5 red, 7 green, 20 blue; 10 blue, 5 red
|
||||||
|
Game 79: 3 blue; 6 blue, 5 red; 4 red, 1 green, 4 blue; 7 blue, 6 red; 7 red, 1 blue; 1 red, 1 blue, 1 green
|
||||||
|
Game 80: 11 green, 3 red, 8 blue; 2 red, 15 green, 2 blue; 5 green, 8 blue, 2 red; 8 blue, 14 green; 2 blue, 13 green
|
||||||
|
Game 81: 9 red, 4 green; 7 green, 4 red; 2 red, 4 blue, 6 green; 6 red, 4 blue, 9 green; 1 green, 3 red; 6 green, 1 blue, 8 red
|
||||||
|
Game 82: 5 blue, 3 red, 3 green; 5 red; 2 red, 3 green, 8 blue
|
||||||
|
Game 83: 10 green, 1 red, 1 blue; 3 red, 1 green, 1 blue; 4 red, 10 green
|
||||||
|
Game 84: 16 red, 2 green, 6 blue; 6 red, 3 green, 8 blue; 3 green, 10 red, 5 blue; 4 blue, 3 green; 15 red
|
||||||
|
Game 85: 3 green, 2 red; 5 green, 4 blue; 5 green, 8 red, 3 blue
|
||||||
|
Game 86: 7 green, 16 blue, 7 red; 1 green, 12 red, 2 blue; 15 green, 16 blue, 7 red
|
||||||
|
Game 87: 1 red, 6 green, 5 blue; 2 green, 1 blue; 2 green, 1 red, 1 blue; 5 green, 4 blue
|
||||||
|
Game 88: 3 green, 3 red, 4 blue; 1 red, 1 green; 6 blue, 9 red, 1 green; 1 green, 11 red, 3 blue; 7 red, 6 blue
|
||||||
|
Game 89: 2 blue, 3 red, 4 green; 5 red, 7 blue, 14 green; 8 blue, 5 red, 16 green; 2 blue, 5 red, 7 green; 5 green, 9 blue, 1 red
|
||||||
|
Game 90: 1 blue, 3 red, 7 green; 11 green, 4 red, 1 blue; 1 red, 1 blue, 6 green; 2 blue, 2 green; 8 green, 2 blue; 3 red, 2 blue, 4 green
|
||||||
|
Game 91: 6 blue, 4 red, 1 green; 8 red, 3 blue, 3 green; 1 green, 2 blue, 5 red; 1 blue, 3 green
|
||||||
|
Game 92: 8 green, 1 red, 5 blue; 2 green, 7 blue; 11 blue, 5 green, 8 red; 7 blue, 3 red, 4 green
|
||||||
|
Game 93: 3 green, 1 red, 9 blue; 13 red, 5 blue, 8 green; 5 green, 2 red, 7 blue
|
||||||
|
Game 94: 4 green, 10 blue, 8 red; 4 red, 10 blue, 2 green; 2 green, 10 blue, 5 red; 5 green, 2 red, 10 blue
|
||||||
|
Game 95: 5 green, 1 blue; 3 blue, 11 green, 8 red; 8 blue, 2 red, 12 green; 4 green, 4 blue, 4 red
|
||||||
|
Game 96: 1 blue, 13 green; 8 blue, 3 red, 4 green; 1 red, 3 blue, 10 green
|
||||||
|
Game 97: 18 green, 4 red; 1 blue, 2 red, 9 green; 6 red, 3 blue, 10 green; 3 blue, 15 green, 4 red
|
||||||
|
Game 98: 2 blue, 3 green, 6 red; 1 green, 1 blue, 8 red; 8 red, 3 green, 1 blue; 2 blue; 8 red, 2 green, 2 blue
|
||||||
|
Game 99: 1 green, 2 red, 1 blue; 8 green, 4 blue, 1 red; 7 blue, 1 red, 11 green; 9 green, 3 blue; 1 red, 2 blue; 1 red, 6 blue
|
||||||
|
Game 100: 7 blue, 9 green, 2 red; 5 red, 9 green; 1 blue, 8 red, 13 green
|
5
inputs/pb2_sample.txt
Normal file
5
inputs/pb2_sample.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
|
||||||
|
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
|
||||||
|
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
|
||||||
|
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
|
||||||
|
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
|
204
inputs/pb4.txt
Normal file
204
inputs/pb4.txt
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
Card 1: 9 39 27 89 87 29 54 19 43 45 | 9 80 29 20 54 58 78 77 39 35 76 79 19 87 45 89 23 31 94 34 67 43 56 50 27
|
||||||
|
Card 2: 89 59 76 2 60 83 21 37 92 45 | 79 5 41 92 45 59 72 50 89 37 64 65 60 54 57 22 66 21 25 76 1 39 83 2 33
|
||||||
|
Card 3: 40 25 13 65 86 5 35 87 9 30 | 87 76 30 93 5 45 16 40 48 89 78 59 18 12 71 85 66 21 80 28 50 60 49 72 27
|
||||||
|
Card 4: 21 34 70 83 66 44 90 68 76 12 | 46 80 70 73 44 99 32 98 66 68 76 28 85 74 17 38 27 22 83 16 12 90 33 34 21
|
||||||
|
Card 5: 5 67 90 43 26 31 17 47 14 1 | 83 64 47 24 33 5 90 20 19 61 14 56 67 26 1 70 31 9 17 57 43 95 82 91 49
|
||||||
|
Card 6: 8 1 42 80 94 21 15 89 60 73 | 53 23 64 63 15 89 29 93 78 80 62 52 21 40 94 4 42 61 22 1 73 97 28 60 8
|
||||||
|
Card 7: 67 32 20 69 40 22 35 44 86 72 | 84 53 39 52 43 46 41 16 25 77 32 5 7 29 13 31 22 98 58 82 2 85 34 89 79
|
||||||
|
Card 8: 94 12 71 3 2 93 87 18 83 67 | 89 80 82 62 88 64 24 45 54 84 2 7 43 37 16 49 67 13 95 53 50 42 6 83 68
|
||||||
|
Card 9: 64 68 80 83 33 1 93 66 8 73 | 51 61 20 32 39 3 8 65 21 56 6 25 86 85 76 95 14 28 62 71 69 12 83 1 22
|
||||||
|
Card 10: 60 88 52 64 87 34 93 37 56 78 | 16 57 87 20 68 98 93 63 12 96 29 51 14 10 45 52 64 83 85 72 49 82 31 44 35
|
||||||
|
Card 11: 36 78 85 63 79 86 20 6 24 28 | 55 86 79 32 84 97 22 20 25 6 29 75 41 24 38 78 23 33 63 50 56 11 85 36 28
|
||||||
|
Card 12: 51 48 95 84 65 40 54 47 35 24 | 41 91 86 2 5 19 54 83 13 98 39 44 47 33 82 48 6 58 87 88 16 29 99 38 40
|
||||||
|
Card 13: 1 3 96 69 86 76 88 24 58 27 | 19 22 25 3 89 88 71 27 76 85 15 45 96 80 70 24 34 61 83 69 47 86 44 7 1
|
||||||
|
Card 14: 64 16 68 57 10 25 51 26 36 59 | 78 27 81 61 21 57 94 41 85 68 77 4 9 56 66 2 42 15 25 7 10 93 36 59 34
|
||||||
|
Card 15: 41 42 5 37 99 19 65 27 44 35 | 99 38 1 9 72 43 84 67 7 44 79 5 29 60 41 98 30 23 27 82 35 97 74 25 90
|
||||||
|
Card 16: 8 72 53 75 61 67 78 54 1 3 | 32 41 81 86 1 95 50 20 58 92 97 60 26 23 27 67 78 53 83 75 7 66 3 59 8
|
||||||
|
Card 17: 39 50 34 66 54 19 30 37 33 24 | 34 62 27 89 49 80 67 50 20 46 4 72 74 85 45 69 40 16 73 57 79 76 95 41 56
|
||||||
|
Card 18: 67 32 84 12 50 44 5 42 69 22 | 67 64 77 83 5 85 50 84 17 7 23 78 97 76 94 39 81 44 96 37 79 61 13 3 49
|
||||||
|
Card 19: 66 39 62 2 47 63 18 19 85 26 | 60 68 9 18 59 24 47 80 86 87 56 48 54 72 16 51 26 23 95 15 38 91 79 31 27
|
||||||
|
Card 20: 48 8 91 42 64 81 16 90 82 30 | 9 65 92 3 49 68 67 52 53 47 56 54 22 10 15 86 72 88 46 75 73 6 55 80 37
|
||||||
|
Card 21: 89 35 21 61 33 44 52 83 51 79 | 64 62 14 54 72 38 80 18 67 65 56 91 94 26 92 96 88 34 81 60 25 9 28 10 55
|
||||||
|
Card 22: 98 19 57 87 65 12 80 18 48 29 | 70 56 81 95 51 48 76 68 73 21 26 67 92 46 54 58 72 45 75 34 25 8 79 55 86
|
||||||
|
Card 23: 50 94 84 86 64 67 26 72 46 96 | 11 98 97 74 47 71 88 93 3 89 2 53 57 54 66 85 52 14 31 38 24 81 44 41 68
|
||||||
|
Card 24: 53 60 37 93 49 98 89 70 72 6 | 83 21 37 94 78 7 44 34 30 58 16 84 8 10 72 48 42 27 79 6 99 67 88 64 25
|
||||||
|
Card 25: 13 18 29 62 44 92 19 58 63 6 | 97 78 16 56 19 62 18 58 63 29 14 44 40 25 70 90 13 82 98 89 51 24 92 55 83
|
||||||
|
Card 26: 75 2 35 21 74 27 45 66 3 91 | 11 8 28 74 26 23 93 2 47 3 25 7 35 6 22 27 58 96 21 75 61 15 94 65 45
|
||||||
|
Card 27: 11 35 97 64 30 50 5 90 2 19 | 7 92 18 68 95 22 86 65 91 1 6 80 66 93 27 77 90 40 45 48 89 38 32 26 78
|
||||||
|
Card 28: 89 67 61 81 98 64 49 54 70 79 | 78 81 66 70 30 49 79 10 59 67 98 61 99 43 1 77 50 90 64 89 75 85 16 71 54
|
||||||
|
Card 29: 4 94 51 84 70 21 76 55 35 66 | 68 52 61 75 50 37 71 72 14 78 19 18 93 20 79 60 86 2 59 8 47 1 90 33 30
|
||||||
|
Card 30: 84 90 5 67 66 27 3 89 41 63 | 65 66 63 32 5 97 68 13 95 12 39 27 67 25 89 90 3 1 75 40 41 19 51 9 71
|
||||||
|
Card 31: 99 88 64 27 71 97 30 47 32 11 | 73 8 7 61 45 29 62 74 49 11 80 14 75 68 63 43 4 40 72 84 82 44 96 69 87
|
||||||
|
Card 32: 49 22 35 33 44 77 24 18 74 10 | 79 68 81 31 88 33 10 74 49 30 44 35 22 23 42 73 77 55 67 13 61 25 24 53 18
|
||||||
|
Card 33: 11 54 66 33 51 59 82 24 3 88 | 70 28 24 89 66 42 22 59 88 33 99 54 31 63 47 11 98 39 3 51 82 38 87 16 68
|
||||||
|
Card 34: 26 7 38 74 20 89 78 79 73 47 | 88 64 13 18 99 9 37 61 60 97 22 67 48 95 19 76 40 31 6 90 42 2 41 1 68
|
||||||
|
Card 35: 67 65 8 4 84 62 69 66 46 36 | 27 30 2 16 45 99 65 50 37 19 78 87 49 64 12 84 11 8 4 69 44 62 48 71 17
|
||||||
|
Card 36: 80 77 50 31 90 59 75 74 37 24 | 34 64 37 90 97 75 63 50 3 95 55 94 77 52 80 24 19 32 84 59 60 72 74 8 31
|
||||||
|
Card 37: 6 60 75 78 10 71 32 91 77 97 | 60 88 71 81 74 78 32 97 1 48 91 53 4 89 13 21 67 90 56 44 77 18 46 76 61
|
||||||
|
Card 38: 48 51 53 36 99 73 3 39 70 5 | 42 25 54 98 50 68 73 77 47 33 49 99 57 70 48 5 78 22 7 39 51 2 3 36 44
|
||||||
|
Card 39: 26 4 65 75 52 54 88 37 50 49 | 23 62 60 58 90 57 33 80 29 9 86 34 56 53 42 84 12 18 24 98 72 54 50 51 45
|
||||||
|
Card 40: 48 99 71 68 21 56 90 34 28 18 | 4 34 61 62 48 98 28 65 18 90 77 88 47 68 55 92 99 70 78 14 36 93 84 21 27
|
||||||
|
Card 41: 73 27 13 41 98 47 85 33 59 84 | 15 47 50 75 40 69 12 92 14 21 68 97 87 45 56 37 84 74 3 88 35 36 24 46 54
|
||||||
|
Card 42: 99 58 27 10 18 29 4 91 93 81 | 94 15 73 50 36 49 62 68 57 5 75 42 37 41 79 60 25 86 67 35 45 70 72 34 46
|
||||||
|
Card 43: 26 17 11 50 37 5 47 67 28 31 | 12 44 81 84 48 96 97 90 21 6 10 35 77 20 4 62 76 99 64 19 18 55 43 17 30
|
||||||
|
Card 44: 14 25 88 84 83 58 54 11 80 93 | 50 20 68 16 65 59 41 26 7 13 33 18 60 72 74 55 28 2 66 42 98 78 27 63 40
|
||||||
|
Card 45: 11 24 20 22 78 26 91 54 16 29 | 32 70 83 77 22 63 89 58 68 42 2 87 50 1 95 99 98 55 80 38 76 90 93 54 31
|
||||||
|
Card 46: 35 46 37 90 8 36 12 63 97 89 | 45 18 47 92 9 11 2 79 89 61 88 77 23 33 44 28 36 22 50 52 94 15 84 38 57
|
||||||
|
Card 47: 27 16 35 8 99 21 45 89 64 23 | 42 53 11 57 9 13 75 66 62 88 36 30 49 95 59 7 63 71 34 43 92 55 29 61 52
|
||||||
|
Card 48: 10 1 11 53 97 64 24 49 52 65 | 3 28 40 92 81 58 5 35 46 33 82 77 59 78 87 85 71 61 8 70 74 18 84 56 19
|
||||||
|
Card 49: 37 40 57 47 53 77 25 94 13 58 | 15 76 56 22 35 10 12 77 72 25 27 51 88 3 13 30 26 48 63 19 84 95 34 97 7
|
||||||
|
Card 50: 64 47 51 46 54 93 94 3 53 52 | 48 61 31 96 67 88 68 7 98 87 23 37 77 73 65 83 2 4 27 76 45 97 58 1 75
|
||||||
|
Card 51: 50 84 17 72 35 66 31 40 73 53 | 84 61 74 26 33 38 75 43 53 44 39 79 50 49 65 99 62 85 46 83 21 2 29 36 10
|
||||||
|
Card 52: 9 81 53 22 58 92 90 33 30 59 | 45 12 33 83 59 96 11 65 9 52 32 30 58 77 98 19 22 84 99 92 14 76 90 49 71
|
||||||
|
Card 53: 69 13 67 60 89 50 26 68 29 55 | 29 82 86 36 50 76 69 64 60 61 6 26 42 99 89 98 96 55 68 33 45 10 79 13 67
|
||||||
|
Card 54: 49 15 51 41 75 25 42 47 50 70 | 55 44 57 41 74 25 70 26 82 85 87 67 63 34 69 75 51 49 37 28 95 59 96 83 14
|
||||||
|
Card 55: 74 2 69 5 95 93 90 47 75 14 | 51 28 82 32 49 95 15 61 33 9 58 56 68 64 46 21 99 98 38 44 7 39 36 29 86
|
||||||
|
Card 56: 68 18 77 6 53 43 91 3 57 23 | 52 47 40 96 2 8 59 28 39 74 36 72 32 89 70 92 73 46 85 43 84 5 67 38 77
|
||||||
|
Card 57: 42 9 71 63 30 16 70 77 29 54 | 39 27 24 66 76 72 93 83 47 50 37 67 52 90 11 18 19 56 99 84 41 74 59 32 48
|
||||||
|
Card 58: 28 38 63 96 31 30 18 6 82 9 | 82 9 20 91 43 60 46 52 78 67 96 28 39 92 89 8 57 31 87 84 10 75 37 23 88
|
||||||
|
Card 59: 93 89 66 99 10 9 92 65 50 12 | 48 28 46 58 38 65 2 30 8 35 6 95 97 98 10 5 44 78 37 68 32 71 72 29 83
|
||||||
|
Card 60: 43 46 57 73 75 24 56 39 23 81 | 22 57 51 96 60 44 34 94 88 10 84 67 32 7 97 68 78 56 21 95 55 59 8 92 76
|
||||||
|
Card 61: 63 66 83 81 76 40 47 97 22 26 | 28 87 16 64 12 85 89 2 45 13 39 21 31 18 24 20 96 32 3 54 56 34 52 92 5
|
||||||
|
Card 62: 71 63 44 3 88 24 79 70 82 53 | 30 96 68 25 92 39 86 75 21 98 93 17 62 28 35 8 54 12 36 7 33 91 13 85 40
|
||||||
|
Card 63: 20 89 99 39 61 91 44 45 3 38 | 26 68 88 63 69 84 16 55 60 19 50 14 2 41 6 30 98 29 65 43 4 7 67 80 37
|
||||||
|
Card 64: 70 64 27 51 11 81 8 56 2 19 | 19 27 49 80 66 86 20 39 70 73 98 2 10 81 64 33 47 88 51 11 37 8 40 56 74
|
||||||
|
Card 65: 61 1 79 74 23 88 29 52 58 31 | 11 17 89 60 98 15 12 75 52 85 93 41 88 30 2 18 79 92 40 26 29 73 94 70 34
|
||||||
|
Card 66: 91 8 53 34 43 38 89 99 79 27 | 15 67 34 70 97 74 9 11 73 49 14 54 50 47 71 91 23 18 84 65 35 5 63 46 66
|
||||||
|
Card 67: 61 42 21 34 57 12 74 52 72 88 | 61 5 72 24 16 95 2 38 42 94 21 18 12 37 57 66 34 48 88 69 52 47 74 62 96
|
||||||
|
Card 68: 78 46 10 30 2 47 92 16 64 72 | 72 65 30 17 84 88 16 41 92 45 46 11 51 2 10 81 55 47 3 18 36 97 60 12 78
|
||||||
|
Card 69: 14 91 68 42 6 4 50 98 89 90 | 6 28 76 83 68 7 88 53 27 16 98 74 5 63 48 89 40 30 50 4 85 91 92 64 20
|
||||||
|
Card 70: 86 64 33 35 36 24 67 39 77 6 | 81 74 59 25 98 48 69 80 16 47 13 8 84 50 37 2 54 51 27 15 31 26 93 45 9
|
||||||
|
Card 71: 18 12 95 25 85 56 99 13 82 77 | 88 26 44 77 73 43 14 37 35 13 21 15 45 99 86 97 54 98 38 27 42 53 93 95 83
|
||||||
|
Card 72: 7 96 8 50 63 39 46 82 43 44 | 89 2 42 65 78 7 16 73 43 72 39 1 25 58 64 50 67 46 23 87 18 82 30 24 95
|
||||||
|
Card 73: 77 97 99 54 49 48 58 24 6 73 | 68 10 89 53 50 22 14 28 83 59 18 25 2 8 92 76 70 75 85 74 4 7 3 36 72
|
||||||
|
Card 74: 24 96 56 90 46 21 1 62 94 29 | 16 78 21 97 39 4 79 65 22 24 67 69 6 86 82 5 91 51 1 87 60 32 13 77 42
|
||||||
|
Card 75: 95 26 80 37 34 43 46 62 60 24 | 54 16 68 3 55 29 18 53 79 90 14 45 41 67 21 78 8 64 72 66 40 82 73 47 94
|
||||||
|
Card 76: 8 72 87 55 75 36 86 70 45 52 | 28 76 19 5 71 17 92 64 42 80 70 91 43 29 74 47 94 21 66 35 56 88 51 63 78
|
||||||
|
Card 77: 5 62 3 77 9 54 29 12 68 86 | 58 64 7 90 65 78 36 4 29 17 13 87 40 20 83 91 41 96 39 94 80 69 84 42 74
|
||||||
|
Card 78: 4 31 22 18 53 97 42 21 72 57 | 77 1 6 45 17 52 33 15 34 5 84 29 2 23 75 50 27 39 38 70 98 89 19 69 80
|
||||||
|
Card 79: 28 64 2 71 89 44 76 34 55 67 | 28 97 44 64 48 40 76 2 66 56 15 11 92 83 34 53 71 67 89 54 41 43 60 10 55
|
||||||
|
Card 80: 97 58 41 88 57 26 14 71 83 2 | 26 73 57 55 8 97 54 58 63 90 37 98 60 66 41 2 25 87 83 95 71 46 31 14 88
|
||||||
|
Card 81: 76 20 17 38 58 30 87 96 28 12 | 40 47 52 37 48 17 35 8 77 45 21 46 80 69 57 94 50 12 55 81 70 58 25 4 28
|
||||||
|
Card 82: 50 56 9 28 78 8 6 5 45 96 | 83 64 89 39 68 29 99 81 8 45 96 53 20 62 78 9 31 23 34 46 93 50 28 71 56
|
||||||
|
Card 83: 16 9 29 27 89 35 97 6 63 48 | 29 49 6 89 44 42 63 76 21 16 27 97 37 46 31 36 23 66 35 1 33 79 9 48 45
|
||||||
|
Card 84: 24 84 32 55 59 57 70 6 43 38 | 23 26 20 69 83 6 68 47 57 27 75 28 1 56 43 48 95 98 24 51 94 88 19 45 5
|
||||||
|
Card 85: 43 56 46 52 92 64 89 39 8 7 | 25 46 37 70 52 8 68 36 85 66 43 65 10 38 56 49 15 64 12 34 79 39 98 13 90
|
||||||
|
Card 86: 59 43 34 99 39 4 90 66 33 35 | 59 98 81 4 86 95 66 92 22 35 28 80 5 90 21 11 19 33 71 15 57 68 99 75 30
|
||||||
|
Card 87: 3 73 93 21 35 97 61 84 47 58 | 11 57 63 54 73 65 67 47 9 43 31 3 68 82 58 97 35 25 84 13 24 61 21 8 93
|
||||||
|
Card 88: 99 34 88 58 37 54 50 49 53 87 | 88 61 50 75 3 33 57 37 53 54 87 8 99 34 89 74 46 44 91 72 77 49 22 96 58
|
||||||
|
Card 89: 45 94 20 23 83 82 3 39 90 48 | 47 87 80 65 49 29 63 24 1 59 3 73 25 69 32 12 9 15 33 35 82 22 46 48 43
|
||||||
|
Card 90: 11 69 91 38 51 79 15 16 22 26 | 39 80 17 24 1 21 70 82 73 84 87 46 97 94 72 68 89 66 14 65 4 64 88 10 58
|
||||||
|
Card 91: 11 27 2 95 84 13 48 24 89 54 | 6 68 56 98 70 38 95 79 89 83 39 48 17 99 57 51 67 7 28 23 13 50 2 32 93
|
||||||
|
Card 92: 26 1 2 20 16 94 13 60 11 6 | 19 99 92 58 40 82 27 74 32 59 57 86 4 53 73 98 69 48 72 65 62 61 89 56 42
|
||||||
|
Card 93: 69 7 80 87 66 64 89 75 79 53 | 54 9 93 88 36 44 45 63 68 78 22 62 82 70 73 3 98 34 1 52 28 56 55 81 67
|
||||||
|
Card 94: 55 89 2 72 16 12 63 71 41 43 | 83 60 74 68 98 18 73 75 20 87 49 94 32 22 25 6 90 31 9 95 71 11 42 88 5
|
||||||
|
Card 95: 41 72 14 56 75 35 8 3 12 78 | 20 77 80 96 61 86 35 17 95 70 41 6 54 1 79 31 11 38 39 40 4 44 64 63 49
|
||||||
|
Card 96: 18 55 72 59 30 10 58 43 66 57 | 33 46 25 71 30 9 78 88 83 95 11 75 6 20 76 15 74 92 35 61 45 87 99 94 41
|
||||||
|
Card 97: 3 73 83 39 40 63 7 94 35 2 | 64 6 26 28 36 59 98 95 21 93 18 69 42 12 55 79 15 11 70 32 60 61 87 78 4
|
||||||
|
Card 98: 11 99 6 13 40 26 94 46 58 88 | 63 2 5 17 9 72 79 31 37 59 28 95 39 62 97 4 55 83 12 76 68 33 65 10 89
|
||||||
|
Card 99: 31 83 81 22 34 12 55 92 58 29 | 68 66 74 50 91 85 33 81 87 86 98 84 96 48 6 90 70 62 1 38 59 76 16 41 25
|
||||||
|
Card 100: 64 11 22 20 53 7 10 75 9 21 | 35 78 92 88 74 51 91 84 96 25 34 83 46 4 54 81 43 87 47 44 23 59 33 73 67
|
||||||
|
Card 101: 37 87 86 41 1 91 81 29 14 72 | 6 72 1 86 44 87 41 88 3 21 29 97 89 95 64 56 20 91 99 16 14 81 37 13 71
|
||||||
|
Card 102: 4 36 32 61 26 12 85 42 60 77 | 14 40 92 7 66 89 52 54 19 6 49 35 67 46 80 27 30 56 97 83 47 82 87 78 5
|
||||||
|
Card 103: 99 3 67 24 61 34 80 43 54 68 | 34 32 54 67 80 22 24 5 82 30 36 3 69 85 61 68 21 10 99 98 52 42 53 43 26
|
||||||
|
Card 104: 7 9 77 84 53 5 81 32 13 3 | 78 84 94 20 8 56 38 82 76 41 91 90 99 74 25 70 45 32 97 77 67 3 5 13 63
|
||||||
|
Card 105: 85 77 48 14 98 3 67 89 57 43 | 56 21 26 11 81 15 46 68 36 72 50 40 31 37 23 92 24 25 99 35 29 4 12 10 45
|
||||||
|
Card 106: 30 25 66 4 40 43 99 21 89 68 | 32 6 66 25 64 58 78 30 23 35 12 21 4 99 43 89 83 20 61 71 68 16 40 84 45
|
||||||
|
Card 107: 5 74 89 62 52 80 43 42 13 40 | 36 25 84 13 73 56 57 62 46 54 18 89 26 66 28 72 11 61 35 42 14 3 67 39 2
|
||||||
|
Card 108: 79 34 81 43 98 33 24 7 22 13 | 34 98 94 93 81 84 63 17 79 44 13 26 15 18 43 6 22 91 56 33 74 7 24 30 58
|
||||||
|
Card 109: 3 50 79 55 5 30 41 20 52 91 | 33 41 19 50 86 75 91 24 60 1 30 64 52 77 95 58 22 5 70 73 3 59 20 79 55
|
||||||
|
Card 110: 49 42 83 46 84 87 64 89 95 1 | 96 64 97 1 27 79 83 42 21 25 72 59 4 89 23 45 46 71 84 87 49 52 81 95 56
|
||||||
|
Card 111: 64 62 66 74 1 73 8 29 31 19 | 13 62 64 31 78 73 1 41 19 8 80 29 39 70 77 84 40 15 66 68 56 46 94 74 48
|
||||||
|
Card 112: 55 74 88 67 3 58 87 16 97 60 | 36 17 78 66 19 85 59 28 37 24 90 7 97 95 71 27 54 87 77 44 91 64 80 31 46
|
||||||
|
Card 113: 45 76 46 7 60 24 27 21 95 87 | 67 93 12 81 24 72 83 7 60 95 75 2 47 90 46 33 1 70 21 42 16 63 27 45 76
|
||||||
|
Card 114: 71 8 4 96 98 62 69 65 5 46 | 25 43 37 45 34 39 95 24 22 68 32 88 72 73 36 89 54 8 56 35 6 51 81 85 60
|
||||||
|
Card 115: 62 69 28 91 24 53 51 89 99 95 | 74 94 86 36 27 67 69 6 76 35 16 10 18 24 12 28 4 44 15 65 80 14 51 54 88
|
||||||
|
Card 116: 52 94 9 1 51 90 36 3 81 2 | 4 88 90 15 32 35 18 86 89 45 97 5 81 69 1 22 10 57 61 3 42 37 9 93 46
|
||||||
|
Card 117: 63 77 23 81 78 83 92 48 85 25 | 73 31 12 8 34 42 21 29 26 14 75 69 37 16 11 72 41 60 7 80 3 19 95 98 89
|
||||||
|
Card 118: 86 93 55 54 20 66 88 63 94 64 | 23 33 43 35 1 91 48 82 41 55 66 32 52 96 50 54 38 47 70 84 3 11 12 86 58
|
||||||
|
Card 119: 80 69 3 77 33 30 31 99 76 44 | 55 47 57 89 22 26 37 34 23 96 86 94 79 2 38 8 68 4 91 25 97 48 52 43 98
|
||||||
|
Card 120: 9 78 59 93 74 70 66 26 61 11 | 29 95 24 96 97 77 23 42 80 53 86 51 31 92 8 55 32 43 10 56 84 72 28 6 7
|
||||||
|
Card 121: 7 51 68 86 42 96 88 39 94 75 | 22 4 46 5 20 78 94 89 31 92 85 37 41 27 97 32 21 42 2 83 49 79 17 52 69
|
||||||
|
Card 122: 71 79 63 55 2 28 36 45 29 17 | 91 34 88 83 99 92 26 9 70 64 81 98 12 35 74 47 80 82 87 23 2 90 72 52 97
|
||||||
|
Card 123: 31 54 44 21 47 64 62 65 92 10 | 98 32 71 97 66 46 99 20 3 72 76 75 40 81 30 43 61 4 82 87 7 37 36 27 91
|
||||||
|
Card 124: 14 49 77 61 15 41 27 57 29 38 | 23 38 49 41 15 27 16 90 14 50 28 29 94 91 19 2 43 98 66 57 77 71 99 74 61
|
||||||
|
Card 125: 64 46 99 34 80 85 68 73 48 10 | 43 85 98 46 37 5 34 81 49 63 9 50 30 44 64 68 10 73 66 99 97 96 52 48 80
|
||||||
|
Card 126: 89 74 85 14 66 45 55 21 86 18 | 96 13 15 18 76 39 55 27 75 87 45 74 32 49 64 21 66 86 14 89 85 77 92 82 59
|
||||||
|
Card 127: 87 31 54 37 78 58 14 36 96 71 | 10 40 77 36 41 71 84 78 32 18 8 37 87 22 58 16 26 55 43 54 25 14 96 31 38
|
||||||
|
Card 128: 62 43 69 74 5 40 3 89 59 22 | 77 52 88 59 69 74 32 96 43 40 86 16 85 62 5 70 80 89 1 2 94 22 31 18 3
|
||||||
|
Card 129: 88 10 75 71 22 8 34 15 49 61 | 59 98 85 25 88 15 10 57 8 34 74 94 4 41 72 90 71 73 75 1 9 49 61 22 95
|
||||||
|
Card 130: 46 51 4 25 45 50 47 57 35 23 | 50 63 74 10 46 4 17 35 2 11 87 26 99 84 92 65 45 57 85 51 25 47 54 23 62
|
||||||
|
Card 131: 13 73 45 63 15 43 19 11 52 55 | 38 79 21 52 91 53 69 96 13 9 48 58 43 44 46 39 32 85 31 63 73 1 15 82 37
|
||||||
|
Card 132: 89 53 76 33 18 42 23 27 43 80 | 20 53 74 86 76 27 36 75 43 93 88 65 54 68 45 29 64 3 80 37 66 69 87 90 39
|
||||||
|
Card 133: 76 92 70 84 90 5 64 26 16 41 | 97 54 56 79 31 26 82 41 58 76 68 77 13 15 90 50 29 69 60 64 10 84 87 14 67
|
||||||
|
Card 134: 9 21 86 14 37 61 69 98 88 31 | 98 58 18 65 35 6 15 33 43 54 8 82 19 87 76 78 38 20 62 86 21 57 11 3 75
|
||||||
|
Card 135: 50 10 16 57 63 24 32 29 56 88 | 16 1 98 10 45 51 50 69 47 49 21 43 29 87 85 5 73 32 24 37 57 26 61 3 7
|
||||||
|
Card 136: 77 16 62 61 73 52 3 25 6 69 | 13 70 77 94 28 17 45 67 25 22 29 10 72 16 65 73 85 79 62 90 1 6 56 74 49
|
||||||
|
Card 137: 94 91 68 5 36 88 26 37 3 15 | 68 3 7 6 20 26 99 39 44 78 88 40 53 27 1 50 36 15 79 67 37 2 5 91 84
|
||||||
|
Card 138: 98 63 62 27 71 65 88 81 55 49 | 97 96 25 88 23 92 85 49 30 76 98 40 45 67 61 24 66 91 27 37 84 18 5 75 55
|
||||||
|
Card 139: 44 27 57 99 24 80 66 34 71 12 | 60 96 78 25 15 86 74 98 7 27 62 29 80 82 65 47 32 95 99 66 92 63 2 24 37
|
||||||
|
Card 140: 73 69 45 14 70 80 2 33 71 95 | 96 59 56 63 98 32 74 97 3 78 91 99 19 39 81 2 10 25 72 65 55 87 24 48 4
|
||||||
|
Card 141: 72 35 1 53 12 78 32 61 68 87 | 93 35 29 64 82 76 37 36 4 40 53 42 63 85 87 31 1 6 32 81 55 94 11 26 10
|
||||||
|
Card 142: 39 65 95 25 34 46 73 4 23 99 | 33 78 22 6 55 67 17 35 7 94 53 64 13 69 11 75 83 82 40 23 58 61 85 10 46
|
||||||
|
Card 143: 46 15 60 76 32 10 83 47 22 1 | 23 6 51 85 12 90 35 39 21 7 53 57 27 96 80 78 70 79 25 26 56 62 17 73 41
|
||||||
|
Card 144: 28 76 1 63 66 95 81 36 94 10 | 86 59 21 46 65 66 64 38 84 14 56 52 74 33 88 13 9 39 16 32 12 29 83 85 47
|
||||||
|
Card 145: 12 77 54 56 67 90 37 76 32 46 | 12 49 58 45 19 36 98 40 77 16 17 68 73 44 30 24 2 75 35 86 65 70 50 10 47
|
||||||
|
Card 146: 63 35 23 56 96 37 14 24 18 52 | 81 1 53 86 37 68 11 10 83 78 32 2 50 3 71 15 19 17 25 29 67 8 45 61 22
|
||||||
|
Card 147: 55 94 5 53 92 87 63 56 2 23 | 34 13 93 42 1 11 31 51 41 24 95 72 57 35 9 61 90 43 75 67 10 97 7 46 89
|
||||||
|
Card 148: 80 10 79 30 5 37 25 73 81 91 | 81 79 52 72 56 69 26 24 63 65 12 25 37 71 80 32 4 38 77 5 2 10 73 43 91
|
||||||
|
Card 149: 53 46 42 20 89 16 11 60 57 2 | 68 20 53 6 2 16 61 11 54 70 91 3 8 82 57 93 79 60 92 73 89 76 56 14 78
|
||||||
|
Card 150: 87 33 53 21 26 77 28 49 51 17 | 48 6 65 61 72 77 16 94 12 57 79 75 87 34 63 52 8 88 28 85 33 41 29 31 35
|
||||||
|
Card 151: 42 82 89 14 16 28 7 77 23 54 | 89 71 14 6 15 16 82 33 28 4 78 80 54 77 53 8 7 42 50 30 23 58 76 34 74
|
||||||
|
Card 152: 89 87 91 5 37 80 81 82 70 11 | 92 50 54 78 19 71 12 45 73 82 72 18 28 62 21 1 79 35 84 56 17 95 98 76 69
|
||||||
|
Card 153: 50 2 27 20 92 34 10 63 75 89 | 75 52 5 63 50 69 89 51 2 86 10 57 28 74 34 95 92 27 84 77 46 85 4 93 20
|
||||||
|
Card 154: 52 86 12 69 88 43 2 89 66 7 | 25 2 88 39 6 42 69 17 86 97 18 26 16 43 22 51 89 32 34 66 98 46 28 21 47
|
||||||
|
Card 155: 20 53 2 15 95 77 19 4 73 96 | 32 70 75 54 4 26 76 83 30 7 44 97 39 96 25 46 15 10 67 95 77 41 35 53 71
|
||||||
|
Card 156: 91 16 30 70 87 84 19 55 21 92 | 17 41 78 7 67 50 51 34 93 59 80 47 92 32 62 82 31 24 90 97 46 5 43 40 4
|
||||||
|
Card 157: 69 16 12 19 28 89 35 43 91 11 | 68 97 45 52 38 18 20 9 34 67 6 35 28 1 94 23 25 19 73 89 76 95 21 12 57
|
||||||
|
Card 158: 54 21 50 62 96 94 43 86 30 33 | 91 57 7 11 92 20 12 89 58 36 56 6 42 71 64 47 32 88 29 67 63 97 55 98 48
|
||||||
|
Card 159: 12 90 89 88 46 40 83 27 7 95 | 65 98 71 26 21 78 42 18 91 1 82 5 86 2 53 72 41 85 73 16 35 14 52 11 74
|
||||||
|
Card 160: 92 89 2 29 25 53 65 30 38 71 | 11 53 6 63 15 50 41 37 27 96 73 57 64 85 59 1 22 49 25 52 29 80 72 58 28
|
||||||
|
Card 161: 36 66 57 82 10 1 28 25 56 83 | 23 58 38 35 97 66 55 14 85 79 54 77 93 62 67 4 11 99 94 90 32 22 12 36 63
|
||||||
|
Card 162: 61 19 76 17 81 18 87 44 45 74 | 37 15 31 67 24 4 77 81 63 68 27 94 3 62 12 90 69 2 8 34 60 53 97 43 73
|
||||||
|
Card 163: 61 97 73 13 88 93 19 75 47 89 | 68 79 15 25 59 16 78 5 40 69 92 20 4 58 22 30 67 21 76 44 81 98 65 74 46
|
||||||
|
Card 164: 3 45 59 47 12 65 8 57 98 53 | 77 96 12 8 22 63 59 88 61 43 66 39 90 45 55 47 10 73 53 34 25 3 6 99 38
|
||||||
|
Card 165: 79 54 12 6 67 92 99 15 41 72 | 37 77 1 51 55 49 92 21 71 76 5 69 74 45 23 44 83 56 66 94 96 86 79 12 97
|
||||||
|
Card 166: 33 18 55 57 68 79 35 40 17 53 | 93 26 55 97 80 84 44 21 15 75 11 79 83 9 50 35 78 43 39 18 17 53 42 68 86
|
||||||
|
Card 167: 80 75 74 26 44 41 42 88 83 12 | 26 88 53 44 97 42 75 25 16 61 1 81 58 41 98 11 93 74 91 94 90 73 83 36 46
|
||||||
|
Card 168: 59 19 45 25 64 75 70 90 84 80 | 54 19 70 89 13 92 76 26 56 80 86 64 40 8 36 25 90 59 85 47 82 45 43 75 84
|
||||||
|
Card 169: 69 95 88 94 67 36 57 79 11 56 | 53 79 94 69 56 36 57 54 73 26 86 88 10 62 12 95 39 11 28 77 98 14 83 1 67
|
||||||
|
Card 170: 64 24 9 85 57 16 91 77 29 28 | 54 43 4 16 79 6 57 47 61 13 12 91 63 77 9 29 33 64 10 98 86 28 24 85 31
|
||||||
|
Card 171: 65 54 4 35 68 81 7 47 87 92 | 50 33 42 29 81 21 1 40 93 19 95 86 28 32 16 85 58 80 4 30 79 60 71 34 27
|
||||||
|
Card 172: 26 49 46 88 71 32 58 12 42 54 | 54 26 58 10 85 12 32 88 49 70 80 68 75 42 28 61 40 79 46 3 95 45 71 11 98
|
||||||
|
Card 173: 76 39 1 91 73 44 41 66 33 96 | 47 85 53 56 88 84 23 41 68 22 71 75 66 34 72 59 45 81 38 6 70 65 40 63 11
|
||||||
|
Card 174: 1 75 14 32 81 27 38 71 45 49 | 64 52 21 1 83 22 45 84 49 53 33 27 88 70 42 43 8 14 17 75 32 38 2 81 99
|
||||||
|
Card 175: 58 22 39 11 42 60 65 46 80 27 | 10 96 22 86 60 23 47 58 17 93 5 11 90 46 39 94 77 66 67 85 33 25 80 65 82
|
||||||
|
Card 176: 22 70 83 88 99 34 38 77 71 51 | 19 96 83 4 70 94 38 64 36 99 49 71 7 15 51 68 77 95 34 6 2 88 21 59 12
|
||||||
|
Card 177: 46 6 50 30 40 75 8 72 95 56 | 86 93 49 95 87 19 80 90 78 56 76 16 92 18 27 37 94 70 59 43 1 72 44 40 81
|
||||||
|
Card 178: 81 79 65 34 71 66 4 53 85 39 | 23 50 10 59 56 60 27 24 5 70 52 67 41 30 99 75 3 37 17 62 12 22 19 93 73
|
||||||
|
Card 179: 80 74 16 31 33 81 55 85 29 53 | 47 53 79 77 2 8 10 41 27 94 28 96 69 63 22 43 90 50 99 86 34 14 5 80 84
|
||||||
|
Card 180: 24 47 72 12 42 34 76 14 15 41 | 18 11 94 82 59 12 15 29 30 9 35 61 87 7 64 95 43 37 6 26 98 78 33 48 92
|
||||||
|
Card 181: 75 31 15 54 44 21 32 8 22 72 | 87 4 24 71 38 32 14 54 44 64 67 55 7 20 74 21 93 6 76 61 91 97 18 17 52
|
||||||
|
Card 182: 17 53 25 76 48 60 80 56 39 50 | 23 5 61 46 97 72 62 55 6 66 9 87 51 7 68 79 92 65 47 26 58 18 36 90 93
|
||||||
|
Card 183: 70 41 69 74 39 43 33 7 79 48 | 51 87 28 93 15 66 58 96 44 29 26 38 94 95 80 71 2 61 32 16 47 77 90 72 3
|
||||||
|
Card 184: 27 69 74 77 85 59 62 87 31 54 | 22 57 12 18 49 26 50 4 84 28 5 67 34 16 86 9 13 42 41 76 77 37 46 98 64
|
||||||
|
Card 185: 33 1 29 47 81 36 87 93 8 99 | 95 57 34 40 35 15 66 51 3 75 53 43 11 25 80 90 48 60 89 70 85 94 14 17 78
|
||||||
|
Card 186: 93 98 37 44 96 61 56 99 52 60 | 87 89 22 61 96 50 93 56 41 30 98 42 60 52 44 37 75 28 99 65 57 88 91 86 20
|
||||||
|
Card 187: 19 84 39 68 48 5 65 93 4 71 | 1 66 81 63 25 28 75 54 86 61 38 37 17 27 32 45 12 31 33 97 34 87 58 24 3
|
||||||
|
Card 188: 58 83 80 19 52 78 43 97 87 44 | 88 73 43 97 84 55 35 9 87 65 16 93 52 40 58 80 44 41 53 19 32 83 26 78 6
|
||||||
|
Card 189: 82 2 67 87 5 55 43 40 66 80 | 88 8 3 92 78 79 65 54 2 80 66 82 75 41 55 5 40 32 25 94 98 64 99 43 76
|
||||||
|
Card 190: 12 61 25 96 98 33 70 86 5 36 | 68 29 33 71 95 72 90 46 63 77 53 88 76 22 61 73 99 75 87 20 16 47 13 89 66
|
||||||
|
Card 191: 3 21 23 71 56 65 50 75 45 15 | 81 44 25 39 83 75 60 15 71 59 2 37 86 45 47 65 55 88 91 77 54 42 76 16 21
|
||||||
|
Card 192: 61 46 82 28 59 17 8 94 36 53 | 94 59 61 20 5 23 10 66 17 64 46 68 49 28 90 79 36 53 19 81 8 55 82 89 18
|
||||||
|
Card 193: 70 22 45 35 51 12 90 29 83 61 | 70 78 11 22 4 96 66 85 51 90 69 45 29 35 23 36 61 21 27 42 91 12 72 83 5
|
||||||
|
Card 194: 33 56 96 67 75 44 71 20 24 98 | 20 80 24 26 33 8 44 4 96 23 65 57 29 98 50 61 59 55 77 28 86 71 75 67 56
|
||||||
|
Card 195: 9 1 79 39 24 95 91 4 45 93 | 39 91 18 35 96 45 58 92 7 79 9 98 67 95 30 60 10 62 54 26 25 1 93 99 50
|
||||||
|
Card 196: 43 53 38 7 78 41 57 98 89 83 | 46 38 94 81 3 56 16 41 87 68 52 95 77 92 88 72 36 17 80 58 43 97 27 99 7
|
||||||
|
Card 197: 73 49 37 31 85 45 78 46 48 97 | 73 36 82 30 3 84 15 69 45 53 37 29 85 96 91 61 78 70 71 34 62 79 22 57 64
|
||||||
|
Card 198: 52 67 30 11 88 68 96 84 48 89 | 38 66 64 88 95 27 62 46 3 16 20 48 76 97 91 74 70 73 17 75 52 30 21 58 77
|
||||||
|
Card 199: 30 15 96 2 41 56 50 81 29 60 | 42 56 5 50 40 1 6 77 61 73 60 74 79 8 53 3 75 80 36 64 89 43 81 70 90
|
||||||
|
Card 200: 86 29 15 97 91 10 62 68 19 75 | 8 12 68 18 36 62 37 16 41 97 5 64 81 80 75 6 24 59 23 33 79 1 22 63 89
|
||||||
|
Card 201: 16 72 24 22 23 44 67 3 27 85 | 54 78 25 59 87 6 98 81 49 77 83 33 82 99 90 32 65 57 30 36 28 95 92 17 71
|
||||||
|
Card 202: 69 11 38 33 26 39 84 57 98 36 | 46 35 45 80 94 26 52 92 76 90 55 31 18 73 30 15 7 39 4 34 19 47 21 29 54
|
||||||
|
Card 203: 62 87 19 82 3 28 64 9 93 80 | 50 11 71 78 36 25 66 40 43 51 81 48 44 27 75 73 14 26 99 49 69 6 55 33 67
|
||||||
|
Card 204: 82 64 58 18 73 13 2 71 24 49 | 9 61 47 31 5 89 78 99 40 54 23 68 38 95 69 84 53 27 45 33 87 90 93 44 60
|
6
inputs/pb4_sample.txt
Normal file
6
inputs/pb4_sample.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
|
||||||
|
Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
|
||||||
|
Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1
|
||||||
|
Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83
|
||||||
|
Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
|
||||||
|
Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11
|
236
inputs/pb5.txt
Normal file
236
inputs/pb5.txt
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
seeds: 2880930400 17599561 549922357 200746426 1378552684 43534336 155057073 56546377 824205101 378503603 1678376802 130912435 2685513694 137778160 2492361384 188575752 3139914842 1092214826 2989476473 58874625
|
||||||
|
|
||||||
|
seed-to-soil map:
|
||||||
|
341680072 47360832 98093750
|
||||||
|
1677587229 1836834678 160297919
|
||||||
|
1122651749 4014790961 280176335
|
||||||
|
2279929873 2689269992 53644948
|
||||||
|
3916120104 1199400457 172302726
|
||||||
|
0 381576527 58197295
|
||||||
|
1402828084 3450816018 274759145
|
||||||
|
3909949227 2540063154 6170877
|
||||||
|
802918801 2384227172 155835982
|
||||||
|
4088422830 3244271552 206544466
|
||||||
|
958754783 1997132597 28874650
|
||||||
|
58197295 306349987 75226540
|
||||||
|
180784667 145454582 160895405
|
||||||
|
2334903647 1543332738 293501940
|
||||||
|
3699983017 2997982209 25342830
|
||||||
|
2333574821 2687941166 1328826
|
||||||
|
3111317969 1371703183 171629555
|
||||||
|
2806959198 2135774873 248452299
|
||||||
|
2766721604 717118138 40237594
|
||||||
|
3055411497 2632034694 55906472
|
||||||
|
2628405587 3023325039 138316017
|
||||||
|
1837885148 757355732 442044725
|
||||||
|
3725325847 2813358829 184623380
|
||||||
|
3353391413 2026007247 109767626
|
||||||
|
987629433 3962399141 10015813
|
||||||
|
717118138 2546234031 85800663
|
||||||
|
3282947524 2742914940 70443889
|
||||||
|
1080275742 3972414954 42376007
|
||||||
|
133423835 0 47360832
|
||||||
|
3463159039 3725575163 236823978
|
||||||
|
997645246 3161641056 82630496
|
||||||
|
|
||||||
|
soil-to-fertilizer map:
|
||||||
|
303672059 1087423328 103502353
|
||||||
|
171922589 2907629744 91556518
|
||||||
|
2064217168 468859004 91214014
|
||||||
|
1129888530 1046445685 40977643
|
||||||
|
3698610046 4215442249 79525047
|
||||||
|
1045870106 1586657152 41455160
|
||||||
|
1170866173 1322928302 17679660
|
||||||
|
4160148003 3332238470 107558461
|
||||||
|
4267706464 3853049576 27260832
|
||||||
|
0 3007612896 90771201
|
||||||
|
3447204990 3880310408 249339913
|
||||||
|
1189561657 1438888401 43309463
|
||||||
|
4019710828 3219712242 104981462
|
||||||
|
2226263856 2187322171 114088350
|
||||||
|
553216166 1847338068 182148047
|
||||||
|
3217647099 3439796931 229557891
|
||||||
|
2832115692 1482197864 23307900
|
||||||
|
867366834 94995931 178503272
|
||||||
|
1969221237 0 94995931
|
||||||
|
3785679859 3704810535 148239041
|
||||||
|
1095751900 2693816297 34136630
|
||||||
|
4124692290 3669354822 35455713
|
||||||
|
454935727 1340607962 98280439
|
||||||
|
2204466075 1628112312 21797781
|
||||||
|
1947833351 2164918461 21387886
|
||||||
|
2634687717 1649910093 197427975
|
||||||
|
263479107 2850768768 40192952
|
||||||
|
3696544903 3217647099 2065143
|
||||||
|
735364213 1190925681 132002621
|
||||||
|
3050783393 2337205982 47600704
|
||||||
|
1087325266 2999186262 8426634
|
||||||
|
3778135093 3324693704 7544766
|
||||||
|
2855423592 273499203 195359801
|
||||||
|
90771201 1505505764 81151388
|
||||||
|
2340352206 560073018 290906919
|
||||||
|
1531641800 939263745 107181940
|
||||||
|
1188545833 2186306347 1015824
|
||||||
|
1355686961 850979937 88283808
|
||||||
|
1492181516 2029486115 39460284
|
||||||
|
1638823740 2384806686 309009611
|
||||||
|
2155431182 2894390312 13239432
|
||||||
|
1443970769 2068946399 48210747
|
||||||
|
1232871120 2727952927 122815841
|
||||||
|
3933918900 4129650321 85791928
|
||||||
|
2631259125 2890961720 3428592
|
||||||
|
407174412 2117157146 47761315
|
||||||
|
2168670614 2301410521 35795461
|
||||||
|
|
||||||
|
fertilizer-to-water map:
|
||||||
|
4253126168 3603943470 41841128
|
||||||
|
3150812716 3873122781 161556325
|
||||||
|
4132148538 3445929121 16652907
|
||||||
|
4071215062 2557593856 10373731
|
||||||
|
3585414898 2401284809 61555959
|
||||||
|
124617758 989226185 56063423
|
||||||
|
1311995731 916233018 72993167
|
||||||
|
180681181 891200267 25032751
|
||||||
|
1577315548 1448436684 231921083
|
||||||
|
69948934 1391916079 39397864
|
||||||
|
2730663795 3577458422 26485048
|
||||||
|
2453473122 3255362867 102306532
|
||||||
|
4148801445 3801350502 12292818
|
||||||
|
3002725397 3107275548 148087319
|
||||||
|
3525935437 3813643320 59479461
|
||||||
|
3982955340 3357669399 88259722
|
||||||
|
2631712351 2567967587 98951444
|
||||||
|
628324302 2038793089 109830184
|
||||||
|
3427245435 3721480891 3936914
|
||||||
|
796140554 1045289608 36965524
|
||||||
|
939693576 1140241200 24301167
|
||||||
|
205713932 1680357767 358435322
|
||||||
|
4161094263 2666919031 92031905
|
||||||
|
1103981621 0 206162329
|
||||||
|
1809236631 761213122 129987145
|
||||||
|
1310143950 1431313943 1851781
|
||||||
|
4081588793 3056715803 50559745
|
||||||
|
738154486 1082255132 57986068
|
||||||
|
564149254 206162329 64175048
|
||||||
|
3722667150 4034679106 260288190
|
||||||
|
3431182349 2462840768 94753088
|
||||||
|
109346798 1433165724 15270960
|
||||||
|
2757148843 2811139249 245576554
|
||||||
|
1044349135 2294919620 59632486
|
||||||
|
833106078 270337377 106587498
|
||||||
|
3646970857 3645784598 75696293
|
||||||
|
0 2354552106 4006979
|
||||||
|
1974270838 376924875 384288247
|
||||||
|
3312369041 3462582028 114876394
|
||||||
|
2401284809 2758950936 52188313
|
||||||
|
1384988898 1199589429 192326650
|
||||||
|
963994743 2214565228 80354392
|
||||||
|
1939223776 1164542367 35047062
|
||||||
|
4006979 2148623273 65941955
|
||||||
|
2555779654 3725417805 75932697
|
||||||
|
|
||||||
|
water-to-light map:
|
||||||
|
1553071310 2767299260 81555093
|
||||||
|
1638385137 3758734 7165416
|
||||||
|
3923895602 3742459208 355646104
|
||||||
|
2563492152 40550035 317968
|
||||||
|
357175543 151852464 53516575
|
||||||
|
756535305 2730597762 36701498
|
||||||
|
1142337672 1915537677 164067723
|
||||||
|
436470886 2848854353 61956232
|
||||||
|
1316538987 1679005354 102639946
|
||||||
|
609765571 2079605400 146769734
|
||||||
|
1306405395 2660382036 10133592
|
||||||
|
3817572860 3406157555 106322742
|
||||||
|
2023184953 353497588 62195869
|
||||||
|
3531543848 4223491605 71475691
|
||||||
|
410692118 126073696 25778768
|
||||||
|
4279541706 3727562743 14896465
|
||||||
|
2903607795 1495097536 74179449
|
||||||
|
1794747312 2279656479 95385933
|
||||||
|
2783150325 2269091374 10565105
|
||||||
|
3406157555 4098105312 125386293
|
||||||
|
2145462956 205369039 148128549
|
||||||
|
2833741244 2401175172 69866551
|
||||||
|
793236803 685594104 306384629
|
||||||
|
1645550553 2511185277 149196759
|
||||||
|
1419178933 1781645300 133892377
|
||||||
|
1634626403 0 3758734
|
||||||
|
3274934245 2471041723 36449164
|
||||||
|
0 1097896179 357175543
|
||||||
|
2563810120 991978733 105917446
|
||||||
|
4294438171 3727033618 529125
|
||||||
|
2688189328 1569276985 94960997
|
||||||
|
2669727566 2507490887 3694390
|
||||||
|
3311383409 10924150 29625885
|
||||||
|
1099621432 2226375134 42716240
|
||||||
|
1890133245 2910810585 133051708
|
||||||
|
583632811 2375042412 26132760
|
||||||
|
498427118 40868003 85205693
|
||||||
|
2293591505 415693457 269900647
|
||||||
|
2673421956 1664237982 14767372
|
||||||
|
2085380822 2670515628 60082134
|
||||||
|
3603019539 3512480297 214553321
|
||||||
|
2977787244 3043862293 297147001
|
||||||
|
2793715430 1455071722 40025814
|
||||||
|
|
||||||
|
light-to-temperature map:
|
||||||
|
3752181853 3850028427 61847460
|
||||||
|
3392702182 4061054452 68370555
|
||||||
|
3610251302 4129425007 141930551
|
||||||
|
2019529001 2633762146 55812503
|
||||||
|
1423059901 2612524947 21237199
|
||||||
|
1637625157 3160312690 128493598
|
||||||
|
2109055159 2018596226 368399035
|
||||||
|
343891384 811352094 920120231
|
||||||
|
154347384 2422980947 189544000
|
||||||
|
2075341504 1978947609 33713655
|
||||||
|
1444297100 2966984633 193328057
|
||||||
|
35985686 2689574649 118361698
|
||||||
|
2477454194 0 811352094
|
||||||
|
1772053717 1854798742 124148867
|
||||||
|
1264011615 2807936347 159048286
|
||||||
|
0 2386995261 35985686
|
||||||
|
1766118755 2012661264 5934962
|
||||||
|
3814029313 3392702182 457326245
|
||||||
|
3461072737 3911875887 149178565
|
||||||
|
1896202584 1731472325 123326417
|
||||||
|
|
||||||
|
temperature-to-humidity map:
|
||||||
|
3344602117 2991074372 262457649
|
||||||
|
1707309180 3911386116 383581180
|
||||||
|
3778482785 2130995124 374719434
|
||||||
|
3607059766 3253532021 171423019
|
||||||
|
584508486 478912361 161371970
|
||||||
|
1578590582 2505714558 128718598
|
||||||
|
3294145751 1806488186 50456366
|
||||||
|
1143023241 2829557603 161516769
|
||||||
|
1304540010 1856944552 274050572
|
||||||
|
2090890360 3424955040 344665999
|
||||||
|
2435556359 1143023241 663464945
|
||||||
|
496214964 1000471163 88293522
|
||||||
|
0 640284331 360186832
|
||||||
|
3099021304 2634433156 195124447
|
||||||
|
360186832 342884229 136028132
|
||||||
|
745880456 0 342884229
|
||||||
|
4153202219 3769621039 141765077
|
||||||
|
|
||||||
|
humidity-to-location map:
|
||||||
|
3114211644 984440400 35385940
|
||||||
|
3530465412 479339778 128291026
|
||||||
|
0 3699707734 285474938
|
||||||
|
2898087648 3606829306 92878428
|
||||||
|
2762235329 607630804 135852319
|
||||||
|
4210792153 4197161772 84175143
|
||||||
|
3149597584 31394121 380867828
|
||||||
|
1848709689 0 31394121
|
||||||
|
1880103810 412261949 67077829
|
||||||
|
285474938 1579019790 1563234751
|
||||||
|
2990966076 3566305423 40523883
|
||||||
|
2434079297 1019826340 328156032
|
||||||
|
2371232521 3985182672 62846776
|
||||||
|
1947181639 3142254541 424050882
|
||||||
|
3899713715 1347982372 148315733
|
||||||
|
3031489959 1496298105 82721685
|
||||||
|
4197161772 4281336915 13630381
|
||||||
|
3658756438 743483123 240957277
|
33
inputs/pb5_sample.txt
Normal file
33
inputs/pb5_sample.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
seeds: 79 14 55 13
|
||||||
|
|
||||||
|
seed-to-soil map:
|
||||||
|
50 98 2
|
||||||
|
52 50 48
|
||||||
|
|
||||||
|
soil-to-fertilizer map:
|
||||||
|
0 15 37
|
||||||
|
37 52 2
|
||||||
|
39 0 15
|
||||||
|
|
||||||
|
fertilizer-to-water map:
|
||||||
|
49 53 8
|
||||||
|
0 11 42
|
||||||
|
42 0 7
|
||||||
|
57 7 4
|
||||||
|
|
||||||
|
water-to-light map:
|
||||||
|
88 18 7
|
||||||
|
18 25 70
|
||||||
|
|
||||||
|
light-to-temperature map:
|
||||||
|
45 77 23
|
||||||
|
81 45 19
|
||||||
|
68 64 13
|
||||||
|
|
||||||
|
temperature-to-humidity map:
|
||||||
|
0 69 1
|
||||||
|
1 0 69
|
||||||
|
|
||||||
|
humidity-to-location map:
|
||||||
|
60 56 37
|
||||||
|
56 93 4
|
26
main.cpp
26
main.cpp
@ -1,5 +1,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "pb_1/problem_1.hpp"
|
#include "pb_1/problem_1.hpp"
|
||||||
|
#include "pb_2/problem_2.hpp"
|
||||||
|
#include "pb_4/problem_4.hpp"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
{
|
{
|
||||||
@ -10,8 +12,28 @@ int main() {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::cout << "Begin Problem 1 part 2\n";
|
std::cout << "Begin Problem 1 part 2\n";
|
||||||
if (const auto result = pb1::solve_problem_part2("inputs/pb1_p2_sample.txt"); result != 0) {
|
// if (const auto result = pb1::solve_problem_part2("inputs/pb1_p2_sample.txt"); result != 0) {
|
||||||
std::cout << "Problem 1 part2: " << result << '\n';
|
// std::cout << "Problem 1 part2: " << result << '\n';
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::cout << "Begin Problem 2 part 1\n";
|
||||||
|
if (const auto result = pb2::problem_part1("inputs/pb2.txt"); result != 0) {
|
||||||
|
std::cout << "Problem 2 part 1: " << result << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::cout << "Begin Problem 4 part 1\n";
|
||||||
|
if (const auto result = pb4::problem_part1("inputs/pb4.txt"); result != 0) {
|
||||||
|
std::cout << "Problem 4 part 1: " << result << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::cout << "Begin Problem 4 part 2\n";
|
||||||
|
if (const auto result = pb4::problem_part2("inputs/pb4.txt"); result != 0) {
|
||||||
|
std::cout << "Problem 4 part 2: " << result << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
11
pb_1/CMakeLists.txt
Normal file
11
pb_1/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
project(pb1 CXX)
|
||||||
|
|
||||||
|
add_library(pb_1 STATIC problem_1.cpp problem_1.hpp)
|
||||||
|
|
||||||
|
target_compile_definitions(pb_1 PUBLIC $<$<AND:$<CONFIG:Debug>,$<STREQUAL:$<CXX_COMPILER_ID>,GNU>>:_GLIBCXX_DEBUG>)
|
||||||
|
|
||||||
|
target_compile_options(pb_1 PUBLIC ${COMPILE_FLAGS})
|
||||||
|
|
||||||
|
target_link_options(pb_1 PUBLIC ${LINKER_OPTIONS})
|
||||||
|
|
||||||
|
target_link_libraries(pb_1 PUBLIC ${LINKER_FLAGS} common)
|
@ -7,12 +7,14 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <unordered_set>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <format>
|
#include <format>
|
||||||
|
|
||||||
|
#include "../common/common_functions.hpp"
|
||||||
|
|
||||||
namespace pb1 {
|
namespace pb1 {
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
|
|
||||||
@ -30,44 +32,18 @@ namespace pb1 {
|
|||||||
"nine"sv,
|
"nine"sv,
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::unordered_set numbersSet{
|
const std::unordered_map<std::string_view, char> numbersSet{
|
||||||
"one"sv,
|
{ "one"sv, '1' },
|
||||||
"two"sv,
|
{ "two"sv, '2' },
|
||||||
"three"sv,
|
{ "three"sv, '3' },
|
||||||
"four"sv,
|
{ "four"sv, '4' },
|
||||||
"five"sv,
|
{ "five"sv, '5' },
|
||||||
"six"sv,
|
{ "six"sv, '6' },
|
||||||
"seven"sv,
|
{ "seven"sv, '7' },
|
||||||
"eight"sv,
|
{ "eight"sv, '8' },
|
||||||
"nine"sv,
|
{ "nine"sv, '9' },
|
||||||
};
|
};
|
||||||
|
|
||||||
std::optional<std::ifstream> read_file(const fs::path &problemFile) noexcept {
|
|
||||||
std::ifstream file(problemFile);
|
|
||||||
if (!file.is_open()) {
|
|
||||||
const auto error_state = file.rdstate();
|
|
||||||
switch (error_state) {
|
|
||||||
case std::ios::badbit:
|
|
||||||
std::cerr << "Fatal I/O error occurred.\n";
|
|
||||||
break;
|
|
||||||
case std::ios::eofbit:
|
|
||||||
std::cerr << "End of file reached.\n";
|
|
||||||
break;
|
|
||||||
case std::ios::failbit:
|
|
||||||
std::cerr << "Non-fatal I/O error occurred.\n";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cerr << "impossible to reach.\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const auto path_string = problemFile.string();
|
|
||||||
const auto msg = std::format("Failed to open file {}: ", path_string);
|
|
||||||
std::perror(msg.c_str());
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
void part1(const std::string_view &toSearch, std::size_t &result) noexcept {
|
void part1(const std::string_view &toSearch, std::size_t &result) noexcept {
|
||||||
const auto first_digit_pos = toSearch.find_first_of(digits);
|
const auto first_digit_pos = toSearch.find_first_of(digits);
|
||||||
if (first_digit_pos == std::string::npos) {
|
if (first_digit_pos == std::string::npos) {
|
||||||
@ -79,7 +55,7 @@ namespace pb1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::size_t solve_problem_part1(const fs::path &problemFile) {
|
std::size_t solve_problem_part1(const fs::path &problemFile) {
|
||||||
auto file_option = read_file(problemFile);
|
auto file_option = common::read_file(problemFile);
|
||||||
if (!file_option) {
|
if (!file_option) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -96,44 +72,125 @@ namespace pb1 {
|
|||||||
line_with_numbers.reserve(toSearch.size());
|
line_with_numbers.reserve(toSearch.size());
|
||||||
word.reserve(sizeof("seven") - 1);
|
word.reserve(sizeof("seven") - 1);
|
||||||
for (int i = 0; i < toSearch.size(); ++i) {
|
for (int i = 0; i < toSearch.size(); ++i) {
|
||||||
const int second_letter = i + 1, third = i + 2, fourth = i + 3, fifth = i + 4, sixth = i + 5;
|
const std::uint32_t nb_characters_remaining = toSearch.size() - i;
|
||||||
switch (toSearch[i]) {
|
switch (toSearch[i]) {
|
||||||
case 'o': {
|
case 'o': {
|
||||||
if (second_letter >= toSearch.size() or third >= toSearch.size()) {
|
if (nb_characters_remaining >= digitLetters[0].size()) {
|
||||||
|
word.append(toSearch.substr(i, digitLetters[0].size()));
|
||||||
|
if (numbersSet.contains(word)) {
|
||||||
|
line_with_numbers.push_back(numbersSet.at(word));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
word.clear();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 't': {
|
||||||
|
if (nb_characters_remaining >= digitLetters[1].size()) {
|
||||||
|
// TODO: problème si on a two mais là ça ajoute + de caractère…
|
||||||
|
const auto number_two = toSearch.substr(i, digitLetters[1].size());
|
||||||
|
const auto number_three = [&]() -> std::string_view {
|
||||||
|
const auto tmp = toSearch.substr(i);
|
||||||
|
if (tmp.size() <= digitLetters[2].size()) {
|
||||||
|
return toSearch.substr(i);
|
||||||
|
} else {
|
||||||
|
return toSearch.substr(i, digitLetters[2].size());
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
if (numbersSet.contains(number_two) or numbersSet.contains(number_three)) {
|
||||||
|
word.append(numbersSet.contains(number_two) ? number_two : number_three);
|
||||||
|
line_with_numbers.push_back(numbersSet.at(word));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
word.clear();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'f': {
|
||||||
|
// length five and four are equal
|
||||||
|
if (nb_characters_remaining < digitLetters[3].size()) {
|
||||||
line_with_numbers.append(toSearch.substr(i));
|
line_with_numbers.append(toSearch.substr(i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
word.append(toSearch.substr(i, digitLetters[0].size()));
|
word.append(toSearch.substr(i, digitLetters[3].size()));
|
||||||
if (!numbersSet.contains(word)) {
|
if (!numbersSet.contains(word)) {
|
||||||
const auto pos = word.find_first_of(digits);
|
const auto pos = word.find_first_of(digits);
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
line_with_numbers.push_back(word[pos]);
|
line_with_numbers.push_back(word[pos]);
|
||||||
}
|
}
|
||||||
if (word[1] == 'n') {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
line_with_numbers.push_back('1');
|
line_with_numbers.push_back(numbersSet.at(word));
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
word.clear();
|
word.clear();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 's': {
|
||||||
|
if (nb_characters_remaining < digitLetters[6].size()) {
|
||||||
|
line_with_numbers.append(toSearch.substr(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto number_six = toSearch.substr(i, digitLetters[5].size());
|
||||||
|
const auto number_seven = toSearch.substr(i, digitLetters[6].size());
|
||||||
|
if (!numbersSet.contains(number_six) and !numbersSet.contains(number_seven)) {
|
||||||
|
const auto pos = number_seven.find_first_of(digits);
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
line_with_numbers.push_back(word[pos]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
line_with_numbers.push_back(numbersSet.at(word));
|
||||||
|
}
|
||||||
|
word.clear();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'e': {
|
||||||
|
if (nb_characters_remaining < digitLetters[7].size()) {
|
||||||
|
line_with_numbers.append(toSearch.substr(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
word.append(toSearch.substr(i, digitLetters[7].size()));
|
||||||
|
if (!numbersSet.contains(word)) {
|
||||||
|
const auto pos = word.find_first_of(digits);
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
line_with_numbers.push_back(word[pos]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
line_with_numbers.push_back(numbersSet.at(word));
|
||||||
|
}
|
||||||
|
word.clear();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 'n': {
|
||||||
|
if (nb_characters_remaining < digitLetters.back().size()) {
|
||||||
|
line_with_numbers.append(toSearch.substr(i));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
word.append(toSearch.substr(i, digitLetters.back().size()));
|
||||||
|
if (!numbersSet.contains(word)) {
|
||||||
|
const auto pos = word.find_first_of(digits);
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
line_with_numbers.push_back(word[pos]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
line_with_numbers.push_back(numbersSet.at(word));
|
||||||
|
}
|
||||||
|
word.clear();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case '0':
|
||||||
break;
|
case '1':
|
||||||
case 'n':
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
line_with_numbers.push_back(toSearch[i]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ((toSearch[i] - '0') < 10) {
|
if ((toSearch[i] - '0') < 10) {
|
||||||
line_with_numbers.push_back(toSearch[i]);
|
line_with_numbers.push_back(toSearch[i]);
|
||||||
}
|
}
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!line_with_numbers.empty()) {
|
if (!line_with_numbers.empty()) {
|
||||||
@ -142,7 +199,7 @@ namespace pb1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::size_t solve_problem_part2(const fs::path &problemFile) {
|
std::size_t solve_problem_part2(const fs::path &problemFile) {
|
||||||
auto file_option = read_file(problemFile);
|
auto file_option = common::read_file(problemFile);
|
||||||
if (!file_option) {
|
if (!file_option) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
15
pb_2/CMakeLists.txt
Normal file
15
pb_2/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
project(pb_2 CXX)
|
||||||
|
|
||||||
|
find_package(Boost REQUIRED)
|
||||||
|
|
||||||
|
add_library(pb_2 STATIC problem_2.cpp problem_2.hpp)
|
||||||
|
|
||||||
|
target_include_directories(pb_2 PRIVATE ${Boost_INCLUDE_DIR})
|
||||||
|
|
||||||
|
target_compile_definitions(pb_2 PUBLIC $<$<AND:$<CONFIG:Debug>,$<STREQUAL:$<CXX_COMPILER_ID>,GNU>>:_GLIBCXX_DEBUG>)
|
||||||
|
|
||||||
|
target_compile_options(pb_2 PUBLIC ${COMPILE_FLAGS})
|
||||||
|
|
||||||
|
target_link_options(pb_2 PUBLIC ${LINKER_OPTIONS})
|
||||||
|
|
||||||
|
target_link_libraries(pb_2 PUBLIC ${LINKER_FLAGS} common)
|
124
pb_2/problem_2.cpp
Normal file
124
pb_2/problem_2.cpp
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
//
|
||||||
|
// Created by postaron on 17/01/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "problem_2.hpp"
|
||||||
|
#include "../common/common_functions.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <list>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <numeric>
|
||||||
|
#include <charconv>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
namespace pb2 {
|
||||||
|
struct Cube final {
|
||||||
|
int red{ 0 };
|
||||||
|
int green{ 0 };
|
||||||
|
int blue{ 0 };
|
||||||
|
|
||||||
|
constexpr Cube() noexcept = default;
|
||||||
|
|
||||||
|
constexpr Cube(int red, int green, int blue) noexcept: red(red), green(green), blue(blue) {}
|
||||||
|
|
||||||
|
friend std::ostream &operator<<(std::ostream &os, const Cube &cube) {
|
||||||
|
os << "red: " << cube.red << " green: " << cube.green << " blue: " << cube.blue;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cube &operator+=(const Cube &rhs) noexcept {
|
||||||
|
red += rhs.red;
|
||||||
|
green += rhs.green;
|
||||||
|
blue += rhs.blue;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend Cube operator+(Cube lhs, const Cube &rhs) noexcept {
|
||||||
|
lhs += rhs;
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Cube parse_line(const std::string &line) {
|
||||||
|
std::list<std::string_view> cubes_str;
|
||||||
|
std::list<Cube> cubes;
|
||||||
|
std::vector<std::string_view> cube_str;
|
||||||
|
cube_str.reserve(2);
|
||||||
|
std::string_view line_view = line;
|
||||||
|
line_view = line_view.substr(line.find_first_of(':') + 1);
|
||||||
|
boost::split(cubes_str, line_view.cbegin(), boost::is_any_of(","));
|
||||||
|
return std::transform_reduce(cubes_str.begin(),
|
||||||
|
cubes_str.end(),
|
||||||
|
Cube{},
|
||||||
|
std::plus<>{},
|
||||||
|
[&cube_str](std::string_view &str) -> Cube {
|
||||||
|
str = str.substr(1);
|
||||||
|
const std::string tmp(str.cbegin(), str.cend());
|
||||||
|
boost::split(cube_str, tmp, boost::is_any_of(" "));
|
||||||
|
Cube cube;
|
||||||
|
const auto &chars = cube_str.front();
|
||||||
|
switch (cube_str.back().size()) {
|
||||||
|
case 3:
|
||||||
|
// means it's red
|
||||||
|
if (const auto result = std::from_chars(chars.data(),
|
||||||
|
chars.data() + chars.size(),
|
||||||
|
cube.red);
|
||||||
|
result.ec != std::errc{}) {
|
||||||
|
std::cerr << "Error: "
|
||||||
|
<< std::quoted(std::make_error_code(result.ec).message())
|
||||||
|
<< '\n';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
// means it's blue
|
||||||
|
if (const auto result = std::from_chars(chars.data(),
|
||||||
|
chars.data() + chars.size(),
|
||||||
|
cube.blue);
|
||||||
|
result.ec != std::errc{}) {
|
||||||
|
std::cerr << "Error: "
|
||||||
|
<< std::quoted(std::make_error_code(result.ec).message())
|
||||||
|
<< '\n';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// means it's green
|
||||||
|
if (const auto result = std::from_chars(chars.data(),
|
||||||
|
chars.data() + chars.size(),
|
||||||
|
cube.green);
|
||||||
|
result.ec != std::errc{}) {
|
||||||
|
std::cerr << "Error: "
|
||||||
|
<< std::quoted(std::make_error_code(result.ec).message())
|
||||||
|
<< '\n';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cube_str.clear();
|
||||||
|
return cube;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr int maxRed = 12;
|
||||||
|
|
||||||
|
constexpr int maxGreen = 13;
|
||||||
|
|
||||||
|
constexpr int maxBlue = 14;
|
||||||
|
|
||||||
|
std::size_t problem_part1(const fs::path &problemFile) noexcept {
|
||||||
|
auto file_optional = common::read_file(problemFile);
|
||||||
|
if (!file_optional) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::ifstream &file = *file_optional;
|
||||||
|
int i = 1;
|
||||||
|
int output = 0;
|
||||||
|
for (std::string line; std::getline(file, line); ++i) {
|
||||||
|
std::replace(line.begin(), line.end(), ';', ',');
|
||||||
|
auto tmp = parse_line(line);
|
||||||
|
if (tmp.red <= maxRed && tmp.green <= maxGreen && tmp.blue <= maxBlue) {
|
||||||
|
output += i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
14
pb_2/problem_2.hpp
Normal file
14
pb_2/problem_2.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef ADVENTOFCODE2023_PROBLEM_2_HPP
|
||||||
|
#define ADVENTOFCODE2023_PROBLEM_2_HPP
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
namespace pb2 {
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
std::size_t problem_part1(const fs::path &problemFile) noexcept;
|
||||||
|
|
||||||
|
std::size_t problem_part2(const fs::path &problemFile) noexcept;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //ADVENTOFCODE2023_PROBLEM_2_HPP
|
11
pb_4/CMakeLists.txt
Normal file
11
pb_4/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
project(pb_4 CXX)
|
||||||
|
|
||||||
|
add_library(pb_4 STATIC problem_4.cpp problem_4.hpp)
|
||||||
|
|
||||||
|
target_compile_definitions(pb_4 PUBLIC $<$<AND:$<CONFIG:Debug>,$<STREQUAL:$<CXX_COMPILER_ID>,GNU>>:_GLIBCXX_DEBUG>)
|
||||||
|
|
||||||
|
target_compile_options(pb_4 PUBLIC ${COMPILE_FLAGS})
|
||||||
|
|
||||||
|
target_link_options(pb_4 PUBLIC ${LINKER_OPTIONS})
|
||||||
|
|
||||||
|
target_link_libraries(pb_4 ${LINKER_FLAGS} common)
|
125
pb_4/problem_4.cpp
Normal file
125
pb_4/problem_4.cpp
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
//
|
||||||
|
// Created by postaron on 31/07/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "problem_4.hpp"
|
||||||
|
#include "../common/common_functions.hpp"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <string>
|
||||||
|
#include <cmath>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
|
std::vector<int> extract_unique_cards(const std::string &input) {
|
||||||
|
std::set<int> unique_part;
|
||||||
|
|
||||||
|
bool begin_num = false;
|
||||||
|
std::string tmp_num;
|
||||||
|
for (const auto &item: input) {
|
||||||
|
if (!begin_num && item != ' ') {
|
||||||
|
begin_num = true;
|
||||||
|
tmp_num.push_back(item);
|
||||||
|
} else if (begin_num && item == ' ') {
|
||||||
|
begin_num = false;
|
||||||
|
unique_part.insert(std::stoi(tmp_num));
|
||||||
|
tmp_num.clear();
|
||||||
|
} else if (begin_num) {
|
||||||
|
tmp_num.push_back(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tmp_num.empty()) {
|
||||||
|
unique_part.insert(std::stoi(tmp_num));
|
||||||
|
}
|
||||||
|
|
||||||
|
return { unique_part.cbegin(), unique_part.cend() };
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t pb4::problem_part1(const std::filesystem::path &problemFile) noexcept {
|
||||||
|
auto file_opt = common::read_file(problemFile);
|
||||||
|
if (!file_opt) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::ifstream &file = *file_opt;
|
||||||
|
std::string line;
|
||||||
|
std::vector<int> compute_points;
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
if (!line.empty()) {
|
||||||
|
line = line.substr(line.find_first_of(':') + 1);
|
||||||
|
|
||||||
|
const auto split_char = line.find_first_of('|');
|
||||||
|
const auto left = line.substr(0, split_char);
|
||||||
|
const auto right = line.substr(split_char + 1);
|
||||||
|
|
||||||
|
const auto left_cards = extract_unique_cards(left);
|
||||||
|
const auto right_cards = extract_unique_cards(right);
|
||||||
|
std::vector<int> intersection;
|
||||||
|
intersection.reserve(left.size() + right_cards.size());
|
||||||
|
std::set_intersection(left_cards.cbegin(),
|
||||||
|
left_cards.cend(),
|
||||||
|
right_cards.cbegin(),
|
||||||
|
right_cards.cend(),
|
||||||
|
std::back_inserter(intersection));
|
||||||
|
if (!intersection.empty()) {
|
||||||
|
compute_points.emplace_back(
|
||||||
|
static_cast<int>(std::floor(std::pow(2.0f, static_cast<float>(intersection.size() - 1))))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
compute_points.emplace_back(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::accumulate(compute_points.cbegin(), compute_points.cend(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t pb4::problem_part2(const std::filesystem::path &problemFile) noexcept {
|
||||||
|
auto file_opt = common::read_file(problemFile);
|
||||||
|
if (!file_opt) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::ifstream &file = *file_opt;
|
||||||
|
std::string line;
|
||||||
|
std::unordered_map<int, int> matching_number;
|
||||||
|
int i = 1;
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
if (!line.empty()) {
|
||||||
|
line = line.substr(line.find_first_of(':') + 1);
|
||||||
|
|
||||||
|
const auto split_char = line.find_first_of('|');
|
||||||
|
const auto left = line.substr(0, split_char);
|
||||||
|
const auto right = line.substr(split_char + 1);
|
||||||
|
|
||||||
|
const auto left_cards = extract_unique_cards(left);
|
||||||
|
const auto right_cards = extract_unique_cards(right);
|
||||||
|
std::vector<int> intersection;
|
||||||
|
intersection.reserve(left.size() + right_cards.size());
|
||||||
|
std::set_intersection(left_cards.cbegin(),
|
||||||
|
left_cards.cend(),
|
||||||
|
right_cards.cbegin(),
|
||||||
|
right_cards.cend(),
|
||||||
|
std::back_inserter(intersection));
|
||||||
|
|
||||||
|
const int inter_size = static_cast<int>(intersection.size());
|
||||||
|
if (matching_number.contains(i)) {
|
||||||
|
matching_number[i] += 1;
|
||||||
|
} else {
|
||||||
|
matching_number.emplace(i, 1);
|
||||||
|
}
|
||||||
|
for (int j = 1; j <= inter_size; ++j) {
|
||||||
|
const int next_match = i + j;
|
||||||
|
if (!matching_number.contains(next_match)) {
|
||||||
|
matching_number.emplace(next_match, matching_number.at(i));
|
||||||
|
} else {
|
||||||
|
matching_number[next_match] += matching_number.at(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::accumulate(matching_number.cbegin(),
|
||||||
|
matching_number.cend(),
|
||||||
|
0,
|
||||||
|
[](const auto input, const auto &bPair) -> int { return input + bPair.second; });
|
||||||
|
}
|
20
pb_4/problem_4.hpp
Normal file
20
pb_4/problem_4.hpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// Created by postaron on 31/07/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef ADVENTOFCODE2023_PROBLEM_4_HPP
|
||||||
|
#define ADVENTOFCODE2023_PROBLEM_4_HPP
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
namespace pb4 {
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
std::size_t problem_part1(const fs::path &problemFile) noexcept;
|
||||||
|
|
||||||
|
std::size_t problem_part2(const fs::path &problemFile) noexcept;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //ADVENTOFCODE2023_PROBLEM_4_HPP
|
Loading…
Reference in New Issue
Block a user