mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 12:50:32 +01:00
Simplify the "find" operation.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use common;
|
||||
use itertools::Itertools;
|
||||
use std::io::prelude::*;
|
||||
use std::io::BufReader;
|
||||
|
||||
@@ -36,10 +35,7 @@ impl Day21 {
|
||||
|
||||
fn find(&self, search: &str) -> usize {
|
||||
let c = search.chars().next().unwrap();
|
||||
match self.password.iter().find_position(|&&x| x == c) {
|
||||
Some((pos, _)) => pos,
|
||||
_ => panic!("Char not in password: {}", c)
|
||||
}
|
||||
self.password.iter().position(|&x| x == c).unwrap()
|
||||
}
|
||||
|
||||
fn reverse_range(&mut self, pos_1: usize, pos_2: usize)
|
||||
|
||||
Reference in New Issue
Block a user