SHARE
TWEET

Untitled

a guest Apr 19th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def threeSplit(a)
  2.    
  3.     s = a.sum/3
  4.     count = 0
  5.     s1 = 0
  6.     s2 = 0
  7.    
  8.     (0..a.size-3).each do |cut1|
  9.         s1 += a[cut1]
  10.         if(s1 == s)
  11.             s2 = 0
  12.             ((cut1+1)..a.size-2).each do |cut2|
  13.                 s2 += a[cut2]
  14.                if(s == s2)
  15.                    count += 1
  16.                end
  17.             end
  18.         end
  19.     end
  20.     count
  21. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top