From 18dc6dd71458aa02b1e428b1c34ec13267b6a47f Mon Sep 17 00:00:00 2001 From: JonOfUs Date: Fri, 6 Dec 2024 12:23:04 +0100 Subject: [PATCH] d06 start --- res/06/example | 10 ++++ res/06/input | 130 ++++++++++++++++++++++++++++++++++++++++++++++++ src/days/d06.rs | 38 ++++++++++++++ src/main.rs | 2 +- 4 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 res/06/example create mode 100644 res/06/input create mode 100644 src/days/d06.rs diff --git a/res/06/example b/res/06/example new file mode 100644 index 0000000..a4eb402 --- /dev/null +++ b/res/06/example @@ -0,0 +1,10 @@ +....#..... +.........# +.......... +..#....... +.......#.. +.......... +.#..^..... +........#. +#......... +......#... diff --git a/res/06/input b/res/06/input new file mode 100644 index 0000000..22c7157 --- /dev/null +++ b/res/06/input @@ -0,0 +1,130 @@ +....#.....#......#...............................#...........#.......#.....#................#...#....#....#................#..#.#. +...................................................................................#...........#............#..................... +..........#..............#.................................................#..............#....................................... +....................#...............#...#.....................#..............................#....#.............................#. +...............................##...............................................................#............#.................... +................#...........#................#...............#....#.......#.............................#..........#...........#.. +...........................#................................................#.##..................#.............#........#........ +......#......#.....#..........#.......................#..........#.............#.....................#........#....#.............. +..................................................#..................................#....#.........#...........#..............#.. +..................................#..................#..........................................#.........#....................#.. +#.................#....................#...........#....................................#......................#.................. +.......#..........................................................................................................#............... +...............##.............................#...#.....................#..........................#.......................#...... +...#.......................................................#..........................................#...................#..#.... +.......#...#.......#.#.............#.....#.##.........................#........................................................... +#................#.........#.......................##............................................#...#.....#........#.......#..... +#......##..............................................................#......#....#....#....#.#...............#............#..#.. +.....#...............................##.......................................#.......#......#............................#.....#. +.........#......#...............................#.....#.....#...................##......#......................................... +.#.................................................#...............#........#............................#........................ +#.........#.........................................#.......................#..............#......................#...........#... +..........................................##.............................................................##..#.......#............ +...#.........................#...........................................#........#............................................... +#..................#............#.................................................................#.#....................#....#..# +...................#.....................................#.#.........#.............#......#............................##......... +....#..............................................................##.......................................................#....# +.....................#.....#.............................................#.......................#..................#............. +...........#.......................................#................#.........#...............#.#...........#.....#.....#........# +.#..#.................#....#...............................#.................................................##................... +..#.....#......#..........#...................#..#..................................................#.......#...#................. +.............................................................#.......................#..........#.....#...................#....... +.......#.......................#.#....#...#.....##.......................#.................................................#...... +.................#.....................#...............................................................#..#....................... +...#.................#.#..................................................##......................................#..#............ +#........................................................#...#.........#................#.#....................................... +.................#........#.#........................#.#..................................#....................................... +..........#..#......#..................#.........................#................................#............................... +.............................................................................................#.................................... +.....................#...........#........##.....#.........................#..............................#.....#....#............ +..#........#.........#.....................................................#...................................................... +...................................#...................#............#.............#...........................#................... +....#.........................................................#................................#......#...#..#.................... +................................................................................#..#.......#..........................#....#...... +#...........................................................................#........................#............................ +..#..............#..........#...#..........................................................#...................................... +.......................................................#.................#.#....#.................#..........#....#............... +.................................................................................................................................. +.................#.........................................................#..........#.........#.........#.................#..... +....................#........#...................#................#...#....................#..............#................#...... +...#.............##........................................#.........#.................#...........#.........#.................... +................#............#...........#...............#.....................................#...........................#...... +....................................................#...........#..............................#..........#...........#........... +.........#..............#................................#.............#......................................#.........#...#..... +..#..#.........................................#.............................#.................................................... +.#............................##...#..........#............#..#.........................#......................#...#.............. +........#.....#..............#..................................................#...#......................#....#..............#.. +...............................................#.........#..................#............#.............................#.......... +..................................................................................................#....#.......................... +..............#..............................................................#.................................................... +.....#....#.....................#......................#...........#...#..#.............#.......................#................. +.............................#...#..#...........................#............................................................#.... +.............................................#...............................#...................................................# +..................................................................#......#....#.......................#.......#........#.......... +..................#.#.........................................................................................##.......#........#. +.............................#.......................#.......................................##................................... +.....#.............................................................................................................#.#............ +...............##.........#..#.....#...............#....................#.................................#.#....#................ +................#......................................................................#...............#...................#...... +.................#..............#................................................................................................. +............#...#...........................................................................................#......#.............. +..#.....................................................................#.....#.#.#......#....#..........#........................ +.#........#.............................#.....................#.....................#....#........................................ +.......................................................................................................#.......................... +...#........#..................................................#.........................................................#......#. +.......#.......#..#.................................................................................................#............. +..............................#..#..........................#..#..................#.............#................................. +..................#...#.............................................#...................#.......#...............#................. +...#.......#........#.....................................#...........#.................................................#......... +.#.............#....................................#........................................................##............#...#.. +...............#.....#....................................................................................#....#................#. +....#...........................................................#.....#..............................................#............ +.........#..........#...........................#.......................................#....#....................#............... +...............................................................#..........#......^...............................................# +#..........................#.....................#..............................#..............................#.................. +...................#.....#......#...........#........#............#.......#.......#............................................... +.....#.....#.............................................................#..............#........#..........................#....# +............#...............................................................#.............#......................#................ +.....#...............................................##........................................#.......#......#................... +.........................................#........................................................................................ +..........................#...............................#............#............................#.....#....................... +...##.........#......#.....#...............................................................#........#............................. +......#...............#.#......................#.......#..............................#...#.........#.........#..#.........#...... +....#......#....#........#.#.............................#......................................................#.....#........... +.....#.............#.....................#...#...............#.................................................................... +......#............#............#.#............#....................#............................................................. +.............#..................................................#....................#.............#.......#.............#........ +.............................................#......................................................................#............. +...............................#............................................................#................#...................# +............#.....#....................................................................................................#.#........ +.........................#....................#...##.......#............#..#.................................#......#............. +....#......................#.....................#...........#.........................................#......#.#................. +..................................................................#..........................#......................#............. +.......................#......#..............................................................................#.................... +.......#.................#...............................##...............................................#.............#......... +.#..............#.....................................................................................................#........... +.......##.................#................#.#...#......................................#...............#...#..................... +.............##......................................................#....................................#..........#............ +....................................#............#............#............#.....................................#................ +................#..#............................#..............................................#.....#...................#......#. +....................#....#......#..................#................#............................................................. +...............##...............#...#..........................#......#...............#..#................#.....#.............#... +...........#..........#..........#..#.........#....#...#......#..............#................#....#..#........................... +#.....................#..#...................................#...#..............................#......#.#.#...................... +............##...................#..#............................................................................................. +..............................................#.#.......................#.................#....#..................#.......#....... +....#................#......#........................................................#........#..............#.................... +.........#.#...............#............................###...........#........................................................... +.........#.................................................................................#......#...#..............#......#..... +....#....#......#.#.........#..........#...............#.........#............##.............#..#............................#.... +....#..#...#.....#...........................#.#.......................................#...#.....................#............#..# +...........#............................#........#...#......#...............................................#...#................. +..#...............................................................#..............................................#.........#...... +...................#.....................................#....................................#.#.#............#............#..... +.....#.................#...........................##.................#..#........................................................ +...#.......#...................................#.............................#...........#......##.#...#.........#.#...........#.. +.#.............#......#..#...#......................................................#..............#.............#.#.............. +.......................#............#...................#.....................#.......................#.............#..#......#... +......................#..#.#.......#........#....#.............#.........#..............................#.#..........#........#... +.................#.............#..#..........#...#.........#..................................#..#.............#................#. +.#..................................#....#...........................................#..............................#...#......... diff --git a/src/days/d06.rs b/src/days/d06.rs new file mode 100644 index 0000000..3031890 --- /dev/null +++ b/src/days/d06.rs @@ -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> = contents + .lines() + .map(|line| { + line.chars() + .map(|c| match c { + '#' => true, + _ => false, + }) + .collect::>() + }) + .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); +} diff --git a/src/main.rs b/src/main.rs index bd9ccb0..64d1cf9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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);