Compare commits

...

2 Commits

Author SHA1 Message Date
aaf9b54e03 use same naming as clj solution 2025-12-28 05:42:23 -10:00
406c5906eb remove dead code 2025-12-28 05:40:22 -10:00

View File

@ -76,13 +76,11 @@ void insert_or_increment(std::map<size_t, uint64_t> &cols, size_t col,
uint64_t part_2(const Grid &grid) { uint64_t part_2(const Grid &grid) {
Location start = find_start(grid); Location start = find_start(grid);
const auto [start_row, start_col]{start}; const auto [start_row, start_col]{start};
using namespace std::ranges::views;
using namespace std::ranges; using namespace std::ranges;
auto view = iota_view{start_row, grid.size()}; auto view = iota_view{start_row, grid.size()};
std::map<size_t, uint64_t> starting_cols{{start_col, 1}}; std::map<size_t, uint64_t> starting_cols{{start_col, 1}};
auto cols = fold_left(view, starting_cols, [&grid](auto acc, auto row) { auto cols = fold_left(view, starting_cols, [&grid](auto cols, auto row) {
return fold_left(acc, std::map<size_t, uint64_t>{}, return fold_left(cols, std::map<size_t, uint64_t>{},
[&grid, &row](auto next_cols, auto col_cnt) { [&grid, &row](auto next_cols, auto col_cnt) {
auto [col, cnt] = col_cnt; auto [col, cnt] = col_cnt;
if (at_loc(grid, row, col) == '^') { if (at_loc(grid, row, col) == '^') {