Skip to content

Instantly share code, notes, and snippets.

/test

Created September 28, 2016 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b46038b7cf6d09918418c15e082069bd to your computer and use it in GitHub Desktop.
Save anonymous/b46038b7cf6d09918418c15e082069bd to your computer and use it in GitHub Desktop.
class Person
attr_accessor :name
def test(a)
min = 0
max = a.count()-1
puts max
puts "****"
a.each_with_index do |el, idx|
array = el
arrayMin = a[0,idx]
arrayMinSum = arrayMin.inject(:+)
arrayMax = a[idx+1, max]
arrayMaxSum = arrayMax.inject(:+)
if arrayMinSum == arrayMaxSum
puts a[idx]
end
sleep 1
end
end
end
puts " "
person = Person.new
a = [-1,3,-4,5,1,-6,2,1]
person.test(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment