d06 start

This commit is contained in:
JonOfUs 2024-12-06 12:23:04 +01:00
parent 5dffb6f929
commit 18dc6dd714
4 changed files with 179 additions and 1 deletions

10
res/06/example Normal file
View file

@ -0,0 +1,10 @@
....#.....
.........#
..........
..#.......
.......#..
..........
.#..^.....
........#.
#.........
......#...

130
res/06/input Normal file
View file

@ -0,0 +1,130 @@
....#.....#......#...............................#...........#.......#.....#................#...#....#....#................#..#.#.
...................................................................................#...........#............#.....................
..........#..............#.................................................#..............#.......................................
....................#...............#...#.....................#..............................#....#.............................#.
...............................##...............................................................#............#....................
................#...........#................#...............#....#.......#.............................#..........#...........#..
...........................#................................................#.##..................#.............#........#........
......#......#.....#..........#.......................#..........#.............#.....................#........#....#..............
..................................................#..................................#....#.........#...........#..............#..
..................................#..................#..........................................#.........#....................#..
#.................#....................#...........#....................................#......................#..................
.......#..........................................................................................................#...............
...............##.............................#...#.....................#..........................#.......................#......
...#.......................................................#..........................................#...................#..#....
.......#...#.......#.#.............#.....#.##.........................#...........................................................
#................#.........#.......................##............................................#...#.....#........#.......#.....
#......##..............................................................#......#....#....#....#.#...............#............#..#..
.....#...............................##.......................................#.......#......#............................#.....#.
.........#......#...............................#.....#.....#...................##......#.........................................
.#.................................................#...............#........#............................#........................
#.........#.........................................#.......................#..............#......................#...........#...
..........................................##.............................................................##..#.......#............
...#.........................#...........................................#........#...............................................
#..................#............#.................................................................#.#....................#....#..#
...................#.....................................#.#.........#.............#......#............................##.........
....#..............................................................##.......................................................#....#
.....................#.....#.............................................#.......................#..................#.............
...........#.......................................#................#.........#...............#.#...........#.....#.....#........#
.#..#.................#....#...............................#.................................................##...................
..#.....#......#..........#...................#..#..................................................#.......#...#.................
.............................................................#.......................#..........#.....#...................#.......
.......#.......................#.#....#...#.....##.......................#.................................................#......
.................#.....................#...............................................................#..#.......................
...#.................#.#..................................................##......................................#..#............
#........................................................#...#.........#................#.#.......................................
.................#........#.#........................#.#..................................#.......................................
..........#..#......#..................#.........................#................................#...............................
.............................................................................................#....................................
.....................#...........#........##.....#.........................#..............................#.....#....#............
..#........#.........#.....................................................#......................................................
...................................#...................#............#.............#...........................#...................
....#.........................................................#................................#......#...#..#....................
................................................................................#..#.......#..........................#....#......
#...........................................................................#........................#............................
..#..............#..........#...#..........................................................#......................................
.......................................................#.................#.#....#.................#..........#....#...............
..................................................................................................................................
.................#.........................................................#..........#.........#.........#.................#.....
....................#........#...................#................#...#....................#..............#................#......
...#.............##........................................#.........#.................#...........#.........#....................
................#............#...........#...............#.....................................#...........................#......
....................................................#...........#..............................#..........#...........#...........
.........#..............#................................#.............#......................................#.........#...#.....
..#..#.........................................#.............................#....................................................
.#............................##...#..........#............#..#.........................#......................#...#..............
........#.....#..............#..................................................#...#......................#....#..............#..
...............................................#.........#..................#............#.............................#..........
..................................................................................................#....#..........................
..............#..............................................................#....................................................
.....#....#.....................#......................#...........#...#..#.............#.......................#.................
.............................#...#..#...........................#............................................................#....
.............................................#...............................#...................................................#
..................................................................#......#....#.......................#.......#........#..........
..................#.#.........................................................................................##.......#........#.
.............................#.......................#.......................................##...................................
.....#.............................................................................................................#.#............
...............##.........#..#.....#...............#....................#.................................#.#....#................
................#......................................................................#...............#...................#......
.................#..............#.................................................................................................
............#...#...........................................................................................#......#..............
..#.....................................................................#.....#.#.#......#....#..........#........................
.#........#.............................#.....................#.....................#....#........................................
.......................................................................................................#..........................
...#........#..................................................#.........................................................#......#.
.......#.......#..#.................................................................................................#.............
..............................#..#..........................#..#..................#.............#.................................
..................#...#.............................................#...................#.......#...............#.................
...#.......#........#.....................................#...........#.................................................#.........
.#.............#....................................#........................................................##............#...#..
...............#.....#....................................................................................#....#................#.
....#...........................................................#.....#..............................................#............
.........#..........#...........................#.......................................#....#....................#...............
...............................................................#..........#......^...............................................#
#..........................#.....................#..............................#..............................#..................
...................#.....#......#...........#........#............#.......#.......#...............................................
.....#.....#.............................................................#..............#........#..........................#....#
............#...............................................................#.............#......................#................
.....#...............................................##........................................#.......#......#...................
.........................................#........................................................................................
..........................#...............................#............#............................#.....#.......................
...##.........#......#.....#...............................................................#........#.............................
......#...............#.#......................#.......#..............................#...#.........#.........#..#.........#......
....#......#....#........#.#.............................#......................................................#.....#...........
.....#.............#.....................#...#...............#....................................................................
......#............#............#.#............#....................#.............................................................
.............#..................................................#....................#.............#.......#.............#........
.............................................#......................................................................#.............
...............................#............................................................#................#...................#
............#.....#....................................................................................................#.#........
.........................#....................#...##.......#............#..#.................................#......#.............
....#......................#.....................#...........#.........................................#......#.#.................
..................................................................#..........................#......................#.............
.......................#......#..............................................................................#....................
.......#.................#...............................##...............................................#.............#.........
.#..............#.....................................................................................................#...........
.......##.................#................#.#...#......................................#...............#...#.....................
.............##......................................................#....................................#..........#............
....................................#............#............#............#.....................................#................
................#..#............................#..............................................#.....#...................#......#.
....................#....#......#..................#................#.............................................................
...............##...............#...#..........................#......#...............#..#................#.....#.............#...
...........#..........#..........#..#.........#....#...#......#..............#................#....#..#...........................
#.....................#..#...................................#...#..............................#......#.#.#......................
............##...................#..#.............................................................................................
..............................................#.#.......................#.................#....#..................#.......#.......
....#................#......#........................................................#........#..............#....................
.........#.#...............#............................###...........#...........................................................
.........#.................................................................................#......#...#..............#......#.....
....#....#......#.#.........#..........#...............#.........#............##.............#..#............................#....
....#..#...#.....#...........................#.#.......................................#...#.....................#............#..#
...........#............................#........#...#......#...............................................#...#.................
..#...............................................................#..............................................#.........#......
...................#.....................................#....................................#.#.#............#............#.....
.....#.................#...........................##.................#..#........................................................
...#.......#...................................#.............................#...........#......##.#...#.........#.#...........#..
.#.............#......#..#...#......................................................#..............#.............#.#..............
.......................#............#...................#.....................#.......................#.............#..#......#...
......................#..#.#.......#........#....#.............#.........#..............................#.#..........#........#...
.................#.............#..#..........#...#.........#..................................#..#.............#................#.
.#..................................#....#...........................................#..............................#...#.........

38
src/days/d06.rs Normal file
View file

@ -0,0 +1,38 @@
use std::fs;
pub fn solve() {
let path = "res/06/example";
let contents = fs::read_to_string(path).expect("Something went wrong reading the file");
let map: Vec<Vec<bool>> = contents
.lines()
.map(|line| {
line.chars()
.map(|c| match c {
'#' => true,
_ => false,
})
.collect::<Vec<bool>>()
})
.collect();
let mut pos: (usize, usize) = contents
.lines()
.enumerate()
.find(|(_, line)| line.contains("^"))
.map(|(x, line)| (x, line.chars().position(|c| c == '^').unwrap()))
.unwrap();
let mut dir: (isize, isize) = (-1, 0);
let mut guard_positions: Vec<(usize, usize)> = vec![];
// let the guard move until he leaves the map
let result: usize = 0;
println!("Result 1: {}", result);
println!("Result 2: {}", result);
}

View file

@ -33,11 +33,11 @@ fn _all_days() {
days::d05::solve();
time = _print_elapsed(time);
/*
println!("\nDay 6");
days::d06::solve();
time = _print_elapsed(time);
/*
println!("\nDay 7");
days::d07::solve();
time = _print_elapsed(time);