90 lines
1.7 KiB
C++
90 lines
1.7 KiB
C++
#include <span>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <numeric>
|
|
#include <ranges>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include "fmt/std.h"
|
|
|
|
#include "aoc/types.hpp"
|
|
#include "aoc/utils.hpp"
|
|
|
|
using namespace std::string_view_literals;
|
|
using namespace aoc::types;
|
|
|
|
// simple pipe for std::string by value
|
|
template <typename F>
|
|
auto operator|(std::string s, F&& f) -> decltype(auto) {
|
|
return std::forward<F>(f)(std::move(s));
|
|
}
|
|
|
|
auto ltrim(std::string s) -> std::string {
|
|
s.erase(
|
|
std::begin(s),
|
|
std::find_if(s.begin(), s.end(), [](char ch) {
|
|
return !std::isspace(static_cast<char>(ch));
|
|
}));
|
|
return s;
|
|
}
|
|
|
|
auto rtrim(std::string s) -> std::string {
|
|
s.erase(
|
|
std::find_if(s.rbegin(), s.rend(), [](char ch) {
|
|
return !std::isspace(static_cast<char>(ch));
|
|
}).base(),
|
|
s.end());
|
|
return s;
|
|
}
|
|
|
|
auto trim(std::string s) -> std::string {
|
|
return ltrim(rtrim(std::move(s)));
|
|
}
|
|
|
|
// starts at 50
|
|
constexpr auto raw_str = R"(
|
|
L68
|
|
L30
|
|
R48
|
|
L5
|
|
R60
|
|
L55
|
|
L1
|
|
L99
|
|
R14
|
|
L82
|
|
)";
|
|
|
|
enum class rotdir {
|
|
L,
|
|
R
|
|
};
|
|
|
|
struct rot {
|
|
rotdir dir;
|
|
u32 turns;
|
|
};
|
|
|
|
static auto entry([[maybe_unused]]std::span<char const*> const& args) -> void {
|
|
std::string str{raw_str};
|
|
str = str | trim;
|
|
fmt::print("{}\n", str);
|
|
|
|
auto rot_vec = str | std::views::split("\n"sv) | std::views::transform([](auto const& str) {
|
|
return 0;
|
|
}) | std::ranges::to<std::vector>();
|
|
}
|
|
|
|
auto main([[maybe_unused]]int argc, [[maybe_unused]]char const* argv[]) -> int {
|
|
try {
|
|
entry({argv, std::next(argv, argc)});
|
|
} catch (std::exception const& e) {
|
|
fmt::print(stderr, "{}\n", e.what());
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|