diff --git a/aoc2015/src/day05.rs b/aoc2015/src/day05.rs index 942a5e5..5efdf56 100644 --- a/aoc2015/src/day05.rs +++ b/aoc2015/src/day05.rs @@ -41,10 +41,10 @@ fn part1(input: &str) -> usize { false }) - .filter(|line| line.find("ab").is_none()) - .filter(|line| line.find("cd").is_none()) - .filter(|line| line.find("pq").is_none()) - .filter(|line| line.find("xy").is_none()) + .filter(|line| !line.contains("ab")) + .filter(|line| !line.contains("cd")) + .filter(|line| !line.contains("pq")) + .filter(|line| !line.contains("xy")) .count() } @@ -56,7 +56,7 @@ fn part2(input: &str) -> usize { for i in 0..(line.chars().count() - 3) { let seq = &line[i..(i + 2)]; let line = &line[(i + 2)..]; - if line.find(seq).is_some() { + if line.contains(seq) { return true; } } diff --git a/aoc2018/src/day04.rs b/aoc2018/src/day04.rs index 879bf67..cab4b8a 100644 --- a/aoc2018/src/day04.rs +++ b/aoc2018/src/day04.rs @@ -31,11 +31,11 @@ impl FromStr for Event { type Err = anyhow::Error; fn from_str(s: &str) -> Result { - if s.find("wakes up").is_some() { + if s.contains("wakes up") { Ok(Event::WakeUp) - } else if s.find("falls asleep").is_some() { + } else if s.contains("falls asleep") { Ok(Event::FallAsleep) - } else if s.find("begins shift").is_some() { + } else if s.contains("begins shift") { let pound = s.find('#').context("`#` not found")?; let s = &s[(pound + 1)..]; let space = s.find(' ').context("` ` not found after `#`")?; diff --git a/aoc2019/src/day03.rs b/aoc2019/src/day03.rs index d77b719..40a1f9a 100644 --- a/aoc2019/src/day03.rs +++ b/aoc2019/src/day03.rs @@ -48,7 +48,7 @@ fn part2(first_wire: &Wire, second_wire: &Wire) -> Result { let mut second_length = 0; for seg2 in &second_wire.0 { - if let Some(inter) = seg1.intersection(&seg2) { + if let Some(inter) = seg1.intersection(seg2) { if inter.x == 0 && inter.y == 0 { continue; } diff --git a/aoc2019/src/day06.rs b/aoc2019/src/day06.rs index 3c7a134..5d2767e 100644 --- a/aoc2019/src/day06.rs +++ b/aoc2019/src/day06.rs @@ -49,7 +49,7 @@ fn part1(input: &str) -> Result { let mut cache = HashMap::new(); Ok(orbits .keys() - .map(|k| count_orbits(&k, &orbits, &mut cache)) + .map(|k| count_orbits(k, &orbits, &mut cache)) .sum()) } diff --git a/aoc2020/src/day04.rs b/aoc2020/src/day04.rs index f79a908..74d021e 100644 --- a/aoc2020/src/day04.rs +++ b/aoc2020/src/day04.rs @@ -154,16 +154,16 @@ impl CompletePassport { fn hgt_valid(&self) -> bool { if let Some(num) = self.hgt.strip_suffix("in") { - is_number_in_range(&num, 59..=76) + is_number_in_range(num, 59..=76) } else if let Some(num) = self.hgt.strip_suffix("cm") { - is_number_in_range(&num, 150..=193) + is_number_in_range(num, 150..=193) } else { false } } fn hcl_valid(&self) -> bool { - if let Some(rest) = self.hcl.strip_prefix("#") { + if let Some(rest) = self.hcl.strip_prefix('#') { rest.chars().filter(|c| !c.is_ascii_hexdigit()).count() == 0 } else { false diff --git a/aoc2020/src/day11.rs b/aoc2020/src/day11.rs index b438df0..8a05a0a 100644 --- a/aoc2020/src/day11.rs +++ b/aoc2020/src/day11.rs @@ -64,13 +64,13 @@ impl Layout { match cell { Cell::EmptySeat => { - if adj_count(&self, i, j, Cell::OccupiedSeat) == 0 { + if adj_count(self, i, j, Cell::OccupiedSeat) == 0 { new[i][j] = Cell::OccupiedSeat; changed = true; } } Cell::OccupiedSeat => { - if adj_count(&self, i, j, Cell::OccupiedSeat) >= occupied_threshold { + if adj_count(self, i, j, Cell::OccupiedSeat) >= occupied_threshold { new[i][j] = Cell::EmptySeat; changed = true; } diff --git a/aoc2020/src/day24.rs b/aoc2020/src/day24.rs index 703c790..9992e86 100644 --- a/aoc2020/src/day24.rs +++ b/aoc2020/src/day24.rs @@ -99,7 +99,7 @@ fn part2(input: &str) -> Result { let count = neighbours .iter() - .filter(|tile| black_tiles.contains(&tile)) + .filter(|tile| black_tiles.contains(tile)) .count(); if black_tiles.contains(&tile) { // Any black tile with zero or more than 2 black tiles immediately adjacent to it is