Skip to content

Commit 85a1164

Browse files
committed
Start Day 4
1 parent 68bd15f commit 85a1164

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

include/advent_of_code/day_4.hxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include <fstream>
4+
#include <vector>
5+
6+
namespace AdventOfCode::Day4 {
7+
int get_matches(const std::string& word, const std::vector<std::string>& block);
8+
};

src/day_4.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "advent_of_code/day_4.hxx"
2+
3+
namespace AdventOfCode::Day4 {
4+
int get_matches(const std::string& word, const std::vector<std::string> block) {
5+
}
6+
};

tests/data/day_4_1.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
MMMSXXMASM
2+
MSAMXMSMSA
3+
AMXSXMAAMM
4+
MSAMASMSMX
5+
XMASAMXAMM
6+
XXAMMXXAMA
7+
SMSMSASXSS
8+
SAXAMASAAA
9+
MAMMMXMMMM
10+
MXMXAXMASX

tests/test_day_4.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
#include <gtest/gtest.h>
3+
#include <string>
4+
#include "advent_of_code/day_3.hxx"
5+
6+
using namespace AdventOfCode::Day4;
7+
8+
#ifndef ADVENT_OF_CODE_DATA
9+
#error "ADVENT_OF_CODE_DATA is not defined!"
10+
#endif
11+
12+
TEST(TestAOC, TestDay4pt1_block_parse) {
13+
const std::string word{"XMAS"};
14+
const std::string block{"XJYSAMXOTX\nMHRHXMASMD\nAGKUWQAP\nSCYKOSTRY\n"};
15+
const int n_matches{get_matches(word, block)};
16+
17+
ASSERT_EQ(n_matches, 4);
18+
}
19+

0 commit comments

Comments
 (0)