Skip to content

Instantly share code, notes, and snippets.

@rodcul
Created April 28, 2015 08:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rodcul/6972a998ee28b4f21f3d to your computer and use it in GitHub Desktop.
Save rodcul/6972a998ee28b4f21f3d to your computer and use it in GitHub Desktop.
Wolf of Commercial Street
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