summaryrefslogtreecommitdiff
path: root/2023/02/src/part1.cpp
blob: c9fe48c45c3324d1c781815324b55dbc94778cd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <fstream>

#include "game.h"

int main(void)
{
    int answer{};
    std::vector<Game> games{};

    std::ifstream input{ "resources/input.txt" };
    if (input.is_open())
    {
        std::string line;

        while (not std::getline(input,line).eof())
        {
            games.push_back(Game::from_string(line));
        }
    }
    input.close();

    for (const auto& game : games)
    {
        if (game.is_valid(14, 12, 13))
        {
            answer += game.id();
        }
    }

    std::cout << answer << std::endl;
    return 0;
}