This commit is contained in:
kageru 2021-12-21 23:39:43 +01:00
parent 4dee357ea1
commit c47f381a3b
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2
5 changed files with 9 additions and 9 deletions

View File

@ -11,15 +11,15 @@ const DAY: usize = '$today';
type Parsed = Vec<usize>;
fn parse_input(raw: &str) -> Parsed {
unimplemented!()
todo!()
}
fn part1(parsed: &Parsed) -> usize {
unimplemented!()
todo!()
}
fn part2(parsed: &Parsed) -> usize {
unimplemented!()
todo!()
}
fn main() {

View File

@ -44,7 +44,7 @@ fn part2(parsed: &Parsed) -> usize {
possible_paths(parsed, &Node::Start, &Vec::new(), true)
}
fn possible_paths<'a>(map: &'a Parsed, position: &'a Node<'a>, visited: &Vec<&'a Node<'a>>, small_cave_allowed: bool) -> usize {
fn possible_paths<'a>(map: &'a Parsed, position: &'a Node<'a>, visited: &[&'a Node<'a>], small_cave_allowed: bool) -> usize {
map.get(position)
.unwrap()
.iter()

View File

@ -35,8 +35,8 @@ fn part1(parsed: &Parsed, grid_size: usize) -> usize {
}
}
fn part2(parsed: &Parsed) -> usize {
unimplemented!()
fn part2(_parsed: &Parsed) -> usize {
todo!()
}
fn main() {

View File

@ -1,3 +1,4 @@
#![allow(unused)]
#![feature(test)]
extern crate test;
use aoc2021::common::*;

View File

@ -60,12 +60,11 @@ fn step(grid: HashGrid<Pixel, 2>, lookup: &[Pixel; 512], iteration: usize) -> Ha
const OUTSIDE: [Pixel; 2] = [Pixel::Dark, Pixel::Bright];
fn lookup_index(p: Position2D, grid: &HashGrid<Pixel, 2>, iteration: usize) -> usize {
let idx = neighbors_plus_self(p)
neighbors_plus_self(p)
.into_iter()
.rev()
.map(|p| grid.get(&p).unwrap_or(&OUTSIDE[iteration & 1]) == &Pixel::Bright)
.fold(0, |acc, n| (acc << 1) | n as usize);
idx
.fold(0, |acc, n| (acc << 1) | n as usize)
}
fn step_times(grid: &HashGrid<Pixel, 2>, lookup: &[Pixel; 512], iterations: usize) -> usize {