Solved prob 34 and learn scala pattern matching