From 174772b5b8d9f5bf5e3c8e8152adfd89f0e83f6b Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Tue, 19 Apr 2022 20:22:56 +0200 Subject: Refile for merging repos --- aoc18/src/main.rs | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 aoc18/src/main.rs (limited to 'aoc18/src/main.rs') diff --git a/aoc18/src/main.rs b/aoc18/src/main.rs deleted file mode 100644 index 52ad7a9..0000000 --- a/aoc18/src/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -fn main() { - let init: Vec = ".^^..^...^..^^.^^^.^^^.^^^^^^.^.^^^^.^^.^^^^^^.^...^......^...^^^..^^^.....^^^^^^^^^....^^...^^^^..^".chars().collect(); - - let mut map = Vec::new(); - map.push(init); - - for _ in 1..400000 { - let last = map.last().unwrap().clone(); - let mut next = Vec::new(); - for i in 0..last.len() { - let left = if i == 0 { '.' } else { last[i-1] }; - let right = if i == last.len()-1 { '.' } else { last[i+1] }; - next.push(if left == right { '.' } else { '^' }); - } - map.push(next); - } - - let safe_count = map.iter().map(|row| row.iter().filter(|&&c| c=='.').count() as u32).sum::(); - println!("Safe tiles: {}", safe_count); -} -- cgit v1.2.3