Random toy problem Ruby code