My solution for Rubywarrior.