Skip to content

Commit 8b354a6

Browse files
committed
Some tweaks
1 parent 345def5 commit 8b354a6

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

day08b/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn main() {
3232
},
3333
})
3434
.enumerate()
35-
.fold(0, |sum, (i, n)| sum + n * 10_u32.pow(3 - i as u32))
35+
.fold(0, |acc, (i, n)| acc + n * 10_u32.pow(3 - i as u32))
3636
})
3737
.sum::<u32>()
3838
);

day09b/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
const NEXT: [(isize, isize); 4] = [(0, -1), (0, 1), (-1, 0), (1, 0)];
22

33
pub fn main() {
4-
let mut input = include_bytes!("../input.txt")
4+
let mut map = include_bytes!("../input.txt")
55
.split(|&b| b == b'\n')
66
.map(|l| l.to_vec())
7-
.collect::<Vec<Vec<u8>>>();
7+
.collect::<Vec<_>>();
88

99
let mut basins = vec![];
10-
for y in 0..input.len() {
11-
for x in 0..input[0].len() {
12-
(input[y][x] < b'9').then(|| basins.push(basin(&mut input, x, y)));
10+
for y in 0..map.len() {
11+
for x in 0..map[0].len() {
12+
(map[y][x] < b'9').then(|| basins.push(basin(&mut map, x, y)));
1313
}
1414
}
1515

day10a/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn main() {
77
.lines()
88
.filter_map(|seq| seq
99
.bytes()
10-
.scan(Vec::with_capacity(110), |s, c| Some(match c {
10+
.scan(Vec::with_capacity(64), |s, c| Some(match c {
1111
c if matches!(c, b'(' | b'[' | b'{' | b'<') => (s.push(c) != ()).then(|| b' '),
1212
b')' => (s.pop().unwrap() != b'(').then(|| b')'),
1313
c => (s.pop().unwrap() != c - 2).then(|| c),

day10b/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub fn main() {
44
let mut scores = include_str!("../input.txt")
55
.lines()
66
.filter_map(|seq| {
7-
let mut s = Vec::with_capacity(110);
7+
let mut s = Vec::with_capacity(64);
88
seq.bytes()
99
.all(|c| match c {
1010
c if matches!(c, b'(' | b'[' | b'{' | b'<') => s.push(c) == (),

0 commit comments

Comments
 (0)