summaryrefslogtreecommitdiffstats
path: root/2021/day9
diff options
context:
space:
mode:
authorYigit Sever2021-12-14 00:00:46 +0300
committerYigit Sever2022-12-02 21:44:22 +0300
commitb5715d6b6e7d60e8b662ad4b46f0e1f1e7e445c1 (patch)
treefe4d4fa93eccaf11f4d8f21cc7c336a09e1519ac /2021/day9
parent1a844dd44f8f9a457dcbcdbf5cfdb7e3b73f8358 (diff)
downloadaoc-b5715d6b6e7d60e8b662ad4b46f0e1f1e7e445c1.tar.gz
aoc-b5715d6b6e7d60e8b662ad4b46f0e1f1e7e445c1.tar.bz2
aoc-b5715d6b6e7d60e8b662ad4b46f0e1f1e7e445c1.zip
2021, day9: fluff
Diffstat (limited to '2021/day9')
-rw-r--r--2021/day9/src/main.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/2021/day9/src/main.rs b/2021/day9/src/main.rs
index 5d84be9..524fb1b 100644
--- a/2021/day9/src/main.rs
+++ b/2021/day9/src/main.rs
@@ -43,14 +43,19 @@ fn main() {
43 .get(ndx) 43 .get(ndx)
44 .unwrap_or(&9); 44 .unwrap_or(&9);
45 45
46 let down = match points.get(idx + 1) { 46 let down = points
47 Some(line) => line.get(ndx).unwrap_or(&9), 47 .get(idx + 1)
48 None => &9, 48 .unwrap_or_else(|| &nine)
49 }; 49 .get(ndx)
50 .unwrap_or_else(|| &9);
50 51
51 let left = height.get((ndx as isize - 1) as usize).unwrap_or(&9); 52 let left = height
53 .get((ndx as isize - 1) as usize)
54 .unwrap_or_else(|| &9);
52 55
53 let right = height.get(ndx + 1).unwrap_or(&9); 56 let right = height
57 .get((ndx as isize + 1) as usize)
58 .unwrap_or_else(|| &9);
54 59
55 if num < up && num < down && num < right && num < left { 60 if num < up && num < down && num < right && num < left {
56 risk_level += 1 + *num; 61 risk_level += 1 + *num;