ruby algo for game of life