Skip to content

Commit 7f178b3

Browse files
committed
Started Day 6
1 parent fc1514b commit 7f178b3

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

include/advent_of_code/day_6.hxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#pragma once
3+
4+
#include <fstream>
5+
#include <string>
6+
7+
#include "spdlog/spdlog.h"
8+
9+
namespace AdventOfCode24::Day6 {
10+
typedef std::pair<int, int> coord;
11+
typedef std::pair<int, int> direction;
12+
typedef std::pair<coord,direction> status;
13+
std::pair<coord, std::vector<coord>> get_area_map(const std::filesystem::path& input_file);
14+
};

src/day_4.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ namespace AdventOfCode24::Day4 {
195195
}
196196

197197
int count_matches_in_file(const std::filesystem::path& input_file, const std::string& word, bool wordsearch) {
198-
std::deque<std::string> lines;
198+
std::deque<std::string> lines;
199199

200200
std::ifstream read_in(input_file, std::ios::in);
201201
std::string line;
202-
int line_counter{0};
203-
int instance_counter{0};
202+
int line_counter{0};
203+
int instance_counter{0};
204204

205205
while (std::getline(read_in, line)) {
206206
lines.push_back(line);

src/day_6.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "advent_of_code/day_6.hxx"
2+
3+
namespace AdventOfCode24::Day6 {
4+
std::pair<status, std::vector<coord>> get_area_map(const std::filesystem::path& input_file) {
5+
6+
std::ifstream read_in(input_file, std::ios::in);
7+
std::string line;
8+
std::vector<coord> area_map;
9+
status guard_init{{-1,-1},{0,0}};
10+
const char guard_symbols[4]{'v','>','<','^'};
11+
12+
13+
while (std::getline(read_in, line)) {
14+
char symbol{'@'};
15+
std::istringstream iss;
16+
iss.str(line);
17+
int column{0}
18+
19+
while(iss >> symbol) {
20+
if(symbol == '#') {
21+
area_map.push_back({area_map.size(), column});
22+
column++;
23+
continue;
24+
}
25+
auto find_guard = std::find(std::begin(guard_symbols), std::end(guard_symbols), symbol);
26+
}
27+
}
28+
};

0 commit comments

Comments
 (0)