Solution for RubyWarrior Beginner Epic mode. Score: 646