Add VSCode configuration files for debugging and building with CMake; refactor main.cpp to clean up includes

This commit is contained in:
Feiko Wielsma 2025-12-04 16:24:56 +00:00
parent c3a8206e55
commit 840f236c60
3 changed files with 40 additions and 23 deletions

View file

@ -1,18 +1,12 @@
#include <algorithm>
#include <array>
#include <cstddef>
#include <expected>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <mdspan>
#include <numeric>
#include <print>
#include <ranges>
#include <string>
#include <string_view>
#include <vector>
struct Diagram {
@ -25,6 +19,7 @@ struct Diagram {
auto grid() { return GridView(data.data(), height, width); }
};
namespace {
auto printMap(Diagram &diagram) {
auto grid = diagram.grid();
for (auto row = 0UZ; row != grid.extent(0); row++) {
@ -37,7 +32,6 @@ auto printMap(Diagram &diagram) {
std::println("Width: {}", diagram.width);
std::println("Height: {}", diagram.height);
}
auto parseMap(const std::string &filename) -> std::expected<Diagram, std::string> {
std::ifstream inputF{filename};
@ -143,7 +137,7 @@ auto moveMoveablePaper(Diagram &diagram) -> long {
return totalPaperRemoved;
}
} // namespace
auto main() -> int {
auto testCase = parseMap("test_input");
if (testCase) {