Jet interview question

Simple algorithms, a bit of functional programming concepts.