Last active
          August 29, 2015 14:07 
        
      - 
      
 - 
        
Save ajkamel/0b368a9a88d5a018714f to your computer and use it in GitHub Desktop.  
Revisions
- 
        
ajkamel revised this gist
Oct 10, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ I first found this problem when looking at a Yodle engineering challenge questio Basically you this takes a file with lines of numbers and finds the largest sum by totaling the largest adjacent numbers for each new line. ```ruby triangle_array = [] f = File.open("triangle.txt", "r")  - 
        
ajkamel renamed this gist
Oct 4, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
ajkamel renamed this gist
Oct 4, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
ajkamel renamed this gist
Oct 4, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
ajkamel revised this gist
Oct 4, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ I first found this problem when looking at a Yodle engineering challenge question. Basically you this takes a file with lines of numbers and finds the largest sum by totaling the largest adjacent numbers for each new line. ``` triangle_array = []  - 
        
ajkamel revised this gist
Oct 4, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ I first found this problem when looking at a Yodle engineering challenge question. Basically this solution takes a file with lines of numbers and finds the largest sum by totaling the largest adjacent numbers for each new line. ``` triangle_array = []  - 
        
ajkamel renamed this gist
Oct 4, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
ajkamel renamed this gist
Oct 4, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
ajkamel revised this gist
Oct 4, 2014 . No changes.There are no files selected for viewing
 - 
        
ajkamel revised this gist
Oct 4, 2014 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ I first found this problem when looking at a Yodle engineering challenge question. Basically you this takes a file with lines of numbers and finds the largest sum by totaling the largest adjacent numbers for each new line. ``` triangle_array = []  - 
        
ajkamel created this gist
Oct 4, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ ``` triangle_array = [] f = File.open("triangle.txt", "r") f.each_line do |line| triangle_array << line.split.map(&:to_i) end f.close lines = triangle_array.length for i in (lines-2).downto(0).to_a do for j in (i).downto(0).to_a do triangle_array[i][j] += [triangle_array[i+1][j].to_i,triangle_array[i+1][j+1].to_i].max end end p triangle_array[0][0] ```