Created
April 28, 2015 08:49
-
-
Save rodcul/6972a998ee28b4f21f3d to your computer and use it in GitHub Desktop.
Wolf of Commercial Street
This file contains 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 characters
def makemerich(array) | |
output = Array.new | |
diff = 0 | |
array.each_with_index do |item1,index1| | |
array.each_with_index do |item2,index2| | |
n = 0 | |
n = item2-item1 if index2 > index1 | |
output = index1,index2 if n > diff | |
end | |
end | |
output.inspect | |
end | |
puts makemerich([1, 3, 1, 1, 1]) # == [0,1] This will test when the biggest jump is first | |
puts makemerich([7, 9, 7, 5, 8]) # == [3,4] This will test when the biggest jump is not first |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment