diff --git a/2025/CMakeLists.txt b/2025/CMakeLists.txt new file mode 100644 index 0000000..641519a --- /dev/null +++ b/2025/CMakeLists.txt @@ -0,0 +1,9 @@ +set(HEADERS "") +set(SOURCES "day01.cpp") +add_executable(day01 ${HEADERS} ${SOURCES}) +target_include_directories(day01 PUBLIC ${PROJECT_SOURCE_DIR}) +target_compile_features(day01 PRIVATE cxx_std_23) +target_link_libraries(day01 PRIVATE ${PLATFORM_LINK_LIBRARIES}) +target_compile_definitions(day01 PRIVATE ${PLATFORM_DEFINITIONS}) +target_compile_options(day01 PRIVATE ${BASE_OPTIONS}) +source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${HEADERS} ${SOURCES}) diff --git a/2025/day01.cpp b/2025/day01.cpp new file mode 100644 index 0000000..2184175 --- /dev/null +++ b/2025/day01.cpp @@ -0,0 +1,14 @@ +#include + +static auto entry([[maybe_unused]]std::span const& args) -> void { +} + +auto main([[maybe_unused]]int argc, [[maybe_unused]]char const* argv[]) -> int { + try { + entry({argv, std::next(argv, argc)}); + } catch (std::exception const& e) { + (void)e; + return 1; + } + return 0; +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 69655b1..c191693 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,145 +3,17 @@ project(aoc VERSION 0.0.0) set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Group CMake targets inside a folder set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Generate compile_commands.json for language servers -include(FetchContent) -FetchContent_Declare( - fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG 10.1.0 -) -list(APPEND FETCH_CONTENTS fmt) -FetchContent_Declare( - utf8cpp - GIT_REPOSITORY https://github.com/nemtrif/utfcpp.git - GIT_TAG v4.0.5 -) -list(APPEND FETCH_CONTENTS utf8cpp) -FetchContent_Declare( - asio - GIT_REPOSITORY https://github.com/mononerv/asio.git - GIT_TAG bcb8a933b27021d77f2d183991d815ea6c8cdc97 -) -list(APPEND FETCH_CONTENTS asio) -FetchContent_Declare( - stb - GIT_REPOSITORY https://github.com/mononerv/stb.git - GIT_TAG 698c6fb9889c71494b49c9187d249af5fc87b211 -) -list(APPEND FETCH_CONTENTS stb) -# Turn off BUILD_TESTING globally to prevent CTest from being included in CTRE -set(BUILD_TESTING OFF CACHE BOOL "Disable testing globally" FORCE) -# Set the CTRE_BUILD_TESTS option before including the CTRE library -set(CTRE_BUILD_TESTS OFF CACHE BOOL "Build ctre Tests" FORCE) -FetchContent_Declare( - ctre - GIT_REPOSITORY https://github.com/hanickadot/compile-time-regular-expressions.git - GIT_TAG v3.9.0 -) -list(APPEND FETCH_CONTENTS ctre) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/platform.cmake") -FetchContent_MakeAvailable(${FETCH_CONTENTS}) -find_package(Threads REQUIRED) +add_subdirectory("2025") -# Group dependencies in Visual Studio and Xcode -if (CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES "Xcode") - set_target_properties(fmt PROPERTIES FOLDER deps) - set_target_properties(stb PROPERTIES FOLDER deps) -endif() - -set(BASE_DEFINITIONS "ASIO_STANDALONE") -if (APPLE) - message("Platform Apple") - list(APPEND BASE_DEFINITIONS - "AOC_PLATFORM=Apple" - ) - set(IS_UNIX true) -elseif (UNIX AND NOT APPLE AND NOT EMSCRIPTEN) # Linux, BSD, Solaris, Minix - message("Platform Unix") - list(APPEND BASE_DEFINITIONS - "AOC_PLATFORM=Linux" - ) - set(IS_UNIX true) -elseif (WIN32) - message("Platform Windows") - list(APPEND BASE_DEFINITIONS - "AOC_PLATFORM=Windows" - ) -else() - message(FATAL_ERROR "Unkown platform!") -endif() - -# Compiler specific options -if (NOT MSVC) - set(BASE_OPTIONS - "-Wall" - "-Wextra" - "-Wconversion" - "-Wpedantic" - "-Wshadow" - "-Werror" - # fmt warnings - "-Wno-unknown-attributes" - # ctre warning - "-Wno-missing-template-arg-list-after-template-kw" - ) -else() - set(BASE_OPTIONS - "/W4" - "/WX" - "/utf-8" - "/Zc:__cplusplus" - #"/fsanitize=address" # Doesn't work without Visual Studio - ) -endif() - -set(HEADERS - aoc/utils.hpp -) -set(SOURCES "") -add_library(aoclib OBJECT ${HEADERS} ${SOURCES}) -target_include_directories(aoclib - PUBLIC - ${PROJECT_SOURCE_DIR} - PRIVATE - ${PROJECT_SOURCE_DIR}/aoc -) -target_compile_features(aoclib PRIVATE cxx_std_23) -target_compile_options(aoclib PRIVATE ${BASE_OPTIONS}) -target_compile_definitions(aoclib - PRIVATE - ${BASE_DEFINITIONS} -) -target_link_libraries(aoclib - PUBLIC - fmt - utf8cpp - ctre - stb::stb - Threads::Threads - asio::asio -) -source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${HEADERS} ${SOURCES}) - -add_subdirectory(sol/24) - -set(HEADERS "") -set(SOURCES "aoc.cpp") -add_executable(aoc ${HEADERS} ${SOURCES}) -target_include_directories(aoc - PUBLIC - ${PROJECT_SOURCE_DIR} - PRIVATE - ${PROJECT_SOURCE_DIR}/aoc -) -target_compile_features(aoc PRIVATE cxx_std_23) -target_compile_options(aoc PRIVATE ${BASE_OPTIONS}) -target_compile_definitions(aoc - PRIVATE - ${BASE_DEFINITIONS} -) -target_link_libraries(aoc - PUBLIC - aoclib - aoc24 -) -source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${HEADERS} ${SOURCES}) +# set(HEADERS "") +# set(SOURCES "aoc.cpp") +# add_executable(aoc ${HEADERS} ${SOURCES}) +# target_include_directories(aoc PUBLIC ${PROJECT_SOURCE_DIR}) +# target_compile_features(aoc PRIVATE cxx_std_23) +# target_link_libraries(aoc PRIVATE ${PLATFORM_LINK_LIBRARIES}) +# target_compile_definitions(aoc PRIVATE ${PLATFORM_DEFINITIONS}) +# target_compile_options(aoc PRIVATE ${BASE_OPTIONS}) +# source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${HEADERS} ${SOURCES}) diff --git a/aoc.cpp b/aoc.cpp deleted file mode 100644 index 3b1066c..0000000 --- a/aoc.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "fmt/format.h" - -#include "aoc/utils.hpp" -#include "sol/24/aoc.hpp" - -auto entry([[maybe_unused]]std::span const& args) -> std::expected { - return aoc24::entry(args); -} - -auto main([[maybe_unused]]int argc, [[maybe_unused]]char const* argv[]) -> int { - auto const res = entry({argv, static_cast(argc)}); - if (res) return 0; - fmt::print(stderr, "{}: {}\n", res.error().err.message(), res.error().msg); - return 1; -} diff --git a/aoc/types.hpp b/aoc/types.hpp new file mode 100644 index 0000000..470327a --- /dev/null +++ b/aoc/types.hpp @@ -0,0 +1,41 @@ +#ifndef AOC_TYPES_HPP +#define AOC_TYPES_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace aoc { +namespace types { +using f32 = float; +using f64 = double; + +using u8 = std::uint8_t; +using u16 = std::uint16_t; +using u32 = std::uint32_t; +using u64 = std::uint64_t; + +using usize = std::size_t; +using isize = std::ptrdiff_t; + +using i8 = std::int8_t; +using i16 = std::int16_t; +using i32 = std::int32_t; +using i64 = std::int64_t; + +using c8 = char; +using c16 = char16_t; +using c32 = char32_t; +} + +using namespace aoc::types; +} + +#endif // !AOC_TYPES_HPP diff --git a/aoc/utils.hpp b/aoc/utils.hpp index 373cbf3..6e5582d 100644 --- a/aoc/utils.hpp +++ b/aoc/utils.hpp @@ -1,5 +1,5 @@ -#ifndef AOC_AOC_HPP -#define AOC_AOC_HPP +#ifndef AOC_UTILS_HPP +#define AOC_UTILS_HPP #include #include @@ -12,47 +12,9 @@ #include #include +#include "aoc/types.hpp" + namespace aoc { -namespace types { -using f32 = float; -using f64 = double; - -using b8 = bool; -using u8 = std::uint8_t; -using u16 = std::uint16_t; -using u32 = std::uint32_t; -using u64 = std::uint64_t; - -using usize = std::size_t; -using isize = std::ptrdiff_t; - -using i8 = std::int8_t; -using i16 = std::int16_t; -using i32 = std::int32_t; -using i64 = std::int64_t; - -using c8 = char; -} - -using f32 = types::f32; -using f64 = types::f64; - -using b8 = types::b8; -using u8 = types::u8; -using u16 = types::u16; -using u32 = types::u32; -using u64 = types::u64; - -using usize = types::usize; -using isize = types::isize; - -using i8 = types::i8; -using i16 = types::i16; -using i32 = types::i32; -using i64 = types::i64; - -using c8 = types::c8; - template concept Integral = std::is_integral::value; @@ -106,4 +68,4 @@ inline constexpr auto split = std::views::split; }); } -#endif // !AOC_AOC_HPP +#endif // !AOC_UTILS_HPP diff --git a/cmake/platform.cmake b/cmake/platform.cmake new file mode 100644 index 0000000..5ab8727 --- /dev/null +++ b/cmake/platform.cmake @@ -0,0 +1,98 @@ +# cmake/platform.cmake +# Platform detection + compiler options + +if(DEFINED PLATFORM_CONFIG_INCLUDED) + return() +endif() +set(PLATFORM_CONFIG_INCLUDED TRUE) + +# ------------------------------------------------------- +# Platform detection +# ------------------------------------------------------- +if(APPLE) + set(PLATFORM "macOS") + message(STATUS "Platform: ${PLATFORM}") + + set(PLATFORM_LINK_LIBRARIES + "-framework Cocoa" + "-framework IOKit" + "-framework CoreVideo" + "-framework OpenGL" + ) + +elseif(UNIX AND NOT APPLE AND NOT EMSCRIPTEN) # Linux, BSD, etc. + set(PLATFORM "Linux") + message(STATUS "Platform: ${PLATFORM}") + + set(PLATFORM_LINK_LIBRARIES + dl + m + GL + X11 + ) + +elseif(WIN32) + set(PLATFORM "Windows") + message(STATUS "Platform: ${PLATFORM}") + + set(PLATFORM_LINK_LIBRARIES + OpenGL32.lib + ) + + set(PLATFORM_DEFINITIONS + ${PLATFORM_DEFINITIONS} + "_WIN32_WINNT=0x0A00" + ) + +elseif(EMSCRIPTEN) + set(PLATFORM "Emscripten") + message(STATUS "Platform: ${PLATFORM}") + + # Emscripten specific flags (not the warnings; those are below) + add_compile_options( + -pthread + -fexceptions + -sUSE_PTHREADS=1 + ) + add_link_options( + -pthread + -fexceptions + -sUSE_PTHREADS=1 + ) + +else() + message(FATAL_ERROR "Platform: Unknown!") +endif() + +# ------------------------------------------------------- +# Compiler specific options (BASE_OPTIONS) +# ------------------------------------------------------- +if(NOT MSVC) + set(BASE_OPTIONS + -Wall + -Wextra + -Werror + # fmt warnings + -Wno-deprecated-literal-operator + ) + + if(EMSCRIPTEN) + list(APPEND BASE_OPTIONS + # asio + -Wno-sign-conversion + -Wno-shadow + -Wno-shorten-64-to-32 + -Wno-implicit-int-conversion + -Wno-unused-private-field + -Wno-deprecated-declarations + ) + endif() +else() + set(BASE_OPTIONS + /W4 + /WX # warnings as errors (MSVC equivalent of -Werror) + /utf-8 + /Zc:__cplusplus + #/fsanitize=address # Doesn't work without Visual Studio + ) +endif() diff --git a/dat/24/ex/01.txt b/dat/24/ex/01.txt deleted file mode 100644 index b8af9ad..0000000 --- a/dat/24/ex/01.txt +++ /dev/null @@ -1,6 +0,0 @@ -3 4 -4 3 -2 5 -1 3 -3 9 -3 3 diff --git a/dat/24/ex/02.txt b/dat/24/ex/02.txt deleted file mode 100644 index b49c10d..0000000 --- a/dat/24/ex/02.txt +++ /dev/null @@ -1,6 +0,0 @@ -7 6 4 2 1 -1 2 7 8 9 -9 7 6 2 1 -1 3 2 4 5 -8 6 4 4 1 -1 3 6 7 9 diff --git a/dat/24/ex/03.txt b/dat/24/ex/03.txt deleted file mode 100644 index f274bda..0000000 --- a/dat/24/ex/03.txt +++ /dev/null @@ -1 +0,0 @@ -xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5)) diff --git a/dat/24/ex/03b.txt b/dat/24/ex/03b.txt deleted file mode 100644 index 30032cb..0000000 --- a/dat/24/ex/03b.txt +++ /dev/null @@ -1 +0,0 @@ -xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5)) diff --git a/dat/24/ex/04.txt b/dat/24/ex/04.txt deleted file mode 100644 index 1f4eda2..0000000 --- a/dat/24/ex/04.txt +++ /dev/null @@ -1,10 +0,0 @@ -MMMSXXMASM -MSAMXMSMSA -AMXSXMAAMM -MSAMASMSMX -XMASAMXAMM -XXAMMXXAMA -SMSMSASXSS -SAXAMASAAA -MAMMMXMMMM -MXMXAXMASX diff --git a/dat/24/ex/05.txt b/dat/24/ex/05.txt deleted file mode 100644 index 9d146d6..0000000 --- a/dat/24/ex/05.txt +++ /dev/null @@ -1,28 +0,0 @@ -47|53 -97|13 -97|61 -97|47 -75|29 -61|13 -75|53 -29|13 -97|29 -53|29 -61|53 -97|53 -61|29 -47|13 -75|47 -97|75 -47|61 -75|61 -47|29 -75|13 -53|13 - -75,47,61,53,29 -97,61,53,29,13 -75,29,13 -75,97,47,61,53 -61,13,29 -97,13,75,29,47 diff --git a/dat/24/ex/06.txt b/dat/24/ex/06.txt deleted file mode 100644 index a4eb402..0000000 --- a/dat/24/ex/06.txt +++ /dev/null @@ -1,10 +0,0 @@ -....#..... -.........# -.......... -..#....... -.......#.. -.......... -.#..^..... -........#. -#......... -......#... diff --git a/dat/24/ex/07.txt b/dat/24/ex/07.txt deleted file mode 100644 index fc6e099..0000000 --- a/dat/24/ex/07.txt +++ /dev/null @@ -1,9 +0,0 @@ -190: 10 19 -3267: 81 40 27 -83: 17 5 -156: 15 6 -7290: 6 8 6 15 -161011: 16 10 13 -192: 17 8 14 -21037: 9 7 18 13 -292: 11 6 16 20 diff --git a/dat/24/ex/08.txt b/dat/24/ex/08.txt deleted file mode 100644 index 78a1e91..0000000 --- a/dat/24/ex/08.txt +++ /dev/null @@ -1,12 +0,0 @@ -............ -........0... -.....0...... -.......0.... -....0....... -......A..... -............ -............ -........A... -.........A.. -............ -............ diff --git a/dat/24/ex/09.txt b/dat/24/ex/09.txt deleted file mode 100644 index f96c390..0000000 --- a/dat/24/ex/09.txt +++ /dev/null @@ -1 +0,0 @@ -2333133121414131402 diff --git a/dat/24/ex/10a.txt b/dat/24/ex/10a.txt deleted file mode 100644 index a305b9d..0000000 --- a/dat/24/ex/10a.txt +++ /dev/null @@ -1,4 +0,0 @@ -0123 -1234 -8765 -9876 diff --git a/dat/24/ex/10b.txt b/dat/24/ex/10b.txt deleted file mode 100644 index db56de0..0000000 --- a/dat/24/ex/10b.txt +++ /dev/null @@ -1,7 +0,0 @@ -...0... -...1... -...2... -6543456 -7.....7 -8.....8 -9.....9 diff --git a/dat/24/ex/10c.txt b/dat/24/ex/10c.txt deleted file mode 100644 index 17655af..0000000 --- a/dat/24/ex/10c.txt +++ /dev/null @@ -1,7 +0,0 @@ -..90..9 -...1.98 -...2..7 -6543456 -765.987 -876.... -987.... diff --git a/dat/24/ex/10d.txt b/dat/24/ex/10d.txt deleted file mode 100644 index 185787f..0000000 --- a/dat/24/ex/10d.txt +++ /dev/null @@ -1,7 +0,0 @@ -10..9.. -2...8.. -3...7.. -4567654 -...8..3 -...9..2 -.....01 diff --git a/dat/24/ex/10e.txt b/dat/24/ex/10e.txt deleted file mode 100644 index cada9b3..0000000 --- a/dat/24/ex/10e.txt +++ /dev/null @@ -1,8 +0,0 @@ -89010123 -78121874 -87430965 -96549874 -45678903 -32019012 -01329801 -10456732 diff --git a/dat/24/ex/11a.txt b/dat/24/ex/11a.txt deleted file mode 100644 index 9990375..0000000 --- a/dat/24/ex/11a.txt +++ /dev/null @@ -1 +0,0 @@ -0 1 10 99 999 diff --git a/dat/24/ex/11b.txt b/dat/24/ex/11b.txt deleted file mode 100644 index 9b26c84..0000000 --- a/dat/24/ex/11b.txt +++ /dev/null @@ -1 +0,0 @@ -125 17 diff --git a/dat/24/ex/12a.txt b/dat/24/ex/12a.txt deleted file mode 100644 index b41163a..0000000 --- a/dat/24/ex/12a.txt +++ /dev/null @@ -1,4 +0,0 @@ -AAAA -BBCD -BBCC -EEEC diff --git a/dat/24/ex/12b.txt b/dat/24/ex/12b.txt deleted file mode 100644 index 85b768f..0000000 --- a/dat/24/ex/12b.txt +++ /dev/null @@ -1,10 +0,0 @@ -RRRRIICCFF -RRRRIICCCF -VVRRRCCFFF -VVRCCCJFFF -VVVVCJJCFE -VVIVCCJJEE -VVIIICJJEE -MIIIIIJJEE -MIIISIJEEE -MMMISSJEEE diff --git a/dat/24/ex/14.txt b/dat/24/ex/14.txt deleted file mode 100644 index 2455da4..0000000 --- a/dat/24/ex/14.txt +++ /dev/null @@ -1,12 +0,0 @@ -p=0,4 v=3,-3 -p=6,3 v=-1,-3 -p=10,3 v=-1,2 -p=2,0 v=2,-1 -p=0,0 v=1,3 -p=3,0 v=-2,-2 -p=7,6 v=-1,-3 -p=3,0 v=-1,-2 -p=9,3 v=2,3 -p=7,3 v=-1,2 -p=2,4 v=2,-3 -p=9,5 v=-3,-3 diff --git a/dat/24/ex/16.txt b/dat/24/ex/16.txt deleted file mode 100644 index 2c21676..0000000 --- a/dat/24/ex/16.txt +++ /dev/null @@ -1,15 +0,0 @@ -############### -#.......#....E# -#.#.###.#.###.# -#.....#.#...#.# -#.###.#####.#.# -#.#.#.......#.# -#.#.#####.###.# -#...........#.# -###.#.#####.#.# -#...#.....#.#.# -#.#.#.###.#.#.# -#.....#...#.#.# -#.###.#.#.#.#.# -#S..#.....#...# -############### diff --git a/dat/24/ex/17a.txt b/dat/24/ex/17a.txt deleted file mode 100644 index f09839b..0000000 --- a/dat/24/ex/17a.txt +++ /dev/null @@ -1,5 +0,0 @@ -Register A: 729 -Register B: 0 -Register C: 0 - -Program: 0,1,5,4,3,0 diff --git a/dat/24/ex/17b.txt b/dat/24/ex/17b.txt deleted file mode 100644 index f69bbc0..0000000 --- a/dat/24/ex/17b.txt +++ /dev/null @@ -1,5 +0,0 @@ -Register A: 117440 -Register B: 0 -Register C: 0 - -Program: 0,3,5,4,3,0 diff --git a/dat/24/re/01.txt b/dat/24/re/01.txt deleted file mode 100644 index e68b7bb..0000000 --- a/dat/24/re/01.txt +++ /dev/null @@ -1,1000 +0,0 @@ -60236 87497 -27507 18604 -69810 73952 -60448 56269 -92139 61722 -26802 60858 -77131 85480 -11665 30619 -15622 29287 -50472 55227 -31601 15873 -49999 20227 -87160 41386 -58198 25660 -73480 83349 -34374 31670 -56594 81327 -86225 89142 -41024 80952 -53973 84059 -21336 23710 -68229 32979 -31907 49347 -96121 92108 -91843 55227 -64469 46797 -24945 51234 -38171 20077 -85337 65084 -53614 29287 -33205 92108 -92278 65084 -12348 54841 -74217 64534 -31880 67672 -40671 61530 -97622 51354 -83858 54841 -54900 29287 -75694 32657 -12808 92108 -22110 45441 -24842 80522 -76019 85395 -29801 55227 -62119 24086 -84085 42315 -97633 50312 -55735 84085 -37423 24578 -21883 38297 -24725 85063 -94882 96754 -78917 23949 -38963 37984 -58484 54841 -25045 60224 -44549 68472 -96565 28888 -96544 13183 -56476 62216 -93786 36255 -47385 31017 -53003 74502 -34763 90916 -30965 15026 -33970 18604 -59311 87287 -46656 23655 -90690 94389 -90916 85428 -39888 99400 -80325 15572 -66759 90916 -69011 61530 -42661 76190 -62994 36115 -83076 85495 -22038 90916 -28058 16827 -43772 87497 -97469 84059 -73587 46618 -17373 28474 -67819 22858 -83212 71090 -31111 21853 -50655 80499 -46790 54841 -65893 85337 -32657 30300 -39263 63606 -34654 37756 -70982 97980 -47054 90916 -36308 85428 -78055 25699 -82921 57074 -22806 38778 -52324 18604 -69119 87497 -93821 85337 -72610 45392 -81035 32462 -83645 61530 -40083 12785 -65512 39639 -94178 32657 -94616 23243 -48110 85170 -48871 31323 -19056 85337 -41244 32657 -10055 57273 -11393 29287 -41282 89929 -44215 69138 -65273 49214 -51527 88002 -37756 20404 -62112 28474 -20891 84085 -77160 89946 -66205 46881 -48418 77312 -75464 55227 -61530 59969 -21267 29270 -37370 54841 -88644 90916 -78623 63606 -21706 46881 -44144 28524 -92794 62981 -73104 55227 -41050 17824 -18975 74502 -24323 55737 -65877 13086 -26231 46430 -50875 22462 -28235 13325 -19413 52280 -12895 20227 -99917 14861 -12606 85116 -17157 55498 -65577 49347 -83633 75113 -16385 85022 -13523 14114 -56269 63606 -21797 31017 -15276 42139 -60621 92519 -47097 50088 -93922 70323 -47866 84085 -12491 65028 -97496 99400 -50622 92695 -80936 57661 -90350 61530 -24297 31017 -17654 79327 -25402 46881 -22077 18604 -40903 54120 -50315 84991 -84107 90341 -82297 69059 -31420 92108 -32948 13185 -38573 48477 -41469 92536 -47687 67672 -75858 43056 -87492 55227 -43146 63726 -50630 30114 -69070 31922 -99400 80499 -95819 84085 -28688 85428 -34161 47281 -25281 43111 -72346 85337 -43428 65084 -35269 52541 -69977 15275 -21657 15308 -93149 28977 -26372 22264 -53919 26147 -83653 17007 -52437 55338 -58577 81095 -10669 78580 -48716 61530 -44555 54841 -26276 85428 -44928 27597 -78761 83134 -29197 63606 -10381 16778 -19398 74893 -88620 52809 -30433 65084 -80557 31629 -31479 12679 -50801 83534 -65484 55227 -12778 94213 -22907 98741 -27492 21018 -24335 55895 -92027 63071 -42748 38490 -39736 28474 -29251 15930 -18312 38297 -92108 36420 -56841 23667 -24134 80499 -30573 37975 -35062 82320 -10140 77160 -20132 75245 -34245 41016 -39368 39229 -83603 98755 -98047 98888 -96938 15597 -51784 58196 -70081 78652 -46881 49347 -24066 76805 -23023 84959 -89425 67672 -93763 73425 -86478 87497 -12302 87140 -73930 39280 -25718 63606 -90416 18604 -35786 14027 -93942 65398 -65754 86637 -11744 49347 -49585 93684 -15897 67695 -10695 39893 -96173 28474 -76947 29182 -48784 84085 -91121 20227 -49311 23670 -85372 15774 -16681 89841 -45260 90848 -35560 95034 -83401 21784 -12219 96734 -71067 55227 -99026 80166 -69983 15346 -83934 80058 -64979 12968 -41092 63606 -12308 40087 -75169 96117 -15784 77160 -38824 41537 -40870 85116 -19711 99400 -70507 14564 -94676 54768 -14777 80499 -40418 75245 -64438 83035 -57843 35948 -59713 80499 -34140 70427 -11775 32188 -34406 40942 -56896 74472 -86220 28474 -70476 71102 -96477 98192 -18922 51619 -59519 71811 -10789 47031 -86572 92108 -61550 75245 -84059 23351 -96041 23599 -10215 18375 -45040 17072 -58869 16995 -88390 93777 -91416 55497 -17847 55636 -76901 85287 -18097 38297 -96115 87497 -18055 61095 -45533 87184 -63882 29287 -73200 53074 -22109 89509 -83241 80499 -93489 64603 -56777 31017 -99138 62596 -58373 30342 -99202 25402 -58133 60035 -80500 90916 -73469 17731 -35801 99400 -91384 52122 -27573 24457 -28721 28503 -88538 26807 -92971 14100 -48598 63606 -61286 29287 -91745 56269 -34448 25850 -79106 49347 -34898 19376 -40111 67477 -93372 30265 -63851 32657 -59546 48474 -42335 84059 -36277 54841 -87127 99224 -81168 23408 -92976 92195 -98032 25026 -48696 29287 -20385 32499 -74076 65084 -92372 29299 -17059 74502 -42532 30262 -38449 11418 -43881 32657 -54403 63392 -94721 84085 -95152 51611 -51782 62179 -53025 55227 -36643 49347 -87706 65084 -12976 55227 -44534 26147 -30917 87497 -74502 61774 -67952 95476 -11806 29287 -90030 79066 -68902 98976 -68040 90916 -98301 41380 -36051 49347 -16026 69194 -67357 46509 -67306 73846 -82448 20227 -23641 85428 -84634 31017 -69185 43828 -46097 72892 -17794 26147 -43848 49347 -96312 56999 -56019 92546 -56919 86411 -40237 51598 -55120 87497 -92755 87497 -34906 32657 -54889 75245 -41064 62527 -65738 99349 -64355 75245 -52805 80499 -85428 46881 -37626 83414 -53792 34959 -54369 72387 -38094 68402 -99008 33894 -24058 29287 -18736 51209 -25865 80139 -63486 65084 -62108 92108 -65689 14359 -42333 10289 -69333 38259 -18491 62168 -47310 78249 -54570 84023 -20551 78951 -59475 12064 -50311 56215 -65474 70037 -85663 67672 -69259 33147 -83117 61530 -36840 85337 -34169 47016 -88946 97794 -18112 58674 -46551 38349 -82216 72623 -28051 67042 -92921 53931 -49329 21408 -72000 82465 -16291 64726 -89421 28474 -79147 20446 -10763 18604 -44616 79180 -42112 59021 -16110 11993 -95856 75245 -68250 47047 -73900 18604 -83070 70285 -45039 59298 -34384 91759 -69096 40774 -17871 54746 -12711 13323 -61219 85337 -62596 53507 -65641 61530 -44822 29849 -27694 41410 -18316 40475 -88264 27106 -24559 73846 -51165 95419 -41966 80890 -31980 27305 -18954 73225 -48469 99400 -21431 77160 -61521 58997 -91768 50704 -64691 54596 -26116 67672 -38956 90916 -26542 38297 -55188 23379 -59315 70559 -29191 25198 -66379 38297 -25324 66593 -40836 92108 -61397 12807 -33898 61530 -45415 28400 -33802 90916 -62390 21461 -59153 29287 -36034 30152 -98520 22569 -22195 88748 -33327 60661 -45322 26147 -96822 16363 -16125 34893 -87248 22080 -85116 74502 -46038 18604 -37571 85337 -58238 69159 -41500 16532 -83727 38297 -68575 54551 -31681 49347 -38631 22657 -23561 58198 -76931 45582 -28565 80499 -75538 41731 -53316 85116 -63565 16082 -43704 94497 -70404 44010 -30526 10924 -68736 25749 -66570 15277 -78906 63311 -97695 18604 -83519 65084 -41333 17910 -65117 58198 -83816 13162 -82827 99400 -38854 61353 -10453 97813 -39642 62478 -12432 75245 -73646 64603 -69031 52168 -87888 61523 -66253 60542 -50475 48019 -48201 29287 -76179 83869 -69129 16884 -25515 12228 -19375 84085 -66375 55218 -27327 63518 -58580 23667 -21807 37166 -40268 24090 -97745 23667 -32093 80017 -32735 15898 -38297 72737 -66743 99400 -83349 91011 -58316 49347 -72291 61430 -86837 75245 -73810 18232 -84307 18570 -61747 85337 -31550 89967 -47416 65879 -25093 48062 -65307 65580 -84094 89485 -52515 23667 -49044 38003 -78523 89584 -86184 32463 -35308 81918 -27716 92108 -97833 99584 -55235 33021 -92138 55227 -18414 92108 -66833 28474 -29162 83349 -46906 95696 -91988 73664 -56574 18604 -84481 40052 -92467 20808 -68595 18734 -54857 63112 -46447 89520 -38937 31017 -91755 49347 -69591 73958 -71215 56038 -37212 54841 -68160 93928 -50127 58436 -58834 79630 -64554 56269 -53994 58198 -71503 61530 -41132 89321 -73137 39227 -90473 36281 -34280 10905 -32327 73846 -56962 85428 -93849 17923 -91613 43897 -41600 82433 -68548 40140 -57540 69227 -27024 72558 -84038 29287 -68797 90123 -34585 80998 -17224 44725 -67565 65979 -53439 66006 -10746 34397 -60407 96273 -41402 44313 -74625 94199 -48717 97274 -43053 61530 -60079 92108 -51815 18591 -78297 94936 -75363 62686 -34845 85337 -52300 45188 -18321 54841 -30997 13211 -12201 27495 -57013 81991 -32067 85116 -98986 63998 -56366 80499 -88571 19705 -54841 23231 -21485 36499 -79031 67538 -92188 61530 -39376 16112 -49347 23042 -98452 63606 -52132 12521 -22842 28546 -35826 18604 -62218 99676 -14172 32657 -18364 55674 -49002 62596 -51392 45821 -66873 17929 -67156 74502 -28175 32657 -90671 77571 -84511 54841 -18862 18604 -76865 55383 -17699 69478 -79215 56269 -85442 92108 -10959 45021 -48776 77160 -14892 92936 -41140 55337 -84764 80499 -40023 75245 -67389 46881 -45778 36995 -21318 55227 -59744 75245 -67409 38297 -18164 29287 -61584 96614 -41358 38413 -61352 60463 -70015 35917 -39628 81795 -21915 18604 -16171 90414 -15423 55227 -36716 80499 -55056 90916 -63466 15943 -98203 73846 -99741 99459 -85505 38297 -25032 86060 -66980 54841 -98311 31229 -25350 69484 -83835 14362 -46839 78034 -18604 13604 -73846 50472 -18269 56269 -91727 56269 -68873 59307 -15175 87497 -77802 28474 -28913 82745 -22215 60110 -70059 61531 -36612 33386 -67672 88985 -78181 61530 -39317 18558 -77810 35422 -82429 21444 -76561 23667 -58649 38653 -25363 12807 -61473 87684 -36559 71640 -88918 85428 -74396 16237 -33853 55227 -54850 67672 -39779 28474 -64336 74608 -80980 29287 -45483 42757 -73198 85576 -63606 90916 -52630 16429 -35416 12807 -95544 99400 -44801 64603 -80281 80499 -52182 38598 -23258 51480 -42093 51758 -74897 94719 -98978 70168 -42208 87497 -32037 97893 -65966 61530 -77038 29502 -56448 77741 -83791 74727 -25720 31017 -24543 85306 -83743 51386 -83607 36001 -27371 85337 -96010 42013 -29241 74502 -96301 54841 -60646 92108 -56101 38297 -82779 81249 -16670 32639 -24164 52565 -28474 73988 -41717 29287 -55403 32986 -75739 96626 -55398 85116 -55227 55331 -46733 74502 -50659 81687 -25155 98435 -90938 67672 -90142 98291 -29740 71006 -95852 54841 -26912 47695 -41728 65084 -76264 55227 -81182 67672 -88932 55227 -15524 31186 -75333 51809 -98264 37756 -81912 95741 -62285 60469 -47664 93362 -60019 33153 -54501 98948 -46192 20511 -92628 85116 -58318 82669 -44457 87772 -32136 77838 -74012 58198 -20227 35179 -53716 67847 -53411 73846 -68876 49541 -70125 49347 -75562 11521 -72306 47501 -88484 92108 -70619 38297 -86166 36298 -18487 80499 -92524 87204 -52742 67742 -58671 24114 -90475 27557 -19915 80499 -76602 66482 -28497 44495 -41756 84884 -73642 48266 -11516 75245 -97800 63544 -89184 31017 -41929 71798 -61689 46881 -29287 41446 -39444 47202 -35248 23667 -94851 74119 -86784 88863 -74864 73704 -23002 61530 -75245 36530 -83133 55227 -95285 57184 -85832 28474 -95588 74502 -83915 11024 -71644 96251 -71313 18604 -73235 87497 -33469 49347 -21867 38297 -95267 57786 -89935 28171 -21251 12807 -25478 40283 -99474 11515 -80499 66656 -14837 84184 -64729 40572 -40809 32336 -33236 85592 -20441 71171 -64603 66164 -55291 76339 -28881 12197 -58350 51927 -96845 74322 -97597 82513 -62008 54841 -45790 16819 -77813 80499 -81381 17092 -65519 80499 -26031 96119 -16212 90916 -95140 18604 -10312 92108 -61438 19227 -95084 10260 -99043 72732 -89491 54841 -90269 76128 -48016 44722 -20288 67010 -41063 71020 -74315 22618 -99142 76172 -26666 18604 -45041 76748 -47713 89106 -80657 38823 -81404 85337 -47976 85029 -44477 92418 -55367 96148 -63834 14134 -23382 48292 -77597 33494 -55880 93836 -18367 49347 -82262 76051 -95008 56543 -22783 77168 -12807 87497 -28138 55227 -70523 80353 -74070 90870 -76864 65482 -69003 13575 -24843 29287 -69768 20648 -87497 67672 -18271 94218 -45836 28474 -97769 28474 -80076 65084 -72050 46881 -79328 59489 -37514 80499 -42555 32578 -20199 70816 -49460 73487 -90204 93607 -56298 25196 -99974 70377 -56276 28721 -89189 77206 -60768 80376 -21319 63606 -31997 50398 -32416 90916 -54694 22346 -35088 18897 -51752 26147 -55308 95249 -34420 18604 -23667 33821 -82510 99101 -60857 80499 -36607 87497 -49184 18604 -24850 69833 -74238 29287 -57022 18604 -19800 65084 -75401 99400 -69619 16727 -76302 81630 -26599 78516 -91798 49272 -44256 29287 -26147 51140 -49429 29968 -73408 67672 -22299 47662 -95945 46881 -64434 12499 -25710 19594 -33442 63606 -93780 22452 -79459 23892 -82288 56995 -72573 49347 -48719 58670 -32164 38484 -86403 10414 -38984 39863 -86164 79095 -92712 22911 -89181 49347 -87082 40962 -90401 93895 -52697 15438 -34642 38297 -64004 58198 -42756 66637 -89884 63606 -72848 84059 -81971 22307 -61080 37101 -52293 92108 -10451 93989 -85724 84085 -40006 98335 -34725 36933 -85585 99400 -31017 57385 -18673 92108 -63900 58933 -10042 23667 -89735 55825 -11855 90031 -23358 92108 -74765 61530 -18606 54841 -29355 37589 -48513 60953 -53374 55970 -71218 28711 -39215 18604 -35955 94504 -60316 77721 -82523 96106 -29011 56269 -82545 77160 -69538 64794 -21067 28474 -31600 29287 -48638 79513 -77490 38714 -27808 31017 -51472 96525 -59950 83349 -94201 58024 -74719 32598 -44779 24776 -79697 57387 -53766 37236 -79207 49094 -21981 85337 -70180 38991 -92776 26555 -62229 29287 -22837 90916 -47999 85425 -65084 67672 -24224 63606 -45488 92101 -93347 80499 -57265 69150 -35677 90916 -12235 90916 -23634 17105 -69570 77160 -10364 99400 -64953 58607 -94336 72861 -35805 46881 -54374 49061 -56695 28474 -67989 96030 -66652 99400 -98664 85337 -94703 85337 -34924 46881 -89844 36377 -43375 90916 -62268 92108 diff --git a/dat/24/re/02.txt b/dat/24/re/02.txt deleted file mode 100644 index 18d3b27..0000000 --- a/dat/24/re/02.txt +++ /dev/null @@ -1,1000 +0,0 @@ -3 6 7 9 11 8 -21 24 25 26 29 30 32 32 -29 32 33 34 35 37 38 42 -54 55 57 58 60 61 63 70 -59 61 60 63 65 68 71 -43 44 45 44 46 44 -73 75 73 74 75 75 -82 85 82 85 89 -79 82 84 83 85 92 -91 92 93 93 95 -30 33 35 37 37 39 40 38 -74 75 76 78 78 81 81 -25 26 29 29 30 33 35 39 -71 72 72 74 81 -48 51 55 57 59 60 61 63 -57 59 61 62 64 65 69 66 -86 88 90 92 95 99 99 -2 3 6 7 9 13 17 -84 85 89 92 98 -1 2 8 9 11 12 -36 39 46 47 49 51 53 50 -59 60 63 70 72 73 75 75 -6 9 12 18 19 21 22 26 -69 70 77 80 81 84 89 -20 17 18 21 23 25 -17 14 15 16 17 20 19 -69 67 68 71 71 -27 24 27 30 31 33 37 -20 19 20 22 28 -51 48 50 52 51 53 56 58 -6 5 7 8 10 8 7 -74 72 74 71 71 -36 34 36 37 34 35 39 -6 3 5 8 6 8 11 16 -76 74 76 79 82 82 84 -38 36 38 39 39 42 43 40 -33 31 32 35 37 37 37 -78 75 75 78 82 -67 66 67 69 69 71 77 -86 84 85 87 91 93 -55 52 56 58 60 58 -6 5 8 11 15 17 19 19 -65 62 66 68 71 75 -61 60 62 66 67 70 75 -3 1 2 3 10 12 -83 81 84 86 92 90 -45 43 45 51 52 52 -58 55 61 62 66 -55 53 56 58 60 62 68 75 -65 65 66 68 69 72 75 -75 75 76 79 82 81 -50 50 52 54 57 60 63 63 -11 11 14 16 17 19 23 -56 56 58 59 61 64 65 72 -87 87 89 92 90 93 -73 73 74 76 79 78 81 80 -56 56 59 58 60 63 66 66 -16 16 19 17 18 20 24 -70 70 71 73 74 77 76 83 -71 71 73 73 74 75 77 80 -30 30 31 33 33 32 -73 73 76 77 79 81 81 81 -42 42 44 46 48 48 52 -53 53 53 56 61 -62 62 64 65 66 70 72 75 -47 47 50 52 55 57 61 60 -11 11 13 14 17 21 24 24 -33 33 37 38 39 41 45 -46 46 48 50 54 57 63 -51 51 53 58 60 63 -10 10 11 14 15 16 21 18 -4 4 6 9 14 16 16 -54 54 60 61 65 -36 36 39 45 48 53 -58 62 65 67 69 70 71 73 -64 68 69 70 72 75 74 -89 93 96 97 98 99 99 -58 62 65 66 69 70 74 -13 17 19 22 25 27 34 -51 55 54 57 59 61 -69 73 76 78 80 79 81 80 -30 34 37 34 34 -5 9 10 7 10 14 -74 78 79 76 77 83 -87 91 94 97 98 98 99 -67 71 73 75 75 74 -68 72 72 75 75 -77 81 81 82 86 -16 20 21 22 22 27 -31 35 39 40 43 -85 89 93 94 95 97 99 98 -54 58 62 63 65 68 69 69 -78 82 83 87 90 91 94 98 -17 21 25 27 28 29 34 -34 38 39 45 48 50 52 54 -32 36 38 40 45 44 -65 69 74 76 76 -12 16 17 23 25 29 -26 30 33 35 41 47 -3 8 9 11 14 17 -56 63 64 67 64 -52 57 58 59 61 61 -77 83 85 87 89 90 94 -7 13 15 17 19 21 22 27 -52 58 59 56 57 60 63 -16 22 24 26 23 24 27 24 -66 73 75 76 73 76 76 -9 15 14 17 18 19 22 26 -17 23 25 26 28 31 30 35 -82 87 88 90 90 92 93 -63 69 70 70 67 -87 92 94 96 99 99 99 -43 50 52 52 56 -12 17 17 20 22 28 -67 73 74 77 81 82 84 86 -37 43 45 49 52 51 -71 77 81 83 85 88 89 89 -5 11 15 16 19 23 -36 43 45 49 52 57 -50 56 57 64 67 -49 54 61 64 61 -41 48 55 58 61 61 -72 79 80 81 86 90 -57 62 64 65 68 70 77 83 -88 86 83 80 79 77 78 -97 94 92 89 87 84 82 82 -74 73 71 68 65 63 62 58 -88 86 83 80 75 -12 10 13 11 10 9 -33 32 35 33 30 29 27 28 -14 11 8 7 10 10 -71 70 71 70 68 67 66 62 -20 18 16 18 15 13 12 7 -23 20 19 19 17 -60 57 54 52 50 50 48 50 -72 71 71 69 69 -92 91 88 86 85 84 84 80 -36 35 32 29 29 28 22 -41 38 34 31 30 -24 21 18 14 12 14 -78 77 74 73 69 66 66 -30 28 27 24 20 17 13 -78 76 73 70 66 64 57 -66 63 61 58 56 51 48 47 -19 17 15 12 11 5 7 -34 31 30 29 22 22 -29 28 27 26 21 18 14 -94 93 92 85 79 -84 86 85 82 81 79 76 75 -75 77 74 71 72 -72 75 74 73 72 72 -61 64 62 59 55 -19 21 19 17 14 13 10 5 -4 5 4 7 4 3 -81 82 85 83 86 -32 33 34 31 29 28 25 25 -57 58 55 52 55 51 -18 19 18 21 19 12 -42 44 41 41 39 37 -82 84 82 81 81 79 80 -58 59 58 57 57 54 54 -25 28 27 27 26 25 22 18 -97 99 96 93 90 87 87 82 -95 97 93 91 89 87 -42 44 41 37 36 35 33 36 -35 37 33 31 28 28 -40 41 39 37 36 32 31 27 -88 91 88 84 81 78 71 -93 94 93 92 86 85 -85 88 82 81 80 82 -30 33 31 28 22 22 -58 59 54 53 52 50 48 44 -71 72 66 63 57 -18 18 17 16 15 13 11 9 -47 47 44 43 40 38 36 39 -36 36 35 32 29 28 25 25 -64 64 62 59 56 52 -99 99 96 94 92 90 84 -55 55 53 52 51 48 49 46 -32 32 29 32 34 -94 94 91 89 86 83 85 85 -61 61 59 60 56 -49 49 48 50 43 -8 8 5 5 2 -47 47 47 45 48 -27 27 24 22 20 20 19 19 -99 99 96 93 91 91 90 86 -24 24 23 20 20 18 16 10 -15 15 11 8 6 4 3 -72 72 68 65 64 63 65 -90 90 88 84 83 80 80 -85 85 83 82 80 76 72 -66 66 62 59 52 -74 74 71 68 63 62 60 57 -72 72 71 65 63 60 57 58 -68 68 67 64 61 54 54 -94 94 91 86 84 82 78 -57 57 56 53 48 43 -94 90 89 86 83 -97 93 90 88 87 85 87 -35 31 30 29 27 27 -72 68 66 64 60 -71 67 65 64 61 54 -86 82 85 84 81 78 -35 31 32 30 32 -28 24 23 22 23 21 21 -13 9 8 7 9 6 2 -81 77 74 72 75 69 -75 71 69 69 66 65 62 59 -28 24 22 22 20 19 17 20 -37 33 30 29 27 27 27 -43 39 38 38 35 31 -47 43 43 40 35 -22 18 15 11 8 -45 41 40 36 39 -68 64 63 59 57 56 55 55 -36 32 29 27 23 20 16 -64 60 57 53 51 49 46 40 -90 86 85 82 80 77 71 69 -25 21 18 15 13 8 10 -33 29 26 25 24 21 16 16 -89 85 84 83 82 77 74 70 -83 79 76 75 72 71 66 59 -51 44 43 40 38 35 32 -37 30 28 26 23 20 23 -79 72 71 68 66 63 61 61 -51 46 45 44 41 39 36 32 -80 74 71 68 65 62 60 53 -92 85 88 85 84 82 -34 27 25 27 26 24 27 -69 64 62 64 62 59 59 -31 24 21 20 18 19 15 -79 73 70 72 70 63 -36 31 31 28 26 24 -23 18 17 17 15 18 -27 20 18 15 15 15 -30 24 24 22 18 -56 49 46 46 44 39 -28 21 20 19 15 14 13 -38 33 30 26 23 20 18 21 -54 48 47 44 42 38 38 -50 43 39 38 37 35 34 30 -93 86 84 82 78 76 70 -60 54 47 46 44 -49 42 40 37 36 31 30 32 -23 17 15 14 8 5 5 -97 92 91 90 84 83 79 -81 75 74 71 65 58 -24 27 22 21 19 17 15 14 -62 59 57 56 53 53 -88 84 83 80 78 75 73 73 -33 36 36 33 30 26 -66 63 66 68 69 67 70 73 -70 74 75 75 78 81 81 -76 72 69 72 70 69 70 -30 30 28 27 23 21 16 -80 78 78 76 74 76 -8 5 6 8 14 16 -86 87 90 92 96 97 94 -26 24 22 18 20 -23 17 17 16 13 13 -78 74 74 71 68 65 61 -51 52 52 53 54 60 -75 70 69 71 71 -32 36 36 37 39 43 -73 71 74 76 73 76 78 76 -79 79 78 76 78 75 73 73 -68 67 68 66 69 70 70 -57 63 66 71 71 -83 76 74 72 69 64 62 58 -45 50 48 50 51 48 -53 50 52 56 58 61 59 -31 30 28 28 24 -91 87 84 81 77 76 76 -91 87 86 83 82 84 81 74 -32 33 31 28 27 25 19 15 -25 31 33 35 37 40 -16 19 21 24 25 27 30 34 -41 37 30 27 27 -57 56 63 64 64 -85 88 91 88 86 85 78 -72 76 76 79 82 83 86 89 -4 7 9 12 12 15 16 -58 58 60 62 63 65 67 67 -48 55 58 61 65 -76 76 79 77 78 78 -50 50 53 54 55 61 68 -53 54 53 54 54 -73 71 71 73 77 -41 43 43 42 36 -72 72 69 69 68 67 65 65 -25 22 20 20 18 16 14 8 -24 17 14 13 12 7 7 -91 90 91 92 92 93 -5 8 10 11 16 17 20 20 -7 9 13 16 17 18 23 -6 4 6 7 8 7 11 -73 66 64 63 62 64 -70 68 67 64 61 60 63 -17 16 17 20 24 -69 73 75 76 80 -42 38 37 35 37 34 30 -79 79 78 75 78 75 70 -36 35 40 43 47 -45 47 45 43 39 36 36 -61 65 66 68 69 71 68 -84 77 77 75 73 72 -40 39 33 31 27 -76 72 70 67 63 -23 19 16 15 14 9 6 9 -16 17 16 17 21 -68 68 64 63 61 64 -77 77 79 82 83 86 87 84 -41 34 31 27 21 -90 89 87 85 84 83 -77 75 73 72 71 70 69 66 -89 91 93 96 97 99 -55 52 50 49 48 45 43 40 -75 74 71 69 67 65 -74 77 78 79 82 85 87 89 -75 74 72 70 67 66 63 -32 29 26 23 20 19 16 -55 56 57 59 61 62 64 -68 70 73 74 75 76 79 -30 29 26 23 22 21 19 -52 51 48 47 45 -50 52 55 57 58 60 63 -59 60 63 64 66 68 -83 82 79 76 74 72 70 -23 21 18 17 14 12 -32 33 35 38 39 42 45 -89 88 86 84 81 78 77 76 -51 53 54 57 60 61 62 64 -19 18 15 12 10 8 6 -45 44 41 38 37 35 34 -60 57 55 54 53 52 51 -55 57 58 60 63 66 67 69 -34 31 28 25 24 21 20 -32 29 27 24 22 21 18 -30 28 25 22 19 16 -72 69 68 67 64 62 -37 39 42 45 48 -62 65 67 70 73 -68 71 73 76 79 80 83 84 -73 70 68 65 63 62 59 56 -58 55 53 51 49 -74 75 76 79 82 85 -83 84 85 86 87 89 90 -88 91 94 95 98 -10 13 15 18 19 -84 82 79 78 77 75 74 71 -27 30 33 35 37 40 -59 56 55 52 49 -63 62 61 58 55 52 49 -93 90 89 87 86 85 -1 2 5 8 11 -51 49 46 44 42 41 39 -64 65 66 69 72 75 76 -92 91 89 88 85 83 80 -78 79 80 81 84 -40 39 36 34 32 31 30 -95 92 91 89 88 87 86 85 -66 67 70 72 74 75 76 78 -45 48 49 51 54 -11 10 7 5 2 -80 79 76 75 73 70 68 -33 31 28 26 24 21 18 -3 4 7 10 13 -83 85 87 90 93 94 95 -31 32 33 35 37 38 41 42 -50 49 48 47 45 43 41 -28 29 32 34 37 39 -77 79 81 83 85 86 89 91 -69 71 73 74 75 76 78 81 -41 38 37 36 34 32 30 28 -86 85 84 81 80 79 77 -60 57 56 53 51 -65 67 69 71 74 75 -85 86 88 91 93 95 97 -24 21 19 18 16 13 -17 18 21 22 24 27 30 32 -77 79 80 81 82 83 -19 20 22 24 26 27 30 -93 92 90 87 86 84 82 -84 86 88 91 94 -54 55 58 61 62 -70 67 64 62 60 57 -27 30 33 34 35 37 40 -84 82 80 79 78 -97 95 92 90 88 85 82 -48 47 46 44 42 39 38 -72 69 68 65 63 61 -67 65 64 63 60 59 -85 83 82 80 79 -62 61 58 55 52 -29 30 33 36 38 41 -74 75 78 79 81 82 83 86 -52 54 57 60 63 -32 34 37 38 41 42 45 46 -14 15 18 20 22 25 -86 88 91 94 96 98 99 -31 32 35 37 40 42 43 44 -3 4 7 10 13 15 16 17 -37 35 32 31 29 28 26 23 -56 54 52 50 49 48 47 45 -57 60 62 64 66 68 69 72 -16 13 10 7 5 -85 88 89 91 94 95 -42 40 37 36 33 31 28 -33 34 36 39 42 43 -60 57 55 53 52 51 50 -42 44 46 47 49 -19 16 15 14 12 9 -92 94 96 98 99 -73 71 68 66 64 63 60 -34 33 32 31 28 25 -91 89 87 86 83 81 78 -7 8 11 13 16 -26 25 22 21 20 19 16 -32 34 36 37 40 42 45 -73 70 67 66 65 63 -84 83 81 79 76 74 -48 49 51 52 53 55 -53 55 56 58 59 60 62 -52 54 56 59 60 62 -66 65 62 61 58 55 52 -83 86 87 88 91 -49 52 54 55 57 60 62 63 -46 48 49 50 51 53 55 -40 41 42 43 45 48 -51 54 57 59 61 62 -84 85 86 87 89 92 93 -8 6 5 3 1 -81 78 76 73 70 -69 68 65 62 61 59 58 57 -58 55 52 51 49 46 -61 63 65 66 68 -16 17 19 22 23 -22 20 18 17 16 15 14 12 -27 24 22 19 17 -94 93 90 89 88 85 83 81 -42 41 38 35 34 32 -39 36 33 32 30 28 -17 18 20 21 24 26 29 -37 38 39 40 41 44 46 49 -61 63 66 68 71 73 74 -83 85 88 90 91 92 95 -31 34 35 38 39 40 -17 14 11 8 6 5 3 -69 71 73 75 77 78 -64 67 70 73 74 75 -15 16 18 20 22 24 26 29 -24 27 28 31 34 36 -74 75 76 77 78 79 82 83 -29 30 32 35 38 41 42 45 -60 58 56 53 50 48 -27 24 22 20 19 -47 45 42 40 38 37 -60 57 55 53 51 -67 66 63 62 59 57 -48 49 50 52 53 -69 71 74 77 80 82 85 86 -62 65 66 68 69 -82 85 88 91 92 -44 46 48 51 52 53 -96 94 92 89 86 83 -44 46 49 51 52 -76 77 79 80 81 -78 75 74 73 72 71 68 65 -32 33 34 35 36 37 -49 51 54 56 59 61 62 -63 65 67 69 70 72 73 76 -65 62 59 56 55 -68 66 65 64 62 60 -67 65 63 61 59 56 -85 84 81 78 75 74 72 70 -84 81 80 79 76 -55 54 52 51 50 47 45 -33 31 28 27 25 24 22 -16 19 22 25 28 -76 77 80 81 84 86 -58 55 53 50 47 -97 95 92 89 87 84 82 79 -42 43 45 47 50 51 54 -27 28 29 30 33 35 38 41 -21 20 17 15 14 13 12 -32 34 37 38 41 44 46 -31 32 33 34 35 36 39 40 -36 39 42 45 47 -62 65 67 69 71 72 74 75 -98 97 96 93 91 -64 63 60 57 55 52 50 49 -53 54 55 58 61 63 66 -92 91 90 88 85 -71 73 75 76 77 -79 82 85 87 89 92 -64 62 59 57 54 53 51 -80 82 84 86 87 90 -22 24 27 28 30 33 -55 56 57 60 62 64 67 -59 61 64 66 67 70 73 -8 10 13 15 17 19 22 25 -41 44 47 48 51 -25 27 29 30 32 33 34 36 -63 60 58 56 55 53 51 50 -45 48 50 53 54 56 -3 5 8 11 13 15 18 -30 33 34 35 37 -73 71 69 68 67 64 62 60 -89 88 87 84 82 -45 43 40 38 36 34 33 -52 54 55 56 58 60 62 63 -56 59 61 64 65 68 70 -53 52 51 49 48 47 -55 57 59 60 63 66 -90 91 93 95 97 -62 65 66 68 70 71 74 77 -17 15 13 10 7 5 3 -57 56 55 54 52 49 -60 57 56 54 53 52 50 47 -71 73 75 77 78 81 -49 47 46 45 44 41 40 -47 46 45 44 43 40 38 -7 9 11 13 16 17 20 -12 10 9 6 3 -21 19 16 14 13 12 11 -23 26 28 30 31 -81 79 76 74 73 71 -56 59 61 63 65 68 71 74 -2 3 4 7 8 11 -38 40 43 45 48 50 -26 24 22 21 20 17 -71 73 74 75 78 -78 76 74 71 68 65 -85 86 87 89 91 93 96 -59 62 64 67 69 -16 17 20 22 25 -91 88 86 83 82 79 76 -44 47 49 52 53 55 58 59 -12 11 9 8 5 3 2 -86 87 90 92 95 -80 81 82 83 86 87 89 -28 30 33 35 38 40 43 -90 88 86 84 82 79 78 75 -95 93 91 90 87 -15 17 19 20 21 22 23 24 -72 71 70 68 67 -4 6 7 8 9 10 11 12 -58 60 63 64 65 66 -80 83 86 88 89 90 91 -53 55 56 57 58 61 62 -44 41 39 37 35 -71 73 74 76 77 78 -18 16 14 12 10 8 -5 8 10 13 15 -74 77 79 81 83 -35 33 30 28 26 -60 58 57 55 53 52 50 48 -12 10 7 6 3 1 -76 75 73 70 69 68 -50 53 54 56 58 60 63 -38 36 33 31 28 27 26 23 -48 51 53 56 59 61 -75 72 71 68 67 64 -27 25 22 20 17 16 -42 44 45 46 48 49 -89 87 86 83 82 80 77 76 -97 96 93 91 89 86 84 83 -63 61 58 56 53 52 -28 27 25 22 19 -82 80 78 77 74 -96 93 90 87 84 82 79 -46 49 51 53 56 58 61 -69 67 65 64 61 -59 58 56 54 51 50 49 47 -98 95 94 92 89 87 -59 58 57 54 52 50 -71 72 74 77 78 81 -19 18 17 14 12 11 -81 80 79 76 74 72 71 69 -44 46 47 48 50 51 -1 2 5 8 9 12 13 -77 79 82 85 88 89 92 95 -69 71 73 76 77 -75 77 79 81 84 85 86 89 -4 6 8 9 11 12 15 18 -65 63 62 61 60 59 58 -79 77 76 73 71 -59 57 56 55 53 51 49 -45 47 50 51 54 -28 25 23 20 19 18 17 -46 43 41 38 35 -65 66 68 70 71 -81 80 79 77 75 73 -82 84 85 86 89 90 93 95 -52 53 56 58 59 -26 25 22 20 19 17 -81 82 84 86 87 88 91 -61 60 57 55 53 -56 58 61 63 65 -74 72 70 68 67 -35 34 31 28 27 24 23 -65 63 61 60 59 -88 89 90 92 94 -19 18 17 14 11 10 9 6 -59 60 62 63 65 66 68 -66 64 63 62 60 59 -39 40 42 43 44 -52 49 48 47 46 45 43 40 -40 42 44 45 46 49 50 53 -49 51 53 56 58 -68 65 64 62 61 59 -72 73 76 77 80 -31 30 28 26 23 21 19 -8 9 11 14 15 18 20 23 -2 5 7 8 11 -61 62 64 65 68 71 73 74 -51 54 56 57 58 59 60 63 -19 16 14 12 10 9 -85 82 80 78 77 74 73 70 -88 89 90 91 92 93 -37 38 39 42 45 46 48 50 -26 27 28 30 31 34 -32 35 38 40 41 43 -37 38 40 41 44 -47 48 49 51 52 53 54 -26 23 22 20 19 -99 97 96 93 92 89 86 83 -22 20 17 14 13 -9 12 13 14 16 -26 24 22 21 20 -75 78 81 82 83 84 87 89 -29 28 25 24 23 22 -98 95 92 89 88 85 82 81 -54 56 58 59 60 61 -67 68 70 72 74 75 76 78 -48 46 45 42 41 40 37 -27 29 32 34 35 -38 40 42 43 44 47 49 50 -59 60 63 64 66 -76 77 78 79 82 84 85 88 -47 48 50 51 53 55 57 60 -5 6 7 10 13 15 17 -83 81 80 79 76 74 73 71 -3 5 8 10 13 14 17 18 -37 36 33 32 31 30 -70 67 66 64 62 -43 42 40 38 37 35 34 32 -18 20 21 24 25 28 30 33 -99 97 94 91 89 88 86 85 -64 66 68 70 73 74 77 -24 27 28 29 31 32 -22 25 27 30 33 -42 45 48 51 53 56 59 62 -87 88 90 93 94 95 97 -42 41 39 36 33 30 -83 84 87 90 93 -17 20 23 24 27 28 31 34 -15 17 19 22 25 -82 85 86 87 88 89 90 -1 2 5 7 8 11 -39 38 36 34 33 -23 26 28 29 31 34 36 -58 59 60 61 62 65 -19 20 21 22 24 26 28 -85 87 88 91 92 94 97 -96 93 90 89 88 85 -84 87 89 90 92 -21 23 26 28 29 31 -51 53 54 57 59 60 -49 46 43 41 39 36 33 -75 74 71 70 69 67 -59 62 63 65 66 68 71 -50 49 48 46 43 40 38 37 -79 82 85 88 90 92 -74 72 71 69 66 63 61 -38 39 40 42 43 46 48 -17 19 20 22 24 27 28 29 -46 48 49 51 52 53 -61 58 56 55 54 52 49 47 -12 11 10 9 6 -74 76 77 80 81 82 85 -24 21 20 18 15 13 -44 45 48 49 52 55 56 57 -29 31 34 37 39 41 42 -95 94 92 89 87 86 83 81 -36 39 40 42 44 45 -63 64 66 69 71 74 -75 76 78 81 82 -45 44 42 39 38 35 34 33 -37 38 41 44 47 -86 89 92 93 95 98 -72 74 76 77 78 81 -48 45 42 39 38 -11 12 14 17 19 21 23 -28 27 24 21 20 19 -65 66 69 71 73 75 -48 45 42 39 36 -23 21 18 16 14 13 12 11 -87 84 81 80 79 76 75 -30 32 34 36 37 -77 79 82 83 86 88 91 93 -86 88 90 92 93 95 97 -7 9 10 11 13 14 15 16 -84 85 87 88 90 93 94 -71 69 67 65 63 62 60 -44 42 39 37 36 33 30 -72 74 77 80 82 83 86 -79 76 73 70 67 66 63 62 -79 78 75 73 72 -48 47 45 44 42 39 -19 18 15 14 13 12 11 -67 64 62 59 57 54 52 50 -62 60 58 57 55 54 -31 30 28 25 23 20 19 17 -65 64 62 61 60 57 -50 53 54 57 59 61 64 -30 28 25 22 19 16 13 -14 15 18 19 20 22 24 -28 30 33 34 36 39 40 42 -50 53 56 57 60 61 -37 35 33 31 28 -51 53 55 56 57 60 63 65 -44 42 41 39 37 34 33 -31 29 27 24 21 20 19 18 -76 75 74 72 71 69 68 66 -63 64 66 67 69 70 71 -81 78 77 75 73 -78 80 83 85 86 -79 82 84 87 89 91 94 95 -60 62 64 67 69 71 -33 35 37 40 41 42 43 46 -87 88 91 92 94 95 96 99 -1 4 5 6 7 10 -84 86 89 91 92 -18 21 23 24 27 -40 39 38 35 32 -40 41 42 43 44 47 50 -16 14 12 11 8 6 5 -41 43 46 47 49 52 53 -42 43 46 49 52 53 56 59 -72 70 69 66 64 61 59 -21 19 16 15 12 10 -54 57 59 60 63 65 67 70 -60 59 57 54 52 50 48 -40 37 36 34 32 -99 98 96 93 90 89 87 -55 52 51 48 46 -62 59 58 55 52 -24 27 30 32 33 36 39 42 -79 77 75 74 73 -23 21 18 16 13 12 10 8 -70 68 67 64 61 58 55 -20 23 24 25 28 -42 39 37 35 33 -93 91 89 87 85 83 81 78 -41 42 44 45 48 51 54 57 -77 79 82 85 87 89 92 94 -65 67 70 71 72 -24 22 20 17 16 -66 67 70 72 74 75 76 79 -71 73 74 75 76 78 80 -76 78 79 80 83 -85 84 81 78 76 75 -65 66 68 69 72 73 74 -82 85 88 90 92 95 -71 69 68 67 65 62 60 -67 68 71 73 74 75 -76 79 81 83 86 -79 76 73 70 68 66 64 -89 88 85 83 81 79 76 74 -49 51 53 55 56 -27 29 31 34 35 38 41 44 -27 24 23 21 20 19 17 -12 15 17 19 20 22 24 -67 68 70 72 74 -80 79 77 74 73 71 70 -42 45 46 48 51 53 -29 32 33 36 39 42 43 -91 88 86 83 80 77 -33 35 36 37 40 -44 45 47 50 52 -27 29 32 34 36 37 38 -42 45 47 48 49 50 -28 31 34 36 39 -46 43 40 38 35 32 -27 30 33 36 38 40 43 -65 62 60 58 55 -72 74 77 78 81 83 -85 88 91 94 96 98 -51 48 45 44 42 39 36 -64 66 68 71 73 74 77 -96 95 93 92 90 87 86 -39 42 43 46 47 49 -72 75 76 79 82 84 87 -57 55 54 52 50 -40 43 45 46 47 49 -60 57 55 52 50 48 46 -72 69 67 66 63 62 61 -67 68 69 70 73 75 -88 85 83 82 80 79 76 74 -22 19 17 16 13 12 10 8 -36 38 41 42 45 47 50 -93 91 88 85 84 81 80 77 -65 67 70 71 73 -31 34 37 38 40 42 43 -2 4 5 6 7 10 12 -16 15 13 10 8 6 4 -76 77 80 83 86 -85 86 87 88 91 94 -36 33 31 29 26 25 23 -50 48 47 45 42 39 37 36 -67 68 71 72 75 77 -79 76 74 72 69 68 65 -54 52 49 48 46 44 -47 48 51 53 55 56 -74 71 69 68 67 65 63 61 -24 22 20 17 14 13 -72 74 77 79 80 83 85 -28 25 24 23 20 17 -22 24 26 29 31 34 -3 4 7 9 10 13 14 -21 18 17 14 11 10 9 8 -58 56 55 52 51 49 47 -20 17 16 14 11 9 7 4 -34 37 39 40 42 45 46 49 -52 55 58 60 61 63 -26 27 29 32 35 37 38 39 -59 62 65 68 70 -97 95 94 91 90 89 86 -72 75 76 78 80 82 84 -72 69 66 65 63 62 61 -8 10 12 14 16 18 21 23 -19 16 15 12 11 10 8 5 -47 49 52 55 56 59 62 -63 65 66 69 71 72 74 75 -68 71 72 74 77 80 -61 62 64 66 68 70 72 -14 13 10 8 7 -25 26 28 30 32 -68 66 64 63 61 59 -82 83 86 89 92 95 97 -86 83 82 80 77 75 73 72 -68 70 73 74 75 -23 25 28 29 31 33 35 36 -24 25 26 29 31 34 37 39 -71 74 77 80 82 -83 85 87 89 91 93 -61 64 66 69 71 73 76 79 -84 82 80 78 77 75 72 69 -25 26 29 30 32 34 -60 63 65 68 71 73 74 75 -73 70 69 68 67 -52 55 58 60 62 -87 89 91 92 94 97 -23 22 20 17 16 14 -58 55 52 50 47 46 44 42 -33 34 36 37 40 -29 31 33 36 39 -88 87 86 84 81 -62 61 58 57 54 53 50 -11 13 15 17 19 21 -14 17 19 22 25 27 28 30 -33 35 37 40 41 42 44 -53 50 48 45 44 41 39 38 -17 15 13 10 8 7 4 2 -94 92 90 89 86 85 83 -57 56 53 51 50 47 -77 76 74 71 70 -3 4 5 6 8 -87 90 93 94 97 98 -50 51 53 54 57 59 -23 22 20 18 17 15 14 12 -88 87 84 82 80 78 -55 52 50 48 46 -86 85 82 81 80 78 -80 78 75 73 71 70 69 66 -85 82 80 79 77 -17 19 21 23 24 27 -3 4 7 9 12 -47 50 53 54 55 -74 73 71 68 66 63 -78 79 81 82 85 86 89 -35 37 40 42 45 -77 78 79 81 84 86 87 -63 65 67 69 72 74 75 -85 86 89 92 94 -61 64 67 70 73 75 77 79 -39 36 33 32 30 29 -50 51 53 55 58 59 62 64 -85 84 82 81 79 78 77 -10 12 13 16 19 20 22 25 -84 87 89 92 95 -38 36 34 31 29 28 25 23 -74 76 79 81 84 86 89 -46 47 48 49 51 54 55 -25 22 20 18 15 -22 24 26 28 31 -54 53 50 47 44 41 38 35 -66 65 64 62 60 58 -80 77 74 72 69 66 65 62 -19 22 24 25 27 30 -7 8 11 14 16 17 18 21 -46 44 43 40 37 -55 54 52 49 46 -68 70 72 73 75 78 -33 30 27 26 23 21 20 19 -58 61 62 65 68 70 73 75 -43 41 40 37 36 33 32 29 -33 32 30 29 27 26 23 -25 22 19 17 16 -84 85 87 88 89 90 -34 37 40 42 44 -67 66 63 61 58 55 53 52 -65 64 63 62 59 57 55 52 -74 75 76 77 80 81 83 84 -33 34 36 37 40 43 46 48 -66 67 68 69 72 73 75 -86 89 92 93 95 97 -45 47 50 53 55 57 60 -66 67 68 70 71 73 -37 39 40 41 43 44 46 -65 68 71 73 76 -77 80 82 83 84 87 88 -79 77 74 73 70 69 66 64 -29 28 25 23 22 21 18 -36 38 40 42 43 45 48 -26 23 21 18 17 -90 92 94 97 99 -62 64 66 68 70 71 74 77 -85 83 81 80 77 76 -65 68 70 71 73 74 75 -85 83 80 78 77 76 -68 67 65 62 59 57 -38 40 43 45 46 47 49 -48 50 52 54 55 56 59 61 -64 63 62 59 58 56 54 -25 27 29 32 35 38 -37 40 41 42 43 45 48 49 -64 63 61 58 56 53 50 -26 25 22 21 18 15 13 10 -53 54 55 57 60 -42 39 36 34 31 30 -24 25 27 30 32 -80 79 78 76 73 70 68 -18 20 23 26 27 29 -23 20 19 18 15 -72 74 76 77 78 79 81 82 -30 28 27 25 22 -66 65 62 59 58 57 56 -59 57 55 54 52 51 49 48 -74 75 76 77 79 82 85 86 -33 30 28 27 24 23 22 -26 25 22 21 19 -70 71 74 76 77 79 82 85 -21 19 18 15 13 10 9 -82 80 77 76 75 72 70 67 -90 88 86 84 81 79 77 74 -9 12 15 16 17 -85 87 88 89 92 93 94 97 -63 60 57 54 53 52 -90 89 86 85 82 81 78 -45 46 48 51 54 56 59 62 -96 93 90 89 88 86 83 -38 37 35 32 31 30 -83 86 87 88 91 93 -35 36 39 42 43 45 46 -32 35 38 39 42 44 46 -27 30 31 33 34 36 -50 53 55 58 61 64 65 66 -98 95 93 92 91 90 88 85 -6 7 10 13 15 16 19 22 -15 18 20 21 24 27 -87 85 84 83 81 80 78 -11 13 14 17 19 20 22 -28 27 24 22 21 19 16 -89 88 85 82 81 80 79 -36 38 40 41 43 -63 62 61 58 55 -23 26 29 30 33 35 36 39 -78 75 72 69 68 66 -64 61 60 59 58 57 56 54 -33 31 29 26 25 -72 69 66 63 61 -3 4 7 9 10 -11 14 17 20 23 -17 18 19 20 22 24 27 28 -88 89 92 95 96 -67 64 61 60 58 56 55 -11 12 15 16 18 19 21 24 -7 10 12 13 15 18 21 23 -25 26 27 30 31 -57 56 54 51 50 47 45 -68 71 72 75 77 78 81 83 -53 56 57 60 63 66 68 70 -14 13 12 9 6 5 4 3 -59 56 53 52 50 48 45 -51 48 45 42 40 39 36 -99 96 93 91 88 85 82 80 -22 21 18 16 14 13 12 10 diff --git a/dat/24/re/03.txt b/dat/24/re/03.txt deleted file mode 100644 index 024e5b3..0000000 --- a/dat/24/re/03.txt +++ /dev/null @@ -1,6 +0,0 @@ -'{}mul(339,896)>^+!)^mul(799,303)don't()>mul(188,763)'<};who()select()%;+mul(924,355)mul(492,757) what()mul(582,171)][*+select()#mul(840,899){!when()from()%where()mul(318,527)} :!-'mul(530,886)?}>mul(937,475) $;),%:}mul(201,723)where()select()mul(673,729)why()who()^'who()mul(673,694)[+mul(295,161)[!how(88,740)*mul(364,904)how()<]when()+where()mul(329,432)when()mul(499,11)who(238,444))#~mul(775,866);,[)':where()%{[mul(835,890)+&&select()&[when()why(783,259) select()mul(735,871)!)when()'what()[/:mul(952,728)mul(633,505)@ -(?mul(176,469)*%what()>what()who()@{+do()'mul(117,634)-?(^^%:mul(234,514)where()@%mul(291,507)#from()*!*mul(668,282)@&)>,:select()>{%mul(195,300)-why()select()+&~>/^from()mul(801,834)why()~mul(463,630){*, from()$}:@mul(280,83)when()[mul(358,910)[;'why()where()mul(242,569)from()#<>from()&mul(553,455)%who())mul(284,63)%%*+?mul(437,226)* }how()when()~%'mul(57,491)]select(918,666)where()$when()why()'from()?]mul(321,301)'~:mul(619,356):mul(78,106)what()}!+~mul(609,442); $where()$who()mul(996,918)mul(217,653)@##:#mul(998,408))~<#where()from()who()who()what()(mul(305,980)-~(:>where();when()#mul(721,412)how()'< { mul(143,735){:]why(){#),@mul(670,301)$when(),}why()]?why(839,544)mul(120,681){when()$[?@-)mul(805,510)>from()))when();?'#mul(104,633)%<$%}why()mul(555,387)@$+mul(850,237)!^where()<}from()select()from()<@mul(298,559)who():from()+what();mul(556,540)$%<&(%don't()$/':'*)(mul(976,624)!~*/%why()mul(790,645):~^from()[{+*!mul(153,86)+select(){#!from()how()$mul(980,956)>from()select()}<}@}?~mul(151,20)select()mul(703*(){+]who()what()mul(827,322)+](}mul(531,132what()where()+mul(933,2){&$how()%#;]don't())[]mul(845,519)how(),]when()^mul(518,563)#,++$#mul(500,591)(#/what()where()how()from()mul(243,908);mul(574,691)/who(),who()how()&mul#{where()when()]!@mul(534,43)}do(),}/from()when()~{&@mul(92%what()~}mul(496,669)^(!+ ^~mul(28,334)mul(621,688)]mul(627,561))mul(206,37)]~^&mul(288,740,<@mul(540,77)<&:who(594,229)&'*who(){mul(923,453)mul(733,228)where()how()mul(104,17)/!why()~what()*@}mul(500,830)#'(&%{select()*?mul(301,211)]>@@,mul(21,358) ?mul(285,542)how()from())mul(361,19)(who()%}select(){*mul(362,324)<[]'&when()'mul,why()mul(352,273)mul(742,91)>mul(624,723)) ;@+mul(14,149)(from()%%,(mul(547,492)~+mul(712?@@@&{{mul(972,531) -]&%where()~}who()[how()]mul(602,51)how()+&>,{>] #do()from()~{,*[-mul(862,742)how()why()]%mul(432,72)what(){:do()%@!}-mul(663/+,what()--(&?mul(384,302)'@(mul(649,348)+from()%mul(184,596)~+}~mul(719,53)mul(634,179){-:where()mul(684,320where()when(395,300){who()how()^/;where()mul(849,756)!mul(530,108)#*+}what()^(]select()mul(333,615)[why()%?]~$how()mul(314,366)}where()mul(222,364)<){*[mul(449,95){:who(844,554)<;why()$who() mul(831,201))$mul(408,650)who()what()}<[do()~how()select()!]'why()]how(289,983)* <+%&mul(836,460)%mul(339,868)why():from()from()%mul(91,296)!+^,*when()who()from()-$mul(6,37)when()when()mul(69,574)who(),from(),how()mul(431,678~+how()]mul(644,184)-(?why(571,97)])why()from()mul(516>select()mul(67,86)+~%^!~what();mul(526,440)!+>?<:&mul(81,534)&}'mul(64,25)[-;mul(828$<>*mul(157,667)@[ *who()mul(356,285)select()(~*do()how()';why()&^?mul(165,944)select()mul(980,979)<:!~%mul(15why()$ mul(109,665)&-!why()]<'&mul(887,673)]mul(906,700)#mul}@-where()/{{ -mul(935,960),)''[{mul(533,431)what())'@mul(63,509)@why(464,997)$]mul(164,971)select()~where()how()#>' when()>mul(301,62) +;'+what()}!->mul(722,492))!'mul(262,457):@when()-/mul(902,705)~#(mul(640,550)/*$$#select()where(905,349)!&&don't()when()mul(998,104)select()from()select()'when()mul(37,27)!where()$:do()}mul(160,45)mul(716,642~,{+&+!}[}mul(281,768)who()-?;);%mul(270,620) mul(793from()(![(! : who()mul(481,293)?mul(264,360)where(){from();(select()~!from()mul(748,940)[~]why()$[+how(709,453)mul(590&!+*why()]when()mul(182,631)(how()?(select():;&]{mul(83,366)%when()when()&mul(878,366)why()[:,]mul(77,997);%/$&%]mul(827,204)mul(919,654)>,where()%+mul(678,952)who()@select()}*(mul(344,894)where()mul(408,29)#*!{}*~where(906,182)mul(144,162)!&#select()how()&why()~*#don't()-()]~:how()mul(803,649)]@?#;mul(170,978)mul(263,974)!@why()$how()@mul(155,265)&/%^/mul(571,825)$where()mul(507,171)from()^(~*mul(437,680)from()who()>select()}mul(332,921) where()mul(218,74)})from()/mul(470,570)why()@?who()don't()@({*mul(931,767)mul(486,567):&])%/{]%mul(901,942),' ]why()^where()do(){#,what()mul(331,184)how()when()how()*{:^){mul(339,48){'(what(545,390)mul(818,891)who()mul(828,226), how()where()'#,%?mul(798,324))';mul(337,760)[#mul(350,889)~#how()mul(859,480){}^?&select()where()do()~); who()^mul(640,455}why()#mul(744,51)'[who()/> select()mul^where()select()^}^mul(450,596))select()what()}&%;?mul(218,957)+*who(),}do()from()^} when()+[select(938,490))select()mul(406{how()(+who()()select()mul(329,937)&!mul(693,766)<{+}<[@mul)]%why()when()){~[ who()mul(888,144)~$:,mul(517,97)@) ~mul(394,320)why()when()who()(,%mul(761,855) -mul(22,362)('from(886,421)]mul(730,655)[@,how()(mul(692,165)]&$when()!}from()%mul(481,375)where()~mul(954,570)?why()-+mul(338,656)who()~ <}from()mul(616,31)where()/]:select())?from()mul(113,2):?$mul(295,905)];mul(410,181)@%${^how()>select()where()-mul(779>+what();^who(),>)mul(599,200)%~][select()>+>mul(486,481)*!who(693,495)-$mul(237,686)? how()! -@#do()#<(where()-&'>&what()mul(321,434)}@what()~/from()do()?who()$where()mul(328,792)select()how()mul(82,296)#,who())/when(637,168)mul(465,709)mul(208,775)^[@when()>>##<>mul(379,29)%mul(826,43){when()?who()*why()do()&[):@mul(411,966)^mul(24,557)<;where()mul(391,794)#;mul(592,819)+,}'%'mul(210,928)%mul(29,613);$who()why()!]who()mul(56,646)*@]-{~+:mul(425,457)>mul(896,578)%(how()](*where()when()select(237,23)mul(895,482)~<{mul(432,547)who(471,124){mul(483,785)*mul(422,876)^>& ;(^where()~#mul(709,114)(:;where()select()?%mul(263,276)&?;from()&&~(mul(113,694)who()mul(228,70): >[:@ ;@mul(707,104);:mul(423,229)&$[]>who()mul(194,895)><&&when()%%mul(836,144)<^!~)/;#who()>mul(786,723)?!#[mul(287;why()mul(734,761)!who()/<)mul(520,746)where(){!>>select()how()mul(185,986)mul(566,786)why()when()[~do(),}mul(188,610)/+^%-how()[mul(671,105)*[}[mul(403,996)mul(214+($?{when()mul(268,651),[>mul(660,864)%-/how()->([~mul(769,53)?from(197,675)^[-mul(83,519)where()select()don't()[:from()@{who() ?mul(305,335)[when()when();where(751,621)what()mul(395,86)how()?,who():>mul(349,362)how()?*select()when()from()who()where()''mul(414,725)*)when()select()]+mul(180,197)$who()why()&%'}mul(531who()#{mul(370,295)who()%mul(121,586)*^^%?>{,when()mul(944,189)&[/)select()>&^mul(222,28)@!where()'mul(449,827)^[mul(289,78)$how(287,947)mul(337,811)why()''-what()[/when(370,472)from()>mul(865,636){#mul(524,198)why(714,875)!*%mul(181,23)^)why()?:what(630,704)+}mul(569,165);when()')where(597,70):$where()why(),mul(15,411)* ) &don't()mul(124,709)$;/[+select()({mul(50,277))*;+*<#do()!@mul~mul(19,630),,,*+{mul(404,379)mul(72,663)when()don't()where(221,302)from()^>mul(942,445)+^from()]from()*{)mul(83,601)-+what(): where()what()from(),mulwhy()where(856,731)&/+mul(777,574)!+when()don't()*^mul(680,66)how()$mul(361,449):,how(766,248)#}&}[mul(869,603);;where()what()mul(385,816)[!' <-~from();mul(298,605*from()^mul(573,375)when()@(where()%mul(871,907)mul(718,918)?mul/~ ~what()-!select()~do()why():mul(682why()]mul(585,886)(,?+*?%!mul(684,834)what(786,470)mul(443,590))where(228,285) !/%?mul(815,879)#!/usr/bin/perl@mul(444,941)$select(687,764)%'(where()>-/mul(180,328) -[/:@how()*what()!+mul(911,368)?/what()~(+]mul(843?$,who()mul(865,234)@]/-from()mul(397,906)^mul(806,349)]how()where()^)+%select()when()~mul(827,131)]don't()@+/mul(44,818)[,<,mul(295,441)what()/select()]^mul(756,90) [mul(67,416){mul(230,994)select()how()who()/mul(66,226);<~!when()mul(325,467),mul(6,370)mul(619,21)~mul(699,668))^:mul(755,644)<%?#)mul(46,923!mul(730,880)]~]how()-why()'&mul(952,543)from()>!-mul(123,880){(mul(555,437)*mul(692,73)&*when()~>mul(465,602)(mul(471,204){%from();don't()$mul(945,735)from()select(520,626)>@who()]who()mul(615,73)):(;^^when(793,925)*&do(){mul(431,683)*+#select()where()from()?+mul(254,617)#%where()>;%don't()$who()#how()^[how()why()*mul(907where()select()(!:'!?@mul(208,995)}/:when()how(415,229)^-'from()mul;mul(22,79),']^?(mul(583,536):mul(355/-where()?~%,mul(990,358)//+&how() do()?who()%!}]mul(603,599)@mul(285,652){&@@mul(808,857when()when()%select()/'$@mul(585,541)from()@mul(136*#from()@mul(710,522) #*when()*}/mul(801,485) >/mul(393,477)where()(mul(13,599)what()when()(*%>@?];mul(808,562)>mul(407,85)mul(244/$&!+where()mul(67,663)-mul(934,570)]mul(857,473)who()mul(585,495)where()mul(45,904)!when()where())-:mul(747,283)why()#where();what()how(){'from()mul(405,574)[,?what()why()-([mul}where()select(450,140) /@who():@who(),>~mul(104,734)$]#-#who()mul(760,886)what()&where(352,510)->(don't()mul(863,264)$<)where()*/(@'mul(756,795)^)]mul(278,155):&!%$select()mul(189,750)[$#-/mul(549,580))^how(152,70):$mul(28,530)-],;]mul(33,157);!/+?what(253,786)%what()mul(841,40)+&when()why()^mul(898,936)!])mul(891,523);>mul(312,16)@how()*where()'where()<@?mul(967,420)/}why()~,mul(581,636)/ [mul(673,139)who()>mul(578,980):,%mul(75,107)+)how()-mul:/where()why()mul(315,687)!{%'what()mul(110,111)+ #:%!mul(731,760) -(+&mul(887,468)$::)],mul(765,973)'from()from()*mul(810,344)?what()mul(768,468)~'+)select()where()(select()where()$mul(576,358)%??'mul(41,789how()when()&-mul(606,191)!when()'~mul]]how():;~{how()mul(15,34)>%%*^how(54,122)$@mul(739,223)how()~*@!don't()]:{~'@>why()-]&how() **;}mul(900,428)select()]$'mul(874,363)what()@mul(892,45)^*+mul(387,178)?mul(823,845){where()mul(854,982);;/how()-why()mul(899,363)[where()who()what()>$]['do()<'how())mul(201,507)select(): >select()select()what()/where()*do()}@when(392,773)?mul(231,610){- why()*from()when():select():mul(334,751)from()how()~+who()-mul(811,647){^mul(116,805)^where()@}mul(691,631) when()&%from(),@^mul(336,461) ,what())who()when(540,382)'mul(549,430)%]from())@mul(339,808)?mul(264,497)'when()what()~who()~@how()$+mul(965,916)('who())%~from()from()%mul(776,506)/select()mul(385,184)*##select()mul(691,451)]$$mul(303,437);!when()&/<>]^mul(524,315)#^)mul(42,992who()}&-select()mul(902,182)(!''where()'+mul(48,755)@~what(644,7)$select()&%who()-mul(629,650)!^mul(822,985){/select()why()where()!who()%%mul(102,630)why()-{don't(),mul(166,527)'where()mul(245,921)select()-select()mul~>select()'%who()<+,mul(795,941))%$,what()where()>mul(414,585)from(26,999){mul(293,208)when()?#?mul(99,672)why()(select()+]when()mul(300,836)[}where()/mul(425,328))mul(702,532)?#(mul(45,856) ]/$mul(220,616)^when(){^* ?where():,mul(931,398)$;-mul(471,783)why(){:who()what()]>mul(276,590)select()when() /$(^<'mul+*&do()&)>;mul(785,175)mul(131,573),]from():(mul(833,970)! ><<(mul(496,285)&from()~select(){mul(296,374)?[#&from()from(){{when() mul(718,993)@who()&>mul(639,708)why()where()/-<{[ how()&mul(187,633)#:]:?mul(872,562)/who()[-who()(>$%}don't()!{:*mul(82,739)select()]+ ?$?@when()mul(830,429)+;:$>mul(390,30)(&@%&'} {%mul(208,444)mul(854,207);:@where(774,785)mul(120,222)mul(885,372)$ '<[mul(476,77)select()from()mul(305,758)}#[>;,@where()~how()(why(){mul(2,348)%@(~}how():mul(148,153)where()^:'why(907,374)+]mul(375,986);{]where()(!@what()]:mul(254,345))*)where()select()@?^#what()mul(94?what()!@when()select(),$?select()mul(966,420)select()/+{[;!(>what()mul(688,942)&]'^)'#!mul(363,573):$,from()select()mul(260,171)#mul(116,728)'(?mul(51,309)[!^mul(400,128))select()$-^how(740,875)where()@from()mul(319,269)select(844,13)who()#/mul(431,542)mul(794,709)- who()*do()*:)select()mul(12,579)@%])[what()&/mul(361,146)why()>:'-^&;mul(465,576))select()@%mul(101,476)who()%}' [#mul(13,38);:how()from()from()#}#&-mul(30,350)what()/+select()+]don't()!#:@;,[when()mul(303,869)when()where()]/'^!^ mul(938,614) {who()?!what(363,886)mul(439,873)>who()what()-+when()where()[why()mul?from()what()> where()who()!mul(510,226) {how()mul(353,498)]select()why()?[why()'*}(mul(709,649)~?select()*($>[from()mul(144,790)!%!mul(653,286)[<$)*+from()what(),from()mul(373,21))] select()?;+mul(601,965)what(), ,:mul(970,654)~why()(~*<+&mul(19,700)what()$what() <{({,)'how()-@mul(629,950)how()when()who()what(623,556)mul(891,30)(!don't()>who()who()%+ [)when()mul(808,962)+?<({~$#+do()}what()how()(what()*-@mul(296,108)>]^+&mul(592,463)~['%%& mul(733,447),#how()where()select()how()who()>mul(496,360)(&%*{+what()!mul(615,52)#&*,mul(807,92)&]mul(544,513){/+who(868,321)from()mul(164,401)how()][%what()where()(+[>mul(815,703)from()(when(),*select() {what()mul(437,310)who(226,447)mul(45,389)#&who()*[mul(659,114))what()#:+[%mul(686,605)<',,{who()^@-mul(127,293)& ;@mul(608,869)?%+*select(74,799)who()when()/^select()don't()where()$why()>why()when()%mul(752,203)-}'{^#;[%^mul(307,633)%when(970,30)mul(265,251)what(42,790)#mul(188,777)<:*& when():/when()?mul(94,809)mul(621,327)+;/*,,[select();~do()^(when()mul(896,407),$mul(280,745)*:){^~:({where(796,413)mul(262,847)why()&& -#include -#include - -#include "aoc.hpp" -#include "ctre.hpp" - -namespace aoc24 { -auto entry([[maybe_unused]]std::span const& args) -> std::expected { - using namespace aoc::types; - - u32 day = 1; - if (args.size() > 1) { - if (ctre::match<"^[0-9]+$">(args[1])) - day = u32(std::stoul(args[1])); - else - fmt::print(stderr, "arg: {} is not a number\n", args[1]); - } - - switch (day) { - case 1: return day01(args); - // case 2: return day02(args); - case 3: return day03(args); - // case 4: return day04(args); - case 5: return day05(args); - case 6: return day06(args); - // case 7: return day07(args); - case 8: return day08(args); - case 9: return day09(args); - case 10: return day10(args); - // case 11: return day11(args); - case 14: return day14(args); - // case 16: return day16(args); - case 17: return day17(args); - default: - return aoc::make_error(fmt::format("day {}", day), std::errc::not_supported); - } - - return {}; -} -} diff --git a/sol/24/aoc.hpp b/sol/24/aoc.hpp deleted file mode 100644 index 5cbad54..0000000 --- a/sol/24/aoc.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef SOL_24_AOC_HPP -#define SOL_24_AOC_HPP - -#include -#include -#include "aoc/utils.hpp" - -#include "fmt/format.h" - -namespace aoc24 { -auto entry(std::span const& args) -> std::expected; - -auto day01(std::span const& args) -> std::expected; -auto day02(std::span const& args) -> std::expected; -auto day03(std::span const& args) -> std::expected; -auto day04(std::span const& args) -> std::expected; -auto day05(std::span const& args) -> std::expected; -auto day06(std::span const& args) -> std::expected; -auto day07(std::span const& args) -> std::expected; -auto day08(std::span const& args) -> std::expected; -auto day09(std::span const& args) -> std::expected; -auto day10(std::span const& args) -> std::expected; -auto day11(std::span const& args) -> std::expected; -auto day12(std::span const& args) -> std::expected; -auto day13(std::span const& args) -> std::expected; -auto day14(std::span const& args) -> std::expected; -auto day15(std::span const& args) -> std::expected; -auto day16(std::span const& args) -> std::expected; -auto day17(std::span const& args) -> std::expected; -auto day18(std::span const& args) -> std::expected; -auto day19(std::span const& args) -> std::expected; -auto day20(std::span const& args) -> std::expected; -auto day21(std::span const& args) -> std::expected; -auto day22(std::span const& args) -> std::expected; -auto day23(std::span const& args) -> std::expected; -auto day24(std::span const& args) -> std::expected; -auto day25(std::span const& args) -> std::expected; -} - -#endif diff --git a/sol/24/day01.cpp b/sol/24/day01.cpp deleted file mode 100644 index de146cc..0000000 --- a/sol/24/day01.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -auto aoc24::day01([[maybe_unused]]std::span const& args) -> std::expected { - constexpr auto filename = "./dat/24/re/01.txt"; - std::ifstream strm{filename, std::ios::in}; - if (!strm.is_open()) { - return aoc::make_error( - fmt::format("Error opening file: {}\n", filename), - std::errc::file_exists - ); - } - - std::vector a{}; - std::vector b{}; - - std::string str{}; - while (strm) { - auto const c = char(strm.peek()); - if (std::isdigit(c)) { - str += char(strm.get()); - continue; - } - if (c == ' ') { - if (!str.empty()) { - a.emplace_back(std::stoi(str)); - str.clear(); - } - } - if (c == '\n') { - if (!str.empty()) { - b.emplace_back(std::stoi(str)); - str.clear(); - } - } - [[discard]]strm.get(); - } - - fmt::print("a: {}, b: {}\n", a.size(), b.size()); - - std::sort(std::begin(a), std::end(a)); - std::sort(std::begin(b), std::end(b)); - - auto diff_view = std::views::zip(a, b) | std::views::transform([](auto const& p) { - auto const [x, y] = p; - return x > y ? x - y : y - x; - }); - auto const sum = std::accumulate(std::begin(diff_view), std::end(diff_view), 0); - - fmt::print("Part A: {}\n", std::abs(sum)); - - auto values = a | std::views::transform([&b](auto v) { - return std::pair{v, b | std::views::filter([v](auto c) { - return v == c; // Filter elements in `b` equal to `v` - }) | std::ranges::to()}; - }) | std::ranges::to(); - - auto const meow = std::accumulate(std::begin(values), std::end(values), 0, [](auto const acc, auto const& pair) { - return acc + std::int32_t(pair.first * pair.second.size()); - }); - - fmt::print("Part B: {}\n", meow); - return {}; -} diff --git a/sol/24/day02.cpp b/sol/24/day02.cpp deleted file mode 100644 index 60f8ee4..0000000 --- a/sol/24/day02.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace std::string_view_literals; -using namespace aoc::types; - -auto part_a(std::vector> const& reports) -> void { - auto const diffvec = reports | std::views::transform([](auto const& levels) { - return levels | std::views::adjacent_transform<2>([](auto const& a, auto const& b) { - return b - a; - }) | std::ranges::to(); - }) | std::ranges::to(); - - auto answer = diffvec | std::views::filter([](auto const& levels) { - auto const n = std::ranges::all_of(levels, [](auto v) { return v < 0; }); - auto const p = std::ranges::all_of(levels, [](auto v) { return v > 0; }); - auto const c = std::ranges::all_of(levels, [](auto v) { return std::abs(v) > 0 && std::abs(v) <= 3; }); - return (n || p) && c; - }); - - auto const sum = std::ranges::distance(answer); - fmt::print("Part A: {}\n", sum); - -} - -auto part_b(std::vector> const& reports) -> void { - auto const diffvec = reports | std::views::transform([](auto const& levels) { - return levels | std::views::adjacent_transform<2>([](auto const& a, auto const& b) { - return b - a; - }) | std::ranges::to(); - }) | std::ranges::to(); - - auto const test_rule = [](std::vector const& levels) { - auto const n = std::ranges::all_of(levels, [](auto v) { return v < 0; }); - auto const p = std::ranges::all_of(levels, [](auto v) { return v > 0; }); - auto const c = std::ranges::all_of(levels, [](auto v) { return std::abs(v) > 0 && std::abs(v) <= 3; }); - return (n || p) && c; - }; - - auto nochange = diffvec | std::views::filter(test_rule); - - auto unmet = std::views::zip(reports, diffvec) | std::views::filter([](auto const& vecs) { - auto const& [levels, diffs] = vecs; - auto const n = std::ranges::all_of(diffs, [](auto v) { return v < 0; }); - auto const p = std::ranges::all_of(diffs, [](auto v) { return v > 0; }); - auto const c = std::ranges::all_of(diffs, [](auto v) { return std::abs(v) > 0 && std::abs(v) <= 3; }); - return !(n || p) || !c; - }) | std::views::transform([](auto const& vecs) { - auto const& [levels, diffs] = vecs; - return levels; - }); - - auto refit = unmet | std::views::filter([&test_rule](auto const& levels) { - std::vector vec{}; - for (std::size_t i = 0; i < levels.size(); ++i) { - vec = levels; - vec.erase(std::begin(vec) + std::ptrdiff_t(i)); - vec = vec - | std::views::adjacent_transform<2>([](auto const& a, auto const& b) { return b - a; }) - | std::ranges::to(); - if (test_rule(vec)) return true; - } - return false; - }); - - auto const first = std::ranges::distance(nochange); - auto const second = std::ranges::distance(refit); - - fmt::print("Part B: {}\n", first + second); - -} - -auto aoc24::day02([[maybe_unused]]std::span const& args) -> std::expected { - auto txtres = aoc::read_text("./dat/24/re/02.txt"); - // auto txtres = aoc::read_text("./dat/24/ex/02.txt"); - if (!txtres) return std::unexpected(txtres.error()); - auto const txt = *txtres; - - auto const reports = txt | std::views::split("\n"sv) - | std::views::transform([](auto const& str) { return std::string_view(str); }) - | std::views::filter([](auto const& str) { return !str.empty(); }) - | std::views::transform([](auto const& str) { - return str | std::views::split(" "sv) - | std::views::filter([](auto str) { return !str.empty(); }) - | std::views::transform([](auto const& num_str) { - return std::stoi(std::string(std::begin(num_str), std::end(num_str))); - }) - | std::ranges::to(); - }) | std::ranges::to(); - - part_a(reports); - part_b(reports); - - return {}; -} diff --git a/sol/24/day03.cpp b/sol/24/day03.cpp deleted file mode 100644 index 31836c6..0000000 --- a/sol/24/day03.cpp +++ /dev/null @@ -1,445 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" -#include "ctre.hpp" - -namespace npr { -#define ENUMERATOR_AOC_TOKENS \ - ENUMERATOR_AOC_TOKEN(mul , operator_ ) \ - ENUMERATOR_AOC_TOKEN(invalid , invalid ) \ - ENUMERATOR_AOC_TOKEN(numeric_literal, number ) \ - ENUMERATOR_AOC_TOKEN(newline , punctuation) \ - ENUMERATOR_AOC_TOKEN(paren_open , punctuation) \ - ENUMERATOR_AOC_TOKEN(paren_close , punctuation) \ - ENUMERATOR_AOC_TOKEN(comma , punctuation) \ - ENUMERATOR_AOC_TOKEN(identifier , identifier ) - -#define ENUMERATOR_AOC_CATEGORIES \ - ENUMERATOR_AOC_CATEGORY(operator_) \ - ENUMERATOR_AOC_CATEGORY(invalid) \ - ENUMERATOR_AOC_CATEGORY(number) \ - ENUMERATOR_AOC_CATEGORY(punctuation) \ - ENUMERATOR_AOC_CATEGORY(identifier) - -#define ENUMERATOR_AOC_NODE_TYPES \ - ENUMERATOR_AOC_NODE_TYPE(numeric_literal) \ - ENUMERATOR_AOC_NODE_TYPE(call_expression) \ - ENUMERATOR_AOC_NODE_TYPE(binary_expression) - -enum class token_type : std::uint32_t { -#define ENUMERATOR_AOC_TOKEN(type, category) type, - ENUMERATOR_AOC_TOKENS -#undef ENUMERATOR_AOC_TOKEN - _count -}; - -enum class token_category : std::uint32_t { -#define ENUMERATOR_AOC_CATEGORY(type) type, - ENUMERATOR_AOC_CATEGORIES -#undef ENUMERATOR_AOC_CATEGORY - _count -}; - -enum class node_type : std::uint32_t { -#define ENUMERATOR_AOC_NODE_TYPE(type) type, - ENUMERATOR_AOC_NODE_TYPES -#undef ENUMERATOR_AOC_NODE_TYPE - _count -}; - -auto token_type_str(token_type type) -> char const* { - switch (type) { - using enum token_type; -#define ENUMERATOR_AOC_TOKEN(type, category) case type: return #type; - ENUMERATOR_AOC_TOKENS -#undef ENUMERATOR_AOC_TOKEN - default: return "invalid"; - } -} - -auto token_type_category(token_type type) -> token_category { - switch (type) { - using enum token_category; -#define ENUMERATOR_AOC_TOKEN(type, category) case token_type::type: return category; - ENUMERATOR_AOC_TOKENS -#undef ENUMERATOR_AOC_TOKEN - default: return token_category::invalid; - } -} - -auto node_type_str(node_type type) -> char const* { - switch (type) { - using enum node_type; -#define ENUMERATOR_AOC_NODE_TYPE(type) case type: return #type; - ENUMERATOR_AOC_NODE_TYPES -#undef ENUMERATOR_AOC_NODE_TYPE - default: return "invalid"; - } -} - -class token { -public: - token(std::string const& str, token_type type, token_category category, std::size_t row, std::size_t col) - : m_type(type) - , m_category(category) - , m_value(str) - , m_row(row) - , m_column(col) { } - - auto type() const -> token_type { return m_type; } - auto category() const -> token_category { return m_category; } - auto value() const -> std::string const& { return m_value; } - - auto row() const -> std::size_t { return m_row; } - auto col() const -> std::size_t { return m_column; } - - auto str() const -> std::string { - using namespace std::string_literals; - std::string str{"token {"}; - str += " value: \""s + m_value + "\","s; - str += " type: "s + token_type_str(m_type) + ","s; - str += " row: "s + std::to_string(m_row) + ","s; - str += " col: "s + std::to_string(m_column); - str += " }"; - return str; - } - -public: - inline static auto is_identifier(std::string_view const& str) -> bool { - return ctre::match<"^[a-z']+$">(str); - } - - inline static auto is_numeric_literal(std::string_view const& str) -> bool { - return ctre::match<"^[0-9]+$">(str); - } - -private: - token_type m_type; - token_category m_category; - std::string m_value; - std::size_t m_row; - std::size_t m_column; -}; - -enum class lexer_error { - eof, - unknown -}; - -class lexer { -public: - lexer(std::string const& source) - : m_strm(source, std::ios::in | std::ios::binary) - , m_line(1), m_col(1) { - } - - auto tokenize() -> std::vector { - std::vector tokens{}; - auto tk = next_token(); - while (tk) { - tokens.emplace_back(std::move(tk.value())); - tk = next_token(); - } - return tokens; - } - -private: - auto next_token() -> std::optional { - if (!has_next()) return {}; - std::string str{}; - auto const col = m_col; - - if (peek() == '\n') { - peek_consume(); - m_line = m_line + 1; - str += "\\n"; - m_col = 1; - auto const& type = token_type::invalid; - return token(str, type, token_type_category(type), m_line, col); - } - - // mul, do, don't identifier - if (peek() == 'm' || peek() == 'd') { - auto const is_valid_identifier_char = [](auto const c) { - return (c >= 'a' && c <= 'z') || c == '\''; - }; - while (is_valid_identifier_char(peek())) str += peek_consume(); - auto const check_type = [](auto const str) { - if (!token::is_identifier(str)) return token_type::invalid; - return token_type::identifier; - }; - auto const& type = check_type(str); - return token(str, type, token_type_category(type), m_line, col); - } - - if (peek() == '(') { - str += peek_consume(); - return token{ - str, - token_type::paren_open, - token_type_category(token_type::paren_open), - m_line, - col - }; - } - - if (peek() == ')') { - str += peek_consume(); - return token{ - str, - token_type::paren_close, - token_type_category(token_type::paren_close), - m_line, - col - }; - } - - if (peek() == ',') { - str += peek_consume(); - return token{ - str, - token_type::comma, - token_type_category(token_type::comma), - m_line, - col - }; - } - - if (std::isdigit(peek())) { - while(std::isdigit(peek())) str += peek_consume(); - auto const& type = token::is_numeric_literal(str) ? token_type::numeric_literal : token_type::invalid; - return token(str, type, token_type_category(type), m_line, col); - } - - if (!has_next()) return {}; - - str += peek_consume(); - return token{ - str, - token_type::invalid, - token_type_category(token_type::invalid), - m_line, - col - }; - } - - auto peek() -> char { - return static_cast(m_strm.peek()); - } - auto peek_consume() -> char { - ++m_col; - return static_cast(m_strm.get()); - } - auto has_next() const -> bool { - return !m_strm.eof() && m_strm.good(); - } - -private: - std::fstream m_strm; - std::size_t m_line; - std::size_t m_col; -}; - -class node { -public: - node(node_type type, - token const& token, - std::vector const& nodes = {}) - : m_type(type) - , m_token(token) - , m_nodes(nodes) { } - - auto type() const -> node_type { return m_type; } - auto token() const -> npr::token const& { return m_token; } - auto nodes() const -> std::vector const& { return m_nodes; } - auto value() const -> std::string const& { return m_token.value(); } - - auto add_node(npr::node const& node) -> void { - m_nodes.push_back(node); - } - - auto str() const -> std::string { - using namespace std::string_literals; - std::string str{node_type_str(m_type) + " {"s}; - str += " value: "s + m_token.value(); - switch (m_type) { - case node_type::call_expression: - str += call_expression_str(); - break; - default: break; - } - str += " }"; - return str; - } - -private: - auto call_expression_str() const -> std::string { - if (m_nodes.size() == 0) return ""; - using namespace std::string_literals; - std::string str{", ["}; - for (std::size_t i = 0; i < m_nodes.size(); ++i) { - str += " "s + std::to_string(i) + ": "s + m_nodes[i].str(); - if (i < m_nodes.size() - 1) str += ","; - } - str += " ]"; - return str; - } - -private: - node_type m_type; - npr::token m_token; - std::vector m_nodes; -}; - -class parser { -public: - parser() : m_cursor(0), m_tokens() { } - - auto parse(std::vector const& tokens) -> std::vector { - m_cursor = 0; - m_tokens = tokens; - - std::vector nodes{}; - do { - auto n = parse_statement(); - if (n.has_value()) nodes.push_back(n.value()); - } while(has_next()); - - return nodes; - } - -private: - auto parse_statement() -> std::optional { - auto const type = peek().type(); - - switch (type) { - case token_type::identifier: { - if (!has_next()) return {}; - auto next = peek_next(); - if (next.type() == token_type::paren_open) { - return parse_call_expression(); - } - } - default: - break; - } - - consume(); - return {}; - } - - auto parse_call_expression() -> std::optional { - auto const& token_callee = peek(); - node callee{node_type::call_expression, token_callee}; - consume(); - return parse_args(callee); - } - - auto parse_args(npr::node callee) -> std::optional { - if (peek().type() != token_type::paren_open) return {}; - consume(); - while (has_next()) { - auto const& arg_token = peek(); - if (arg_token.type() == token_type::numeric_literal) { - callee.add_node({node_type::numeric_literal, arg_token}); - consume(); - continue; - } - if (arg_token.type() == token_type::comma) { - consume(); - continue; - } - if (arg_token.type() == token_type::paren_close) { - consume(); - break; - } - return {}; - } - return callee; - } - -private: - auto peek() const -> token const& { - return m_tokens[m_cursor]; - } - - auto peek_next() const -> token const& { - return m_tokens[m_cursor + 1]; - } - - auto consume() -> void { - if (m_cursor >= m_tokens.size()) return; - ++m_cursor; - } - - auto has_next(std::size_t i = 0) const -> bool { - return m_cursor + i < m_tokens.size(); - } - -private: - std::size_t m_cursor; - std::vector m_tokens; -}; -} - -auto aoc24::day03([[maybe_unused]]std::span const& args) -> std::expected { - npr::lexer lexer{"./dat/24/re/03.txt"}; - npr::parser parser{}; - auto const tokens = lexer.tokenize(); - auto const nodes = parser.parse(tokens); - - // for (auto const& token : tokens) { - // fmt::print("{}\n", token.str()); - // } - // - // for (auto const& node : nodes) { - // fmt::print("{}\n", node.str()); - // } - - auto opa = nodes | std::views::filter([](auto const& node) { - return node.value() == "mul"; - }) | std::views::transform([](auto const& node) { - auto const a = std::stoi(node.nodes()[0].value()); - auto const b = std::stoi(node.nodes()[1].value()); - return a * b; - }); - - auto const sum = std::accumulate(std::begin(opa), std::end(opa), 0); - - fmt::print("Part A: {}\n", sum); - - std::vector program{}; - bool is_do = true; - for (auto const& node : nodes) { - if (node.value() == "do") { - is_do = true; - continue; - } - if (node.value() == "don't") { - is_do = false; - continue; - } - if (is_do) program.push_back(node); - } - - auto opb = program | std::views::filter([](auto const& node) { - return node.value() == "mul"; - }) | std::views::transform([](auto const& node) { - auto const a = std::stoi(node.nodes()[0].value()); - auto const b = std::stoi(node.nodes()[1].value()); - return a * b; - }); - - auto const sumb = std::accumulate(std::begin(opb), std::end(opb), 0); - - fmt::print("Part B: {}\n", sumb); - return {}; -} - diff --git a/sol/24/day04.cpp b/sol/24/day04.cpp deleted file mode 100644 index 4d088fb..0000000 --- a/sol/24/day04.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" -#include "ctre.hpp" - -namespace cms { -using vecn = std::vector; -using matnxn = std::vector; - -auto read_text_matnxn(std::string const& path) -> matnxn { - std::ifstream strm{path}; - if (!strm.is_open()) - throw std::runtime_error(fmt::format("Failed to open file {}", path)); - - matnxn text{}; - vecn cols{}; - while (!strm.eof()) { - auto const c = static_cast(strm.peek()); - if (c == '\n') - text.emplace_back(std::move(cols)); - else - cols.push_back(c); - strm.get(); - } - - return text; -} -} - -auto part_a(cms::matnxn const& mat) -> void { - std::vector pattern{'X', 'M', 'A', 'S'}; - - aoc::i32 hc = 0; - aoc::i32 vc = 0; - aoc::i32 xc = 0; - - for (std::size_t i = 0; i < mat.size(); ++i) { - auto const& cols = mat[i]; - - auto hview = cols | std::views::slide(4) - | std::views::filter([&](auto const& str) { - auto const a = std::ranges::all_of( - std::views::zip(pattern, str), [](auto const& z) { - return std::get<0>(z) == std::get<1>(z); - }); - auto const b = std::ranges::all_of( - std::views::zip(std::views::reverse(pattern), str), - [](auto const& z) { - return std::get<0>(z) == std::get<1>(z); - }); - return a || b; - }); - hc += std::ranges::distance(hview); - - for (std::size_t j = 0; j < cols.size(); ++j) { - // Vertical pattern - bool is_v_match = true; - bool is_rv_match = true; - for (std::size_t y = 0; y < pattern.size(); ++y) { - if (i + y >= mat.size()) { - is_v_match = false; - is_rv_match = false; - break; - } - if (is_v_match) - is_v_match = mat[i + y][j] == pattern[y]; - if (is_rv_match) - is_rv_match = mat[i + y][j] == pattern[pattern.size() - y - 1]; - } - - vc += is_v_match ? 1 : 0; - vc += is_rv_match ? 1 : 0; - - bool is_dr_match = true; - bool is_drr_match = true; - for (std::size_t x = 0; x < pattern.size(); ++x) { - if (i + x >= mat.size() || j + x >= cols.size()) { - is_dr_match = false; - is_drr_match = false; - break; - } - - if (is_dr_match) - is_dr_match = mat[i + x][j + x] == pattern[x]; - if (is_drr_match) - is_drr_match = mat[i + x][j + x] == pattern[pattern.size() - x - 1]; - } - - xc += is_dr_match ? 1 : 0; - xc += is_drr_match ? 1 : 0; - - bool is_dl_match = true; - bool is_dlr_match = true; - for (std::size_t x = 0; x < pattern.size(); ++x) { - if (i + x >= mat.size() || j + pattern.size() - 1 >= cols.size()) { - is_dl_match = false; - is_dlr_match = false; - break; - } - - if (is_dl_match) - is_dl_match = mat[i + x][j + pattern.size() - x - 1] == pattern[x]; - if (is_dlr_match) - is_dlr_match = mat[i + x][j + pattern.size() - x - 1] == pattern[pattern.size() - x - 1]; - } - - xc += is_dl_match ? 1 : 0; - xc += is_dlr_match ? 1 : 0; - } - } - - // fmt::print("{}\n", hc); - // fmt::print("{}\n", vc); - // fmt::print("{}\n", xc); - fmt::print("Part A: {}\n", hc + vc + xc); -} - -auto part_b(cms::matnxn const& mat) -> void { - std::vector pattern{'M', 'A', 'S'}; - - aoc::i32 xc = 0; - - for (std::size_t i = 0; i < mat.size(); ++i) { - auto const& cols = mat[i]; - - for (std::size_t j = 0; j < cols.size(); ++j) { - bool is_dr_match = true; - bool is_drr_match = true; - for (std::size_t x = 0; x < pattern.size(); ++x) { - if (i + x >= mat.size() || j + x >= cols.size()) { - is_dr_match = false; - is_drr_match = false; - break; - } - - if (is_dr_match) - is_dr_match = mat[i + x][j + x] == pattern[x]; - if (is_drr_match) - is_drr_match = mat[i + x][j + x] == pattern[pattern.size() - x - 1]; - } - - bool is_dl_match = true; - bool is_dlr_match = true; - for (std::size_t x = 0; x < pattern.size(); ++x) { - if (i + x >= mat.size() || j + pattern.size() - 1 >= cols.size()) { - is_dl_match = false; - is_dlr_match = false; - break; - } - - if (is_dl_match) - is_dl_match = mat[i + x][j + pattern.size() - x - 1] == pattern[x]; - if (is_dlr_match) - is_dlr_match = mat[i + x][j + pattern.size() - x - 1] == pattern[pattern.size() - x - 1]; - } - - if ((is_dr_match || is_drr_match) && (is_dl_match || is_dlr_match)) xc += 1; - } - } - - fmt::print("Part B: {}\n", xc); -} - -auto aoc24::day04([[maybe_unused]]std::span const& args) -> std::expected { - // auto mat = cms::read_text_matnxn("./dat/24/ex/04.txt"); - auto mat = cms::read_text_matnxn("./dat/24/re/04.txt"); - - part_a(mat); - part_b(mat); - - return {}; -} - diff --git a/sol/24/day05.cpp b/sol/24/day05.cpp deleted file mode 100644 index 8858706..0000000 --- a/sol/24/day05.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace aoc::types; - -auto part_a(std::vector> const& rules, - std::vector> const& updates) -> void { - // std::ranges::for_each(order_rules, [](auto const& rule) { - // std::ranges::for_each(rule, [](auto const& page) { - // fmt::print("{} ", page); - // }); - // fmt::print("\n"); - // }); - // - // std::ranges::for_each(updates, [](auto const& update) { - // std::ranges::for_each(update, [](auto const& page) { - // fmt::print("{}, ", page); - // }); - // fmt::print("\n"); - // }); - - auto valid_updates = updates | std::views::filter([&](auto const& pages) { - return std::ranges::all_of(rules, [&](auto const& rule) { - auto const a = std::ranges::find(pages, rule[0]); - auto const b = std::ranges::find(pages, rule[1]); - return a < b || a == std::end(pages) || b == std::end(pages) || a == b; - }); - }); - - // std::ranges::for_each(valid_updates, [](auto const& update){ - // std::ranges::for_each(update, [](auto const& page) { - // fmt::print("{}, ", page); - // }); - // fmt::print("\n"); - // }); - - auto mids = valid_updates | std::views::transform([](auto const& updates) { - return *std::ranges::next(std::begin(updates), updates.size() / 2); - }); - - // std::ranges::for_each(mids, [](auto const& mid) { - // fmt::print("{}\n", mid); - // }); - - auto const sum = std::accumulate(std::begin(mids), std::end(mids), 0); - fmt::print("Part A: {}\n", sum); -} - -auto part_b(std::vector> const& rules, - std::vector> const& updates) -> void { - auto valids = updates | std::views::filter([&](auto const& pages) { - return std::ranges::all_of(rules, [&](auto const& rule) { - auto const a = std::ranges::find(pages, rule[0]); - auto const b = std::ranges::find(pages, rule[1]); - return a < b || a == std::end(pages) || b == std::end(pages); - }); - }); - - auto valids_mid = valids | std::views::transform([](auto const& updates) { - return *std::ranges::next(std::begin(updates), updates.size() / 2); - }); - - auto invalids = updates | std::views::filter([&](auto const& pages) { - return !std::ranges::all_of(rules, [&](auto const& rule) { - auto const a = std::ranges::find(pages, rule[0]); - auto const b = std::ranges::find(pages, rule[1]); - return a < b || a == std::end(pages) || b == std::end(pages); - }); - }); - - auto invalid_rules = rules | std::views::filter([&](auto const& rule) { - return !std::ranges::all_of(invalids, [&](auto const& pages) { - auto const a = std::ranges::find(pages, rule[0]); - auto const b = std::ranges::find(pages, rule[1]); - return a < b || a == std::end(pages) || b == std::end(pages); - }); - }); - - auto const a = std::accumulate(std::begin(valids_mid), std::end(valids_mid), 0); - (void)a; - - // std::ranges::for_each(valids, [](auto const& update){ - // std::ranges::for_each(update, [](auto const& page) { - // fmt::print("{}, ", page); - // }); - // fmt::print("\n"); - // }); - // fmt::print("--------------------------------------------------------------------------------\n"); - - std::ranges::for_each(invalid_rules, [](auto const& rules){ - std::ranges::for_each(rules, [](auto const& rule) { - fmt::print("{} ", rule); - }); - fmt::print("\n"); - }); - - std::ranges::for_each(invalids, [](auto const& update){ - std::ranges::for_each(update, [](auto const& page) { - fmt::print("{}, ", page); - }); - fmt::print("\n"); - }); -} - -auto aoc24::day05([[maybe_unused]]std::span const& args) -> std::expected { - using namespace std::string_view_literals; - auto txtres = aoc::read_text("./dat/24/ex/05.txt"); - // auto txtres = aoc::read_text("./dat/24/re/05.txt"); - if (!txtres) return std::unexpected(txtres.error()); - auto const txt = *txtres; - - auto const not_empty = [](auto const& str) { return !str.empty(); }; - auto lines = txt | std::views::split("\n"sv) - | std::views::transform([](auto const& str) { return std::string_view(str); }); - - auto rules_str = lines | std::views::take_while(not_empty) - | std::ranges::to(); - auto updates_str = lines | std::views::drop_while(not_empty) - | std::views::drop(1) - | std::views::take_while(not_empty) - | std::ranges::to(); - - // fmt::print("rules:\n"); - // std::ranges::for_each(rules_str, [](auto const& str) { - // fmt::print(" \"{}\"\n", str); - // }); - // fmt::print("\n"); - // - // fmt::print("updates:\n"); - // std::ranges::for_each(updates_str, [](auto const& str) { - // fmt::print(" \"{}\"\n", str); - // }); - - auto order_rules = rules_str | std::views::transform([](auto const& str) { - return str | std::views::split("|"sv) - | std::views::transform([](auto const& num_str) { - return std::stoi(std::string{std::begin(num_str), std::end(num_str)}); - }) | std::ranges::to(); - }) | std::ranges::to(); - - auto updates = updates_str | std::views::transform([](auto const& str) { - return str | std::views::split(","sv) - | std::views::transform([](auto const& num_str) { - return std::stoi(std::string{std::begin(num_str), std::end(num_str)}); - }) | std::ranges::to(); - }) | std::ranges::to(); - - part_a(order_rules, updates); - part_b(order_rules, updates); - - return {}; -} diff --git a/sol/24/day06.cpp b/sol/24/day06.cpp deleted file mode 100644 index b0c1448..0000000 --- a/sol/24/day06.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace std::string_view_literals; -using namespace aoc::types; - -namespace lab { - -class guard { -public: - guard(i64 x, i64 y) : m_row(y), m_col(x) { } - - auto set_direction(i64 x, i64 y) -> void { - m_dx = x; - m_dy = y; - } - auto set_dx(i64 x) -> void { m_dx = x; } - auto set_dy(i64 y) -> void { m_dy = y; } - auto set_x(i64 v) -> void { m_col = v; } - auto set_y(i64 v) -> void { m_row = v; } - auto x() const -> i64 { return m_col; } - auto y() const -> i64 { return m_row; } - auto dx() const -> i64 { return m_dx; } - auto dy() const -> i64 { return m_dy; } - - auto move() -> void { - m_row += m_dy; - m_col += m_dx; - } - -private: - i64 m_row; - i64 m_col; - i64 m_dx; - i64 m_dy; -}; - -class lab { -public: - lab(std::string const& map_str) { - auto const lines = map_str - | std::views::split("\n"sv) - | std::views::transform([](auto const& str) { - return std::string_view(std::begin(str), std::end(str)); - }) - | std::views::filter([](auto const& str) { return !str.empty(); }) - | std::views::transform([](auto const& str) { - return str | std::views::filter([](auto const& ch) { return ch != '\n'; }) - | std::ranges::to(); - }) | std::ranges::to(); - - m_rows = lines.size(); - m_cols = lines[0].size(); - std::ranges::for_each(lines, [&](auto const& str) { - std::ranges::for_each(str, [&](auto const& ch) { - m_data.emplace_back(ch); - }); - }); - - auto it = std::find_if(std::begin(m_data), std::end(m_data), [](auto const ch) { return ch == '^'; }); - if (it != std::end(m_data)) m_start.set_direction(0, -1); - - auto const dist = usize(it - std::begin(m_data)); - m_start.set_x(i64(dist - (dist / m_cols * m_rows))); - m_start.set_y(i64(dist / m_cols)); - } - - auto start() const -> guard { return m_start; } - auto rows() const -> usize { return m_rows; } - auto cols() const -> usize { return m_cols; } - - auto is_obstruction(usize x, usize y) const -> bool { - if (x >= m_cols || y >= m_rows) return false; - return m_data[y * m_cols + x] == '#'; - } - - auto is_obstruction(guard const& g) const -> bool { - return is_obstruction(usize(g.x()), usize(g.y())); - } - - auto is_outside(usize x, usize y) const -> bool { - return x >= m_cols || y >= m_rows; - } - - auto is_outside(guard const& g) const -> bool { - return is_outside(usize(g.x()), usize(g.y())); - } - -private: - usize m_rows{}; - usize m_cols{}; - std::vector m_data{}; - guard m_start{0, 0}; -}; -} - -auto part_a(lab::lab const& map) -> void { - // for (usize i = 0; i < map.rows; ++i) { - // for (usize j = 0; j < map.cols; ++j) { - // fmt::print("{} ", c8(map.data[i * map.cols + j])); - // } - // fmt::print("\n"); - // } - std::vector cpy{}; - cpy.resize(map.rows() * map.cols()); - std::fill(std::begin(cpy), std::end(cpy), 0); - - auto guard = map.start(); - - while (!map.is_outside(guard)) { - cpy[usize(guard.y()) * map.cols() + usize(guard.x())] = 1; - lab::guard guard_cpy = guard; - guard_cpy.move(); - - if (map.is_obstruction(guard_cpy)) { - if (guard_cpy.dy() == -1) - guard.set_direction(1, 0); - else if (guard_cpy.dy() == 1) - guard.set_direction(-1, 0); - else if (guard_cpy.dx() == -1) - guard.set_direction(0, -1); - else if (guard_cpy.dx() == 1) - guard.set_direction(0, 1); - } - guard.move(); - } - - auto const sum = std::accumulate(std::begin(cpy), std::end(cpy), 0); - fmt::print("Part A: {}\n", sum); -} - -auto aoc24::day06([[maybe_unused]]std::span const& args) -> std::expected { - auto res = aoc::read_text("./dat/24/re/06.txt"); - if (!res) return std::unexpected(res.error()); - auto const map_txt = *res; - - lab::lab map{map_txt}; - part_a(map); - - return {}; -} diff --git a/sol/24/day07.cpp b/sol/24/day07.cpp deleted file mode 100644 index 7b4a842..0000000 --- a/sol/24/day07.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace aoc::types; -using namespace std::string_view_literals; - -namespace rbr { -enum class op { - add, - mul, - cat, -}; - -auto op_to_str(rbr::op value) -> char const* { - switch(value) { - case op::add: return "+"; - case op::mul: return "*"; - case op::cat: return "||"; - default: return "none"; - } -} - -class expr { -public: - expr(u64 eres, std::vector const& operands) - : m_eres(eres), m_operands(operands) { - find_res(); - } - - auto find_res() -> bool { - auto const max = u64(std::pow(3, m_operands.size())); - for (u64 t = 0; t < max; ++t) { - m_ops = t; - m_res = 0; - compute(); - if (m_res == m_eres) break; - } - return m_res == m_eres; - } - auto compute() -> void { - std::vector ops{}; - for (usize i = 0; i < m_operands.size() - 1; ++i) { - auto const mode = op((m_ops >> (i * 2)) & 0x03); - if (mode == op::mul) { - ops.push_back(std::stoull(fmt::format("{}{}", m_operands[i + 0], m_operands[i + 1]))); - ++i; - m_ops = m_ops | ((m_ops & ~u64(mode)) >> 2); - continue; - } - ops.push_back(m_operands[i]); - } - - for (usize i = 0; i < ops.size(); ++i) { - if (i == 0) { - m_res = ops[0]; - continue; - } - auto const a = m_res; - auto const b = ops[i]; - auto const am = op((m_ops >> (i * 2)) & 0x03); - if (am == op::add) - m_res = a + b; - else if (am == op::mul) - m_res = a * b; - } - } - auto res() const -> u64 { return m_eres; } - auto eres() const -> u64 { return m_eres; } - auto operands() const -> std::vector const& { return m_operands; } - auto ops() const -> u64 const& { return m_ops; } - auto valid() const -> bool { return m_res == m_eres; }; - - auto str() const -> std::string { - using namespace std::string_literals; - std::string str{"expr {"}; - str += " expect: "s + std::to_string(m_eres) + ","; - str += " expr: "s; - str += std::to_string(m_res) + " = "; - for (usize i = 0; i < m_operands.size(); ++i) { - auto const& operand = m_operands[i + 0]; - str += std::to_string(operand); - if (i == m_operands.size() - 1) break; - auto const mode = op((m_ops >> (i * 2)) & 0x03); - if (mode == op::add) - str += " + "; - else if (mode == op::mul) - str += " * "; - else - str += " || "; - } - str += " }"; - return str; - } - -private: - u64 m_eres; - std::vector m_operands; - u64 m_res{0x00}; - u64 m_ops{0x00}; -}; - -auto str_to_op(std::string const& str) -> expr { - auto const splitc = str | std::views::split(": "sv) - | std::views::transform([](auto const& str){ - return std::string(std::begin(str), std::end(str)); - }) - | std::views::filter([](auto const& str) { return !str.empty(); }) - | std::ranges::to(); - - u64 const a = std::stoull(splitc[0]); - auto const b = splitc[1] | std::views::split(" "sv) - | std::views::transform([](auto const& str){ - return std::string(std::begin(str), std::end(str)); - }) - | std::views::filter([](auto const& str) { return !str.empty(); }) - | std::views::transform([](auto const& str) { return std::stoull(str); }) - | std::ranges::to(); - return {a, b}; -} -} - -auto aoc24::day07([[maybe_unused]]std::span const& args) -> std::expected { - auto res = aoc::read_text("./dat/24/ex/07.txt"); - // auto res = aoc::read_text("./dat/24/re/07.txt"); - if (!res) return std::unexpected(res.error()); - auto const txt = *res; - - u64 test = 0b1100'1100; - fmt::print("{:b}\n", test); - - test = (test & ~0b1100u) >> 2; - fmt::print("{:b}\n", test); - - // fmt::print("{}\n", rbr::op_to_str(rbr::op(test >> 2))); - - // auto exprs = txt | std::views::split("\n"sv) - // | std::views::transform([](auto const& str){ - // return std::string(std::begin(str), std::end(str)); - // }) - // | std::views::filter([](auto const& str) { return !str.empty(); }) - // | std::views::transform(rbr::str_to_op); - - // auto const valids = exprs | std::views::filter([](auto const expr) { return expr.valid(); }) - // | std::views::transform([](auto const& e) { return f64(e.eres()); }) - // | std::ranges::to(); - // - // auto const sum = std::accumulate(std::begin(valids), std::end(valids), 0.0); - - // fmt::print("{}\n", sum); - - // auto const validsex = exprs | std::views::filter([](auto const expr) { return !expr.valid(); }) - // | std::ranges::to(); - // - // for (auto const& exp : exprs) { - // fmt::print("{}\n", exp.str()); - // } - return {}; -} diff --git a/sol/24/day08.cpp b/sol/24/day08.cpp deleted file mode 100644 index c6d84e4..0000000 --- a/sol/24/day08.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -auto aoc24::day08([[maybe_unused]]std::span const& args) -> std::expected { - return aoc::make_error("", std::errc::not_supported); -} diff --git a/sol/24/day09.cpp b/sol/24/day09.cpp deleted file mode 100644 index eee089d..0000000 --- a/sol/24/day09.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace aoc::types; - -namespace dsk { -enum class format : u8 { - file, - free, -}; - -class block { -public: - block(u32 id, dsk::format format) : m_id(id), m_format(format) {} - - auto id() const -> u32 { return m_id; } - auto format() const -> dsk::format { return m_format; } - auto str() const -> std::string { - using namespace std::string_literals; - std::string str{"{"}; - auto const id = m_id == aoc::lim::max() ? "na" : std::to_string(m_id); - str += " id: "s + id + ","; - str += " type: "s + std::to_string(u32(m_format)) + ","; - str += " }"; - return str; - } - -private: - u32 m_id; - dsk::format m_format; -}; - -class page_block { -public: - page_block(u32 id, dsk::format format, u32 size) - : m_format(format), m_size(size) { - for (u32 i = 0; i < m_size; ++i) { - m_blocks.emplace_back(id, format); - } - } - - auto format() const -> dsk::format { return m_format; } - auto size() const -> u32 { return m_size; } - auto blocks() const -> std::vector const& { return m_blocks; } - - auto str() const -> std::string { - using namespace std::string_literals; - std::string str{"page_block {"}; - str += " size: "s + std::to_string(u32(m_size)) + ","; - str += " data: [ "s; - for (usize i = 0; i < m_blocks.size(); ++i) { - str += fmt::format("{}: ", i); - str += m_blocks[i].str(); - if (i < m_blocks.size() - 1) str += ", "; - else if (i == m_blocks.size() - 1) str += " "; - } - str += "]"; - str += " }"; - return str; - } - -private: - dsk::format m_format; - u32 m_size; - std::vector m_blocks{}; -}; - -class disk_map { -public: - disk_map(std::string const& input_str) { - m_pages = input_str | std::views::filter([](auto const& c) { return c != '\n'; }) - | std::views::transform( - [i = 0u, id = 0u](auto const& size_char) mutable { - auto const f = format(i++ % 2); - auto curr_id = id; - if (f == format::file) - ++id; - else - curr_id = aoc::lim::max(); - return page_block(curr_id, f, u32(size_char - '0')); - } - ) | std::ranges::to(); - } - - auto pages() const -> std::vector { - return m_pages; - } - - auto to_blocks(std::vector const& pages) const -> std::vector { - std::vector tmp{}; - for (usize i = 0; i < pages.size(); ++i) { - auto const& blocks = pages[i].blocks(); - for (usize j = 0; j < blocks.size(); ++j) { - tmp.push_back(blocks[j]); - } - } - return tmp; - } - - auto defrag_block(std::vector const& blocks) -> std::vector { - if (blocks.size() == 0) return {}; - - std::vector cpy = blocks; - usize free_index = 0; - usize file_index = cpy.size() - 1; - while (free_index < cpy.size()) { - free_index = next_free(cpy, free_index); - if (free_index >= cpy.size() - 1) break; - file_index = next_file(cpy, file_index); - if (file_index == 0) break; - - if (free_index >= file_index) break; - std::swap(cpy[free_index], cpy[file_index]); - } - return cpy; - } - - // auto defrag_page(std::vector const& pages) -> std::vector { - // if (pages.size() == 0) return {}; - // - // std::vector cpy = pages; - // usize free_index = 0; - // usize file_index = cpy.size() - 1; - // while (free_index < cpy.size()) { - // free_index = next_page_free(cpy, free_index); - // if (free_index >= cpy.size() - 1) break; - // auto const& tmp = cpy[free_index]; - // - // file_index = next_page_file(cpy, file_index, tmp.size()); - // if (file_index == 0) break; - // - // if (free_index >= file_index) break; - // - // fmt::print("{}, {}\n", file_index, free_index); - // std::swap(cpy[free_index], cpy[file_index]); - // } - // - // return cpy; - // } - - auto checksum(std::vector const& blocks) const -> u64 { - u64 sum = 0; - for (usize i = 0; i < blocks.size(); ++i) { - auto const& block = blocks[i]; - if (block.format() == format::free) break; - sum += i * block.id(); - } - return sum; - } - - auto debug_str(std::vector const& blocks) const -> std::string { - using namespace std::string_literals; - std::string str{}; - - for (usize i = 0; i < blocks.size(); ++i) { - auto const& b = blocks[i]; - if (b.format() == format::file) { - str += fmt::format("{}", b.id()); - if (b.id() > 9) str += "'"; - } else { - str += "."; - } - } - - return str; - } - - auto str() const -> std::string { - using namespace std::string_literals; - std::string str{"disk_map [\n"}; - auto const blocks = to_blocks(m_pages); - - for (usize i = 0; i < blocks.size(); ++i) { - str += " "s + blocks[i].str(); - if (i < blocks.size() - 1) - str += ",\n"; - } - str += "\n]"; - return str; - } - -private: - auto next_free(std::vector const& blocks, usize start) const -> usize { - while (start < blocks.size()) { - if (blocks[start].format() == format::free) - break; - ++start; - } - return start; - } - - auto next_file(std::vector const& blocks, usize start) const -> usize { - while (start >= 0) { - if (blocks[start].format() == format::file) - break; - --start; - } - return start; - } - - auto next_page_free(std::vector const& pages, usize start) const -> usize { - while (start < pages.size()) { - if (pages[start].format() == format::free) - break; - ++start; - } - return start; - } - - auto next_page_file(std::vector const& pages, usize start, u32 size) const -> usize { - while (start >= 0) { - if (pages[start].format() == format::file && pages[start].size() <= size) - break; - --start; - } - return start; - } - -private: - std::vector m_pages{}; -}; -} - -auto aoc24::day09([[maybe_unused]]std::span const& args) -> std::expected { - auto res = aoc::read_text("./dat/24/ex/09.txt"); - // auto res = aoc::read_text("./dat/24/re/09.txt"); - if (!res) return std::unexpected(res.error()); - auto const txt = *res; - - dsk::disk_map dsk{txt}; - fmt::print("{}\n", dsk.debug_str(dsk.to_blocks(dsk.pages()))); - auto const bl = dsk.defrag_block(dsk.to_blocks(dsk.pages())); - fmt::print("{}\n", dsk.debug_str(bl)); - fmt::print("{}\n", dsk.checksum(bl)); - - return {}; -} diff --git a/sol/24/day10.cpp b/sol/24/day10.cpp deleted file mode 100644 index a4c60bb..0000000 --- a/sol/24/day10.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace aoc::types; -using namespace std::string_view_literals; - -namespace lpf { -using edge_t = std::pair; -using edges_t = std::vector; - -class trail { -public: - trail(std::string const& str) { - auto lines = str | std::views::split("\n"sv) - | std::views::transform( - [](auto const& c_str) { - return std::string_view( - std::begin(c_str), - std::end(c_str) - ); - }) - | std::views::filter([](auto const& strv) { return !strv.empty(); }) - | std::ranges::to(); - - m_rows = lines.size(); - m_cols = std::begin(lines)->size(); - - std::ranges::for_each(lines, [&](auto const& str) { - std::ranges::for_each(str, [&](auto const& ch) { - if (std::isdigit(ch)) m_data.emplace_back(ch - '0'); - else m_data.emplace_back(0xFF); - }); - }); - } - - auto at(usize row, usize col) const -> u8 { - if (row >= m_rows || col >= m_cols) return 0; - return m_data[row * m_cols + col]; - } - auto rows() const -> usize { return m_rows; } - auto cols() const -> usize { return m_cols; } - auto data() const -> std::vector const& { return m_data; } - -private: - usize m_rows; - usize m_cols; - std::vector m_data; -}; - -class node { -public: - node(i32 id, i32 value, edges_t const& edges) - : m_id(id), m_value(value), m_edges(edges) {} - - auto operator==(node const& other) const -> bool { - return m_id == other.m_id && m_value == other.m_value; - } - - auto id() const -> i32 { return m_id; } - auto value() const -> i32 { return m_value; } - auto edges() const -> edges_t const& { return m_edges; } - -private: - i32 m_id; - i32 m_value; - edges_t m_edges; -}; - -class graph { -public: - -private: -}; - -} - -auto aoc24::day10([[maybe_unused]]std::span const& args) -> std::expected { - auto res = aoc::read_text("./dat/24/ex/10a.txt"); - if (!res) return std::unexpected(res.error()); - auto const txt = *res; - - lpf::trail trail{txt}; - - return {}; -} diff --git a/sol/24/day11.cpp b/sol/24/day11.cpp deleted file mode 100644 index 95dc005..0000000 --- a/sol/24/day11.cpp +++ /dev/null @@ -1,142 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace aoc::types; -using namespace std::string_view_literals; - -namespace ms { -class magic { -public: - magic(std::string const& str) { - m_stones = str | std::views::filter([](auto const& c) { return c != '\n'; }) - | std::views::split(" "sv) - | std::views::transform([](auto const& c_str) { - return i64(std::stoll(std::string(std::begin(c_str), std::end(c_str)))); - }) | std::ranges::to(); - } - - auto blink() -> void { - std::vector stones{}; - for (usize i = 0; i < m_stones.size(); ++i) { - auto const stone = m_stones[i]; - auto const str = std::to_string(stone); - - if (stone == 0) stones.emplace_back(1); - else if (str.length() % 2 == 0) { - auto const a = std::stoll(str.substr(0, str.length() / 2)); - auto const b = std::stoll(str.substr(str.length() / 2)); - stones.emplace_back(a); - stones.emplace_back(b); - } else { - stones.emplace_back(stone * 2024); - } - } - - m_stones = stones; - } - - auto blink(usize order, std::span const& stones) -> void { - std::vector compute{}; - - for (usize i = 0; i < stones.size(); ++i) { - auto const stone = stones[i]; - auto const str = std::to_string(stone); - - if (stone == 0) compute.emplace_back(1); - else if (str.length() % 2 == 0) { - fmt::print("{}\n", str); - auto const a = std::stoll(str.substr(0, str.length() / 2)); - auto const b = std::stoll(str.substr(str.length() / 2)); - compute.emplace_back(a); - compute.emplace_back(b); - } else { - compute.emplace_back(stone * 2024); - } - } - - m_mutex.lock(); - m_tmp.push_back({order, compute}); - m_mutex.unlock(); - } - - auto size() const -> usize { return m_stones.size(); } - - auto join(i32 current) -> void { - std::sort(std::begin(m_tmp), std::end(m_tmp), [](auto const& a, auto const& b) { - return a.first < b.first; - }); - - m_stones = {}; - for (usize i = 0; i < m_tmp.size(); ++i) { - for (usize j = 0; j < m_tmp[i].second.size(); ++j) { - m_stones.push_back(m_tmp[i].second[j]); - } - } - m_tmp = {}; - (void)current; - - // fmt::print("join... {}, {}\n", current, m_stones.size()); - } - - auto data() const -> std::vector const& { return m_stones; } - auto str() const -> std::string { - std::string str{}; - for (usize i = 0; i < m_stones.size(); ++i) { - str += std::to_string(m_stones[i]); - if (i < m_stones.size() - 1) str += " "; - } - return str; - } - -private: - std::vector m_stones{}; - std::vector>> m_tmp{}; - std::mutex m_mutex{}; -}; -} - -auto aoc24::day11([[maybe_unused]]std::span const& args) -> std::expected { - auto res = aoc::read_text("./dat/24/re/11.txt"); - // auto res = aoc::read_text("./dat/24/ex/11b.txt"); - if (!res) return std::unexpected(res.error()); - auto const txt = *res; - - ms::magic magic{txt}; - fmt::print("{}\n", magic.str()); - - auto const max_threads = std::thread::hardware_concurrency(); - - for (i32 i = 0; i < 75; ++i) { - auto stones = magic.data(); - auto chunk_size = stones.size() / max_threads; - if (chunk_size == 0) chunk_size = stones.size(); - - std::vector threads{}; - for (usize k = 0; k < max_threads; ++k) { - auto start_index = k * chunk_size; - auto end_index = std::min((k + 1) * chunk_size, stones.size()); - if (start_index >= stones.size()) break; - - std::span sp{stones}; - std::span split = sp.subspan(start_index, end_index); - threads.emplace_back([&]{ magic.blink(k, split); }); - } - for (usize k = 0; k < threads.size(); ++k) { - threads[k].join(); - } - magic.join(i); - } - - fmt::print("stones: {}\n", magic.size()); - - return {}; -} diff --git a/sol/24/day12.cpp b/sol/24/day12.cpp deleted file mode 100644 index b58b7f6..0000000 --- a/sol/24/day12.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace aoc::types; -using namespace std::string_view_literals; - -namespace gmf {} - -auto aoc24::day11([[maybe_unused]]std::span const& args) -> std::expected { - auto res = aoc::read_text("./dat/24/re/12.txt"); - // auto res = aoc::read_text("./dat/24/ex/12a.txt"); - if (!res) return std::unexpected(res.error()); - auto const txt = *res; - - fmt::print("{}\n", txt); - - return {}; -} diff --git a/sol/24/day14.cpp b/sol/24/day14.cpp deleted file mode 100644 index 77ce63c..0000000 --- a/sol/24/day14.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" - -using namespace aoc::types; -using namespace std::string_view_literals; - -namespace ebh { -} - -auto aoc24::day14([[maybe_unused]]std::span const& args) -> std::expected { - // auto res = aoc::read_text("./dat/24/ex/07.txt"); - auto res = aoc::read_text("./dat/24/re/07.txt"); - if (!res) return std::unexpected(res.error()); - auto const txt = *res; - return {}; -} diff --git a/sol/24/day16.cpp b/sol/24/day16.cpp deleted file mode 100644 index 70360af..0000000 --- a/sol/24/day16.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" -#include "stb_image_write.h" - -using namespace aoc::types; -using namespace std::string_view_literals; - -namespace rme { -struct edge { - u64 a{0x00}; - u64 b{0x00}; - - auto str() const -> std::string { - if (b == 0) return "nil"; - return fmt::format("{}.{}", (b >> 32), b & 0xFFFFFFFF); - } -}; - -struct node { - u64 id; - edge n; - edge s; - edge e; - edge w; - - auto str() const -> std::string { - std::string str{"node {"}; - str += " id: " + fmt::format("{}.{}", (id >> 32) & 0xFFFFFFFF, id & 0xFFFFFFFF); - if (n.b != 0) - str += ", n → " + n.str(); - if (s.b != 0) - str += ", s → " + s.str(); - if (e.b != 0) - str += ", e → " + e.str(); - if (w.b != 0) - str += ", w → " + w.str(); - str += " }"; - return str; - } -}; - - -class graph { -public: - graph(std::string const& maze_str) : m_start(0), m_exit(0) { - build(maze_str); - - for (auto const& node : m_nodes) { - fmt::print("{}\n", node.str()); - } - } - - auto vertices() const -> std::vector const& { return m_nodes; } - -private: - auto build(std::string const& maze) -> void { - auto const lines = maze | aoc::split("\n"sv) - | aoc::map_to_sv - | aoc::filter_non_empty - | std::ranges::to(); - - m_rows = lines.size(); - for (usize i = 0; i < lines.size(); ++i) { - auto const& str = lines[i]; - m_cols = str.size(); - for (usize j = 0; j < m_cols; ++j) { - auto const c = str[j]; - node n{}; - auto const id = u64((u64(i + 1) << 32) | (j + 1)); - if (c == '#' || c == '\n') continue; - if (c == 'S') m_start = id; - if (c == 'E') m_exit = id; - n.id = id; - - auto const n_e = lines[i - 1][j]; - auto const s_e = lines[i + 1][j]; - auto const e_e = lines[i][j - 1]; - auto const w_e = lines[i][j + 1]; - - if (n_e != '#') { - n.n = { - .a = n.id, - .b = u64((u64(i) << 32) | (j + 1)) - }; - m_edges.emplace_back(n.n); - } - if (s_e != '#') { - n.s = { - .a = n.id, - .b = u64((u64(i + 2) << 32) | (j + 1)) - }; - m_edges.emplace_back(n.s); - } - if (e_e != '#') { - n.e = { - .a = n.id, - .b = u64((u64(i + 1) << 32) | (j)) - }; - m_edges.emplace_back(n.e); - } - if (w_e != '#') { - n.w = { - .a = n.id, - .b = u64((u64(i + 1) << 32) | (j + 2)) - }; - m_edges.emplace_back(n.w); - } - - m_nodes.emplace_back(std::move(n)); - } - } - } - -private: - u64 m_start; - u64 m_exit; - std::vector m_nodes{}; - std::vector m_edges{}; - u64 m_rows{}; - u64 m_cols{}; -}; - -// auto dfs() -> void {} -// auto bfs() -> void {} - -auto dijkstra(graph const& g, u64 source) -> void { - std::map dist{}; - std::map prev{}; - for (auto const& v : g.vertices()) { - dist.insert({v.id, aoc::lim::max()}); - prev.insert({v.id, -1}); - } - dist[source] = 0; - std::queue q{}; - q.push(g.vertices()[0]); - - while (!q.empty()) { - node u = q.pop(); - - if (u.n.b != 0) { - i64 alt = dist[u.id] == aoc::lim::max() ? 1 : dist[u.id] + 1; - } - } -} - -} - -auto aoc24::day16([[maybe_unused]]std::span const& args) -> std::expected { - auto res = aoc::read_text("./dat/24/ex/16.txt"); - // auto res = aoc::read_text("./dat/24/re/16.txt"); - if (!res) return std::unexpected(res.error()); - auto const txt = *res; - - rme::graph g{txt}; - - fmt::print("----------------------------------------\n"); - fmt::print("{}", txt); - - return {}; -} diff --git a/sol/24/day17.cpp b/sol/24/day17.cpp deleted file mode 100644 index af909b0..0000000 --- a/sol/24/day17.cpp +++ /dev/null @@ -1,247 +0,0 @@ -#include -#include -#include -#include -#include - -#include "aoc.hpp" -#include "aoc/utils.hpp" -#include "fmt/format.h" -#include "stb_image_write.h" -#include "ctre.hpp" - -using namespace aoc::types; -using namespace std::string_view_literals; - -namespace uec { -enum class opcode : u16 { - adv = 0, - bxl = 1, - bst = 2, - jnz = 3, - bxc = 4, - out = 5, - bdv = 6, - cdv = 7, - nop = 8, -}; - -auto opcode_to_str(opcode op) -> char const* { - switch (op) { - case opcode::adv: return "adv"; - case opcode::bxl: return "bxl"; - case opcode::bst: return "bst"; - case opcode::jnz: return "jnz"; - case opcode::bxc: return "bxc"; - case opcode::out: return "out"; - case opcode::bdv: return "bdv"; - case opcode::cdv: return "cdv"; - default: return "nop"; - } -} - -struct regs { - u64 a; - u64 b; - u64 c; -}; - -class cpu { -public: - cpu() {} - - auto load(uec::regs const& regs, std::vector const& program) -> void { - m_regs = regs; - m_program = program; - } - - auto registers() const -> uec::regs const& { return m_regs; } - auto program() const -> std::vector const& { return m_program; } - - auto clock() -> void { - auto const op = read(); - if (peek() == opcode::nop) return; - - auto const x = combo(); - switch (op) { - case opcode::adv: adv(x); break; - case opcode::bxl: bxl(); break; - case opcode::bst: bst(x); break; - case opcode::jnz: jnz(); break; - case opcode::bxc: bxc(); break; - case opcode::out: out(x); break; - case opcode::bdv: bdv(x); break; - case opcode::cdv: cdv(x); break; - default: nop(); break; - } - m_pc += 2; - } - - auto halt() const -> bool { - return peek() == opcode::nop; - } - - auto str() const -> std::string { - using namespace std::string_literals; - std::string str{}; - str += "PC: " + fmt::format("{:#04x}", m_pc) + "\n"; - str += "\n"; - - str += "A: " + fmt::format("{:#010x}", m_regs.a) + "\n"; - str += "B: " + fmt::format("{:#010x}", m_regs.b) + "\n"; - str += "C: " + fmt::format("{:#010x}", m_regs.c) + "\n"; - str += "\n"; - - for (usize i = 0; i < m_program.size(); ++i) { - str += fmt::format("{:02x}: ", i); - str += fmt::format("{}{}\n", opcode_to_str(m_program[i]), m_pc == i ? " <" : ""); - } - str += "\n"; - - str += " "; - for (usize i = 0; i < 16; ++i) { - str += fmt::format("{:02X}", i); - if (i == 7) str += " "; - else str += " "; - } - str += "\n\n"; - - for (usize i = 0; i < m_output.size() * sizeof(u64); ++i) { - if (i % 16 == 0) str += fmt::format("{:04X}: ", i); - str += fmt::format("{:02X}", *(reinterpret_cast(const_cast(m_output.data())) + i)); - if ((i + 1) % 16 == 0) str += "\n"; - else if ((i + 1) % 8 == 0) str += " "; - else str += " "; - } - if (m_output.size() != 0) - str += "\n"; - - str += "-------------------------------------------------------\n"; - return str; - } - - auto output_str() const -> std::string { - std::string str{}; - for (usize i = 0; i < m_output.size(); ++i) { - str += fmt::format("{}", m_output.at(i)); - if (i < m_output.size() - 1) str += ","; - } - return str; - } - auto output() const -> std::vector const& { return m_output; } - - -private: - auto read() const -> opcode { - if (m_pc < m_program.size()) - return m_program[m_pc]; - return opcode::nop; - } - auto peek() const -> opcode { - if (m_pc + 1 < m_program.size()) - return m_program[m_pc + 1]; - return opcode::nop; - } - auto combo() const -> u64 { - auto const op = u64(peek()); - if (op < 4) return op; - else if (op == 4) return m_regs.a; - else if (op == 5) return m_regs.b; - else if (op == 6) return m_regs.c; - else return u64(opcode::nop); - } - -private: - auto adv(u64 x) -> void { - m_regs.a >>= x; - } - auto bxl() -> void { - m_regs.b = m_regs.b ^ u64(peek()); - } - auto bst(u64 x) -> void { - m_regs.b = x % 8; - } - auto jnz() -> void { - if (m_regs.a == 0) - return; - m_pc = u64(peek()) - 2; - } - auto bxc() -> void { - m_regs.b = m_regs.b ^ m_regs.c; - } - auto out(u64 x) -> void { - m_output.emplace_back(x % 8); - } - auto bdv(u64 x) -> void { - m_regs.b = m_regs.a >> x; - } - auto cdv(u64 x) -> void { - m_regs.c = m_regs.a >> x; - } - auto nop() -> void {} - -private: - u64 m_pc{}; - uec::regs m_regs{}; - std::vector m_program{}; - std::vector m_output{}; -}; -} - -auto part_a(uec::regs const& regs, std::vector const& program) -> void { - uec::cpu cpu{}; - cpu.load(regs, program); - - while (!cpu.halt()) { - // fmt::print("{}", cpu.str()); - // std::cin.get(); - cpu.clock(); - } - fmt::print("{}", cpu.str()); - fmt::print("{}\n", cpu.output_str()); -} - -auto aoc24::day17([[maybe_unused]]std::span const& args) -> std::expected { - // auto res = aoc::read_text("./dat/24/ex/17a.txt"); - auto res = aoc::read_text("./dat/24/ex/17b.txt"); - // auto res = aoc::read_text("./dat/24/re/17.txt"); - if (!res) return std::unexpected(res.error()); - auto const txt = *res; - auto const lines = txt | aoc::split("\n"sv) - | aoc::map_to_sv - | aoc::filter_non_empty - | std::ranges::to(); - - uec::regs regs{}; - std::vector program{}; - for (auto const& line : lines) { - if (auto reg = ctre::match<"Register ([A-Z]): ([0-9]+)">(line)) { - if (reg.get<1>().view() == "A"sv) { - regs.a = std::stoul(reg.get<2>().to_string()); - } else if (reg.get<1>().view() == "A"sv) { - regs.b = std::stoul(reg.get<2>().to_string()); - } else if (reg.get<1>().view() == "A"sv) { - regs.c = std::stoul(reg.get<2>().to_string()); - } else { - // fmt::print("unknown register\n"); - } - continue; - } - - if (auto prog = ctre::match<"Program: ([0-9,]+)">(line)) { - program = prog.get<1>().to_string() | aoc::split(","sv) - | aoc::map_to_str - | aoc::filter_non_empty - | std::views::transform([](auto const& str) { - return uec::opcode(std::stoul(str)); - }) | std::ranges::to(); - } - } - - // part_a(regs, program); - - uec::cpu cpu{}; - cpu.load({}, program); - - return {}; -}