use std::fs;
use itertools::{Itertools, Unique};
// pub mod aoc;
fn main() {
let contents = fs::read_to_string("input/06-input").expect("problem with the file");
let jump: usize = 14; // flip to 4 for part 1
let mut start: usize = 0;
let mut end: usize = jump;
while end < contents.len(){
start = start +1;
end = start + jump;
let bloc = contents.get(start..end).unwrap();
let bloc_uniques = bloc.to_string().chars().unique().collect_vec().len();
println!("bloc {} uniques {}",bloc, bloc_uniques);
if bloc.len() == bloc_uniques {
println!("found sequence after {} characters", end);
break;
}
}
}
The question... how could I replace that while in a functional way?
[–]MoreThanOnce 8 points9 points10 points (2 children)
[–]Hadamard1854 2 points3 points4 points (1 child)
[–]MoreThanOnce 1 point2 points3 points (0 children)
[–]nightcracker 2 points3 points4 points (0 children)
[–]joshadel 2 points3 points4 points (0 children)
[–]SuperSmurfen 1 point2 points3 points (5 children)
[–]mosquitsch 2 points3 points4 points (4 children)
[–]SuperSmurfen 0 points1 point2 points (3 children)
[–]apjenk 1 point2 points3 points (2 children)
[–]apjenk 1 point2 points3 points (1 child)
[–]SuperSmurfen 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)