Basic algorithms implemented in Python, Ruby, Java and Haskell