Skip to content
This repository has been archived by the owner on Jan 1, 2021. It is now read-only.

ramonsantos/hell-triangle-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hell Triangle

Codacy Badge license

Challenge

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

Example:

   6
  3 5
 9 7 1
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:

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

sudo dnf install ruby rubygems

Install Rake and Bundler Gems

gem install rake bundler

Install Project Dependencies

bundle install

Run Tests

rake test

Releases

No releases published

Packages

No packages published

Languages