MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/3uyl7s/daily_programming_puzzles_at_advent_of_code/cxjdzmi/?context=3
r/programming • u/Aneurysm9 • Dec 01 '15
179 comments sorted by
View all comments
Show parent comment
2
Here's the second part written in a functional Rust style:
fn santa_functional(input: &str) -> usize { input.chars() .scan(0, |f, c| { *f += match c { '(' => 1, ')' => -1, _ => 0 }; Some(*f) }) .take_while(|&f| f != -1) .count() + 1 }
View all comments
Show parent comment
2
u/CryZe92 Dec 01 '15 edited Dec 01 '15
Here's the second part written in a functional Rust style: