Practicing various algorithms in Ruby