项目作者: ramonsantos

项目描述 :
Hell Triangle Challenge
高级语言: Ruby
项目地址: git://github.com/ramonsantos/hell-triangle-challenge.git
创建时间: 2018-02-14T02:36:26Z
项目社区:https://github.com/ramonsantos/hell-triangle-challenge

开源协议:MIT License

下载


Hell Triangle

Codacy Badge
license

Challenge

Given a triangle of numbers, find the maximum total from top to bottom.

Example:

  1. 6
  2. 3 5
  3. 9 7 1
  4. 4 6 8 4

In this triangle the maximum total is: ​ 6 + 5 + 7 + 8 = 26

An element can only be summed with one of the two nearest elements in the next row.
For example: The element 3 in the 2nd row can only be summed with 9 and 7, but not with
1.

Your code will receive an (multidimensional) array as input.
The triangle from above would be:

  1. example = [[6],[3,5],[9,7,1],[4,6,8,4]]

Why Ruby?

The programming language chosen to solve this challenge was Ruby. Some of the main reasons for the choice are:

  • Dynamism;
  • Readability;
  • Professional experience.

How to Run?

Install Ruby and Rubygems

Example of installation on Fedora

  1. sudo dnf install ruby rubygems

Install Rake and Bundler Gems

  1. gem install rake bundler

Install Project Dependencies

  1. bundle install

Run Tests

  1. rake test