Skip to content

Commit

Permalink
Day 25 and Day 24 setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rtsuk committed Dec 25, 2022
1 parent c76989b commit 0deacea
Show file tree
Hide file tree
Showing 6 changed files with 451 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
anyhow = "1.0.66"
console = "0.15.2"
convert-base = "1.1.2"
enum-iterator = "1.2.0"
euclid = { version = "0.22.7", features = ["serde"] }
evalexpr = "8.1.0"
Expand Down
73 changes: 73 additions & 0 deletions data/day24.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.#.######...####..##.###.#########.######..######..#..###...#######.####.
#.#....##..#.##...#..##.#........###.#.###.#.###.###....#.###.#..##..##..
..#########.#.#..##.##....##....##.......#...###....##..#..#.#.#..#.####.
.#..###.#.##...###..####.#.#..#.#.###.##.#.#......#.####..##.#####..#.##.
#..#.#######..####...##..#..##.###.#####...#.###.#....##.####..#.#.#####.
####.#.#..###########..#.###..#.###...###..#....#.####..###...#.##..##.#.
.##...##.##.####......#.#...#.#...###.#..##.###.###.#.########.#####.#.##
#....#.##..#.#..##..##.###.##.##..##..###.#.#...##....#.##..##.#.#..###..
#.##.#.#.##..#.#..#####.#.#...###.#...#####...##.##.#.#......##...#...#..
#.....#.##...##.##.#.####.#####.###..#.#.....#.###..#.######.#####.##.###
##......###...#..##.#####..###..#..######..#...#..#..#..#..#..#.###.#.##.
.....####..######..#.#.....###.#.##.#.##.##...##.#.######.##.#.##..#.###.
#.#.##.#.....#..###..#..##.######.#..####.##.##...##...#.#...#.....######
.#.####..##...#...##.######.#.###.##.#..#...#...#..#.####.#.#####.##...#.
####.##.###...####.....#..#.##..#.#..###..#.#....#.#.#....#.#..#.###....#
.####.#..###...##.#.##........#.#.##.#.####..#..#..##..#..#.#.#.######.##
.###.#..###...######.#..##.#########.#..........####...#.###.##..#..####.
#####....######.##.#....##.####..#.###...#####.###..##..#.#.##..#..#..###
.#.###.#..##.#####.####.#.#.#.#.##..#.####.##.#.#.#..#.#.#..##.#..####.##
####......###.#.#...#.#.....#...##.#.#.......#.##...#..#.###.#.#####..#..
.#.##....#...#.####.###.#.###.#.#.##.#.#.##.###.#####.....##..#..##.#...#
#....#...##.##.####....##...#...#.##...##.##.##...######.#.##..###.####..
#..#.#.##..####.#.#..#.#..#....####...####..#..#..###...##.#.##.#..##....
####..##.#.#.##.#####...####.#.##..##.#.#.#.##....##.#..#..##.##.#...#..#
##.#...#..####..##.#.#.#.#..##..##..###.#...##...#.#.#.#.##...####.##.##.
#######.#...#.####.....#.###.#..#.##.##.#####.....#.#.#..###..#....##.#..
.###....#.#.##.#...#..##..#.#...#.#.....#.##.####..###....#.#.#.###.##.##
#.#.#..#.##.####...#..#..##....##.#.#...#.##..##.#.#####.###.#####.#..##.
.#####.#####....####...#...#..#..#..####.#........###.##..##.#.##..#.#.##
#..#..#.....#.#.##..##.#...#...###.#...###.#...##.##..##.....##.####.#...
##.#.##.###..#...#######.###.###..#.##.##.#..##.....##....##.##.....#####
..#..##.#.###.....#..#..#.##.###.##..###.#.....##..##.#.#.######..##.....
.##..##.#.##.#.#####.....#.#....#...####.#..#.##.#..#..##.#.##.##..#...#.
#.#.#..##...#.#####..#.###.##.###...##...#..##......##.#.#.#.#.#..#.#...#
..###......####.######...###..#.#....#..#.....#..#.#..#.##..####.##.##...
#...#..####..##....#...#..####.#..#####.######..#.######..####.##...#.#.#
##..#..##.####.#..##.###.....###....#...####...#..##..#.####......##.####
.##.##.##.##....#..##.....#####.###....###..##..###..#....#.#.##..#.#####
.#.##..#.###..#.#.#...#..##...##.#.#..#..#.#..###...#..#.......#.#..#.#.#
###.......#.##.##.#..#..#.###.#####.##.#..###..#.#...##..#..#....###.####
.##.#....##.##.#.####.##.#####..#.####..##.##.###..##.#...##.####.#..#..#
..##..###.#.#####.#.#.....#...#.#.#..##..##..##..##..#.###...#.##...#.##.
.####.#.#.##.##.#...##.##..###....#..##.##..#...##.#.###...#.##.#..#.#.##
#.###..#..#..###....#.#...#.#..########.##.######.#.#....##.#.##.##....##
.##.#...#.#.##..#.#.##.###.##.#.....##........##.######...###...#########
..##.##....#.....####....#..#..#....###.##..#.......#..##.#.##.####...##.
##......##.##.###......#.####...#..#.#...#.#.##.#.#....##...##..#.#####.#
##.#.####..####..#.##..#..####.#.#..#.##..####.##..#.##.#.#...##....#....
###...#..##..#.#.#.##.##.#.#.#######.#.###.#...#.##.#.....##.#....#.#....
##.#.#######.#.#....#...##.####.....####.#.##.###.#.##...#.#...#..#...###
.###......##.#..##.###.#...#......##..###.#......#.#..#...#..##.#...####.
##.#..#.#.###.#..#..#####...#.##.###.#.#.###...##.##..####.###.#..##.#.#.
#...#.#.###......##.##...####...######..##...####.#..####.#.#..####...###
##.##.#.####.##.....#..###.###...#....#..###.##....#..#...#.##.##.....#.#
.####..#.#.###.....##.#....#.##.#.#..##.....#.####..##.#####.....#####..#
#...###.#####..###.#...##...#.#.##..#####..##.##.##..#...##.#..###.#####.
###.#####..#.####.#.#.#...#.#.#...####.###.#.#..###..#.####.##..##.#..#..
.#.....##...#.....##.#..###.#......#.##..##...####..##.#.##...#.#..#.###.
.#####.#..###.##.......#############.#.#.....##...#.##.##....###.#.##..##
####.#..#..#..##..#...#.#.#..##....#.########...####.####.#.###.....#.#..
.##..#.##....#.#...#.#.#...###.#.#..#.#.###.##...#.###..#...#.##.######..
#...#.####..#......#.....#######..#........###..##.#..##.#.#.#.###..##..#
.#.######.###.###.....#.#.####..##...#.##....#.##.##.####..###.#####.#.#.
...##...##.##..#.###.###.#......###.##.##.#.#.####.#.#..#...#...###...#..
..#....#....#.#..###.#....#####.#......#....#...#..#........#..##.###.##.
#.#..##.#.####.##..##....##..#.#...#..#.#..#.#.##..#.#.####...#..#####..#
.##.###.#.#.#.#.#.#.##.###.##.#.##.######.##..##.##......####....#....#..
.######..#####.#..#.#...#....###########.#.##.####.###.#....##.###..####.
..#####..##.#..##.#..#..#..##.#.###.#.#......######.#..#...###....#..####
###.##...####....##..###......##.#.#...##..#.##...#.##.#.#.#.##.##.##.#..
#..#.#.##.#.#.##..#..##.###..##.####...........#..####.#.##..#...#....#..
###...#####.#..#..#.##.##...####....#.#..####.#..##..##.##.###.##.###.##.
#.....##.##...###.#.#..###.#####..#.#..####..#..#...#.#...##.####.#..###.
115 changes: 115 additions & 0 deletions data/day25.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
2=-00=02-1
1-1=02=1220
1-000-00
12=-=0--=202-=
1==0=0210-1==1---
122110--01-
1-=1=-==02-12000
1=1=20-
11-1-21-02221=2--=
2=1--11001
210=-1020-=1-1
20-=
10-000=12=21202==
20222=2--21=
1020010
2-=1110=-0=2-
1==2=2-=1--=
100-
2211-==-021==
1=1
1-=1--==0
20220=1=-22
12
2-=002-102-2-
2-0-02
20001-020=01
1===-210--0010
2021=121-00-12=-1=
1-0-0==2=1
1-=01=
102=22=0=02
11=01-
2=0
20=-12=2121--
111102011=0000
22--12010-
1=-21202=-2=-2
1=2-=-2-1-
2-=1=112-1-
22=
1=--20-=000=0-11===
1--==
1000=1-1
1=1-01000
1=2--1=1
1=2-2=--2-00
1=00-=-0010-2
102
111101=21002=
211-=01-=
121--11=12022=-112
1==--0100-=0
2
1=-
220=-1=10--12
10---20--00
1==1111-
12-=0-0==010
2121=1
2==102=21=-2=20
201===-
1-00=11-200=-111012
1-022
1==1010--011-==-22
11==20=1122=12=2-1
1--0001=22
2020==2--
1===--0--
12=2---1
1-0100=-=-1--11
122====20=--2
1-0=-01==-
1-021
2-01==1=0
1=1-20=01121020==2
1=02=-2011--01=21
2-2110-=-
1=-=-002-==
2-=-
10-0
1=0=-1=
1=1=1
212-0
11100=
21=202-111-1=-012-1
22-=001=
11=21=0----010=-10
1=1=221
1221=
1=11=20=-0112-=2-=
2-1-02001
12-=0=120-1=--20=-
2=1---
2==--2=0---
10=-010
112
1-=1
1022100-=
1=220001000-1-1===
2==-2-00=02=10=-
21=2
2==1=02=-02
1=10
1-0202=
1--2=112021=-1112222
1-122=2=-10
1--2112--011-
2=1-=
2211211
1=021=-000
1101
1=2=120=
2=02
12-1
2-=0-=2-1-0112
27 changes: 13 additions & 14 deletions src/bin/day23.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ fn main() -> Result<(), Error> {
mod test {
use super::*;

const EXPECTED_5: &str = include_str!("../../data/day23_ex.txt");
const EXPECTED_10: &str = r#"xxx
const EXPECTED_5: &str = include_str!("../../data/day23_ex.txt");
const EXPECTED_10: &str = r#"xxx
.......#......
...........#..
..#.#..#......
Expand All @@ -374,17 +374,17 @@ mod test {
"#;

fn parse_expected(s: &str) -> Vec<Vec<Elf>> {
let mut exp = vec![];
for chunk in s.split("\n\n") {
let mut elves = vec![];
for (y, line) in chunk.lines().enumerate().skip(1) {
elves.extend(handle_line((y as isize - 3, line), 3));
}
exp.push(elves);
}
exp
}
fn parse_expected(s: &str) -> Vec<Vec<Elf>> {
let mut exp = vec![];
for chunk in s.split("\n\n") {
let mut elves = vec![];
for (y, line) in chunk.lines().enumerate().skip(1) {
elves.extend(handle_line((y as isize - 3, line), 3));
}
exp.push(elves);
}
exp
}

#[test]
fn test_parse() {
Expand Down Expand Up @@ -414,4 +414,3 @@ mod test {
assert_eq!(rounds, 20);
}
}

106 changes: 106 additions & 0 deletions src/bin/day24.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
use anyhow::Error;
use enum_iterator::Sequence;
use euclid::vec2;
use structopt::StructOpt;

type Coord = i64;
type Point = euclid::default::Point2D<Coord>;
type Box = euclid::default::Box2D<Coord>;
type Vector = euclid::default::Vector2D<Coord>;
type Rect = euclid::default::Rect<Coord>;

const DATA: &str = include_str!("../../data/day23.txt");
const SAMPLE: &str = r#"....#..
..###.#
#...#.#
.#...##
#.###..
##.#.##
.#..#.."#;

#[derive(Debug, PartialEq, Eq, Clone, Copy, Sequence)]
#[repr(usize)]
enum Direction {
North,
South,
West,
East,
}

impl Direction {
fn as_char(&self) -> char {
(*self).into()
}
}

impl Into<Vector> for Direction {
fn into(self) -> Vector {
match self {
Direction::North => vec2(0, -1),
Direction::East => vec2(1, 0),
Direction::South => vec2(0, 1),
Direction::West => vec2(-1, 0),
}
}
}

impl Into<char> for Direction {
fn into(self) -> char {
match self {
Direction::North => '^',
Direction::East => '>',
Direction::South => 'v',
Direction::West => '<',
}
}
}

fn parse(_s: &str) -> () {}

fn solve_part_1() -> usize {
todo!();
}

fn solve_part_2() -> usize {
todo!();
}

#[derive(Debug, StructOpt)]
#[structopt(name = "day24", about = "Blizzard Basin")]
struct Opt {
/// Use puzzle input instead of the sample
#[structopt(short, long)]
puzzle_input: bool,
}

fn main() -> Result<(), Error> {
let opt = Opt::from_args();

let _ = parse(if opt.puzzle_input { DATA } else { SAMPLE });

let p1 = solve_part_1();
println!("part 1 = {}", p1);

println!("part 2 = {}", solve_part_2());

Ok(())
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_parse() {
let _ = parse(SAMPLE);
todo!();
}

#[test]
#[ignore]
fn test_part_1() {}

#[test]
#[ignore]
fn test_part_2() {}
}
Loading

0 comments on commit 0deacea

Please sign in to comment.