Day 6 part 2, put data on stack

This commit is contained in:
Bill Thiede 2021-12-06 15:50:10 -08:00
parent 44c0c16255
commit 6acaaf8b7a

View File

@ -80,7 +80,7 @@ fn part1(input: &str) -> Result<usize> {
#[aoc(day6, part2)] #[aoc(day6, part2)]
fn part2(input: &str) -> Result<usize> { fn part2(input: &str) -> Result<usize> {
let mut counts = vec![0; 9]; let mut counts = [0; 9];
input input
.split(',') .split(',')
.map(|s| s.parse()) .map(|s| s.parse())
@ -88,7 +88,7 @@ fn part2(input: &str) -> Result<usize> {
.into_iter() .into_iter()
.for_each(|n| counts[n] += 1); .for_each(|n| counts[n] += 1);
for _ in 0..256 { for _ in 0..256 {
let mut tmp = vec![0; 9]; let mut tmp = [0; 9];
for i in 0..9 { for i in 0..9 {
if i == 0 { if i == 0 {
tmp[6] += counts[0]; tmp[6] += counts[0];