Hopefully the last optimization for Day 17
5x faster, pog. I’m an idiot.
This commit is contained in:
parent
b7d6d40394
commit
b3e81ed412
|
@ -1,5 +1,6 @@
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
use itertools::Itertools;
|
||||||
use aoc2020::{
|
use aoc2020::{
|
||||||
common::*, grid::{cell::Cell, *}
|
common::*, grid::{cell::Cell, *}
|
||||||
};
|
};
|
||||||
|
@ -26,6 +27,7 @@ fn make_step<P: Position>(input: Grid<P, Cell>) -> Grid<P, Cell> {
|
||||||
.fields
|
.fields
|
||||||
.keys()
|
.keys()
|
||||||
.flat_map(|p| p.neighbors())
|
.flat_map(|p| p.neighbors())
|
||||||
|
.unique()
|
||||||
.map(|pos| {
|
.map(|pos| {
|
||||||
let cell = readonly.get(&pos);
|
let cell = readonly.get(&pos);
|
||||||
let new = match (&cell, count_live_neighbors(&pos, &readonly)) {
|
let new = match (&cell, count_live_neighbors(&pos, &readonly)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user