From 714c699f9beccdb27e56c0bdf31cee2ce936da8c Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 6 Dec 2022 21:31:31 +0100 Subject: [PATCH] Wrote custom check which is way faster --- 2022/Cargo.toml | 1 - 2022/src/bin/day6.rs | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/2022/Cargo.toml b/2022/Cargo.toml index 82f2248..ea67c1c 100644 --- a/2022/Cargo.toml +++ b/2022/Cargo.toml @@ -9,4 +9,3 @@ edition = "2021" anyhow = "1.0" regex = "1" lazy_static = "1.4.0" -itertools = "0.10.5" diff --git a/2022/src/bin/day6.rs b/2022/src/bin/day6.rs index 19e288a..b460eec 100644 --- a/2022/src/bin/day6.rs +++ b/2022/src/bin/day6.rs @@ -1,7 +1,6 @@ #![feature(test)] use anyhow::Result; use aoc::Solver; -use itertools::Itertools; // -- Runners -- fn main() -> Result<()> { @@ -70,7 +69,15 @@ mod tests { // -- Helpers -- fn is_start_marker(window: &[char]) -> bool { - window.len() == window.iter().unique().count() + for i in 0..window.len() { + for j in i+1..window.len() { + if window[i] == window[j] { + return false; + } + } + } + + return true; } fn solution(input: &str, length: usize) -> usize {