-
-
Save anonymous/b46038b7cf6d09918418c15e082069bd to your computer and use it in GitHub Desktop.
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
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