switched to workspaces.
This should let me make a cross-day library.
This commit is contained in:
parent
1469c3a32b
commit
242989bb95
57 changed files with 156 additions and 89 deletions
23
days/day06/src/part1.rs
Normal file
23
days/day06/src/part1.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use crate::utilities::*;
|
||||
|
||||
pub fn part1(input: &str) -> usize {
|
||||
input
|
||||
.as_bytes()
|
||||
.windows(4)
|
||||
.position(|x| !find_dupes_stupid(x))
|
||||
.unwrap()+4
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_part1() {
|
||||
assert_eq!(part1("mjqjpqmgbljsphdztnvjfqwrcgsmlb"), 7);
|
||||
assert_eq!(part1("bvwbjplbgvbhsrlpgdmjqwftvncz"), 5);
|
||||
assert_eq!(part1("nppdvjthqldpwncqszvftbrmjlhg"), 6);
|
||||
assert_eq!(part1("nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg"), 10);
|
||||
assert_eq!(part1("zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw"), 11);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue