Ruby script for coding challenge