ruby: triangle max line sum