Hopefully the last optimization for Day 17

5x faster, pog. I’m an idiot.
This commit is contained in:
kageru 2020-12-17 17:17:00 +01:00
parent b7d6d40394
commit b3e81ed412
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -1,5 +1,6 @@
#![feature(test)]
extern crate test;
use itertools::Itertools;
use aoc2020::{
common::*, grid::{cell::Cell, *}
};
@ -26,6 +27,7 @@ fn make_step<P: Position>(input: Grid<P, Cell>) -> Grid<P, Cell> {
.fields
.keys()
.flat_map(|p| p.neighbors())
.unique()
.map(|pos| {
let cell = readonly.get(&pos);
let new = match (&cell, count_live_neighbors(&pos, &readonly)) {