From baaa6cd61c302c80c664e9aaa5e4ab2ab157b5cf Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Sun, 3 Dec 2023 18:57:02 +0100 Subject: aoc(2302): Cube Conundrum --- 2023/02/src/game.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 2023/02/src/game.h (limited to '2023/02/src/game.h') diff --git a/2023/02/src/game.h b/2023/02/src/game.h new file mode 100644 index 0000000..1c8002a --- /dev/null +++ b/2023/02/src/game.h @@ -0,0 +1,45 @@ +#ifndef GAME_H +#define GAME_H + +#include +#include +#include +#include + +template +std::basic_istream& skip(std::basic_istream& stream) +{ + std::string word; + stream >> word; + if (word != keyword) + { + throw std::invalid_argument("Malformed input"); + } + + return stream; +} + +class Game +{ + int id_; + std::vector> draws{}; + + static constexpr char game_t[] = "Game"; + + public: + Game(int id); + + inline int id() const + { + return id_; + } + + bool is_valid(int blue, int red, int green) const; + int power() const; + void push_back(const std::vector& draw); + std::string to_string() const; + + static Game from_string(const std::string& line); +}; + +#endif //GAME_H -- cgit v1.2.3