Write a function:
def solution(A)
that, given a non-empty zero-indexed array A of N integers, returns the minimal difference that can be achieved.
For example, given: A[0] = 3 A[1] = 1 A[2] = 2 A[3] = 4 A[4] = 3
the function should return 1, as explained above.
Assume that:
    N is an integer within the range [2..100,000];
    each element of array A is an integer within the range [−1,000..1,000].
Complexity:
    expected worst-case time complexity is O(N);
    expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
Elements of input arrays can be modified.
In [1]:
    
A = [3,1,2,4,3]
    
V1. broken Testing. Changing the iteration values to be used.
Designing the function
In [2]:
    
def tape_int_1(data):
    
    left_side_sum = 0
    
    right_side_sum = sum(data[:])
    
    min_diff = abs(left_side_sum - right_side_sum)
    
    print "\n initial min_diff: ", min_diff, 
    
    print "\ninitial left side sum: ", left_side_sum
    
    print "initial right side sum: ", right_side_sum , "\n"
    
    for counter,num in enumerate(data):
        if counter == 0: continue
        pre_num = data[counter-1]
        
        left_side_sum += pre_num
        
        right_side_sum -= pre_num
        
        right_side_sum += num
        
        print "\n pre_num: ", pre_num
        
        print "current num: ", num
        
        print "left_sum: ", left_side_sum
        
        print "right_sum: ", right_side_sum, "\n"
        
        current_diff = abs( left_side_sum - right_side_sum)
                           
        print "current diff: ", current_diff, "\n"
        
        if min_diff > current_diff:
            min_diff = current_diff
        
        print "\n current min_diff: ", min_diff
        
        #print "pre_num: ", pre_num
        
        #print "current num: ", num
        
        #print "left_sum: ", left_side_sum
        
        #print "right_sum: ", right_side_sum
                
        #print "current diff: ", current_diff, "\n"
        
        if counter >= len(data) -1:
            return min_diff
    
In [3]:
    
print A
print tape_int_1(A)
    
    
V2.
In [4]:
    
def tape_int_2(data):
    
    left_side_sum = 0
    
    right_side_sum = sum(data[:])
    
    min_diff = abs(left_side_sum - right_side_sum)
    
    print "\n initial min_diff: ", min_diff, 
    
    print "\ninitial left side sum: ", left_side_sum
    
    print "initial right side sum: ", right_side_sum , "\n"
    
    for num in data:
        #if counter == 0: continue
        #pre_num = data[counter-1]
        
        left_side_sum += num
        
        right_side_sum -= num
        
        #right_side_sum += num
        
        #print "\n pre_num: ", num
        
        print "current num: ", num
        
        print "left_sum: ", left_side_sum
        
        print "right_sum: ", right_side_sum, "\n"
        
        current_diff = abs( left_side_sum - right_side_sum)
                           
        print "current diff: ", current_diff, "\n"
        
        if min_diff > current_diff:
            min_diff = current_diff
        
        print "\n current min_diff: ", min_diff
        
        #print "pre_num: ", pre_num
        
        #print "current num: ", num
        
        #print "left_sum: ", left_side_sum
        
        #print "right_sum: ", right_side_sum
                
        #print "current diff: ", current_diff, "\n"
        
        #if counter >= len(data) -1:
    return min_diff
    
In [5]:
    
print A
print tape_int_2(A)
    
    
For example, given: A[0] = 3 A[1] = 1 A[2] = 2 A[3] = 4 A[4] = 3
the function should return 1, as explained above.
Initial Test complete.
V2.1
In [6]:
    
def tape_int_2_1(data):
    
    left_side_sum = 0
    
    right_side_sum = sum(data[:])
    
    min_diff = abs(left_side_sum - right_side_sum)
    
    for num in data:
        left_side_sum += num
        
        right_side_sum -= num
        
        current_diff = abs( left_side_sum - right_side_sum)
                           
        if min_diff > current_diff:
            min_diff = current_diff
        
    return min_diff
    
Testing - the code
Empty List
In [7]:
    
empty_list  = list()
print empty_list
    
    
In [8]:
    
print empty_list
print tape_int_2_1(empty_list)
    
    
Designing Data function for testing
In [9]:
    
def random_test_data(start,stop,size):
    import random
    
    return random.sample(xrange(start,stop), size)
    
In [10]:
    
small_simple_data = random_test_data(0,10,10)
print small_simple_data
print type(small_simple_data)
    
    
In [11]:
    
print tape_int_2_1(small_simple_data)
    
    
V_2_2 test cases
In [12]:
    
double_list = [1,2]
print double_list
print tape_int_2_1(double_list)
    
    
In [13]:
    
def tape_int_2_2(data):
    
    left_side_sum = 0
    
    right_side_sum = sum(data[:])
    
    print "\ninitial left side sum: ", left_side_sum
    
    print "initial right side sum: ", right_side_sum , 
    
    min_diff = abs(left_side_sum - right_side_sum)
    
    print "\n initial min_diff: ", min_diff, "\n"
    
    for i,num in enumerate(data):
        if i == len(data) - 1: break
        
        left_side_sum += num
        
        right_side_sum -= num
        
        print "current num: ", num
        
        print "left_sum: ", left_side_sum
        
        print "right_sum: ", right_side_sum, "\n"
        
        current_diff = abs( left_side_sum - right_side_sum)
        
        print "current diff: ", current_diff, "\n"
                           
        if min_diff > current_diff:
            min_diff = current_diff
            print "min diff: ", min_diff
        
    return min_diff
    
In [14]:
    
print double_list
print tape_int_2_2(double_list)
    
    
In [15]:
    
double_list_1 = [-2000,2000]
print double_list
print tape_int_2_2(double_list_1)
    
    
V2_3
In [16]:
    
def tape_int_2_3(data):
    
    if len(data) == 0:
        return 0
    
    elif len(data) == 1:
        left_side_sum = 0
        
        right_side_sum = data[0]
    else:
    
        left_side_sum = data[0]
        
        right_side_sum = sum(data[1:])
        
    print "\ninitial left side sum: ", left_side_sum
    
    print "initial right side sum: ", right_side_sum , 
    
    min_diff = abs(left_side_sum - right_side_sum)
    
    print "\n initial min_diff: ", min_diff, "\n"
    
    pre_num = 0
    
    for i,num in enumerate(data):
        if i < 2:
            pre_num = num
            continue
        
        left_side_sum += pre_num
        
        right_side_sum -= pre_num
        
        #right_side_sum += num
        
        print "current num: ", num
        
        print "left_sum: ", left_side_sum
        
        print "right_sum: ", right_side_sum, "\n"
        
        current_diff = abs( left_side_sum - right_side_sum)
        
        print "current diff: ", current_diff, "\n"
        
        pre_num = num
                           
        if min_diff > current_diff:
            min_diff = current_diff
            print "min diff: ", min_diff
            
    return min_diff
    
In [17]:
    
double_list_1 = [-2000,2000]
print double_list
print tape_int_2_3(double_list_1)
    
    
In [18]:
    
print tape_int_2_3(empty_list)
    
    
In [19]:
    
print A
print tape_int_2_3(A)
    
    
In [20]:
    
single_list = random_test_data(-2000,2000,1)
print single_list
print (len(single_list))
print tape_int_2_3(single_list)
    
    
In [21]:
    
def tape_int_2_3_1(data):
    
    if len(data) == 0:
        return 0
    
    elif len(data) == 1:
        left_side_sum = 0
        
        right_side_sum = data[0]
    else:
    
        left_side_sum = data[0]
        
        right_side_sum = sum(data[1:])
    
    min_diff = abs(left_side_sum - right_side_sum)
    
    pre_num = 0
    
    for i,num in enumerate(data):
        if i < 2:
            pre_num = num
            continue
        
        left_side_sum += pre_num
        
        right_side_sum -= pre_num
        
        current_diff = abs( left_side_sum - right_side_sum)
        
        pre_num = num
                           
        if min_diff > current_diff:
            min_diff = current_diff
            
    return min_diff
    
In [22]:
    
def gen_list(start, stop ,size):
    from random import randint
    
    values_list = list()
    
    for counter in xrange(size):
        values_list.append(randint(start,stop))
    
    return values_list
    
In [23]:
    
def test_cases_fn(test_cases_list = None):
    
    if test_cases_list is None:
        test_cases_list = list()
        
    # zero element list
    test_cases_list.append(random_test_data(-1000,1000,0))
    
    #single element list
    test_cases_list.append(random_test_data(-1000,1000,1))
    
    #double element list
    test_cases_list.append(random_test_data(-1000,1000,2))
    
    #simple case list positive
    test_cases_list.append(random_test_data(0,1000,10))
    
    #simple case list negative
    test_cases_list.append(random_test_data(-1000,0,10))
    
    #simple case list all
    test_cases_list.append(random_test_data(-1000,1000,10))
    
    #medium case list positive
    test_cases_list.append(random_test_data(0,1000,100))
    
    #medium case list negative
    test_cases_list.append(random_test_data(-1000,0,100))
    
    #medium case list all
    test_cases_list.append(random_test_data(-1000,1000,100))
    
    #large case list positive
    test_cases_list.append(random_test_data(0,1000,1000))
    
    #large case list negative
    test_cases_list.append(random_test_data(-1000,0,1000))
    
    #large case list all
    test_cases_list.append(random_test_data(-1000,1000,1000))
    
    #extra large case list positive
    test_cases_list.append(random_test_data(0,10000,10000))
    
    #extra large case list negative
    test_cases_list.append(random_test_data(-10000,0,10000))
    
    #extra large case list all
    test_cases_list.append(random_test_data(-10000,10000,10000))
    
    #binary case list positive
    test_cases_list.append(gen_list(0,1,10))
    
    #binary case list negative
    test_cases_list.append(gen_list(-1,0,10))
    
    #binary case list all
    test_cases_list.append(gen_list(-1,1,10))
    
    #simple pyramid case list positive
    
    pyramid_arr = random_test_data(0,1000,10)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #simple pyramid case list negative
    pyramid_arr = random_test_data(-1000,0,10)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #simple pyramid case list all
    pyramid_arr = random_test_data(-1000,1000,10)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #medium pyramid case list positive
    pyramid_arr = random_test_data(0,1000,100)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #medium pyramid case list negative
    pyramid_arr = random_test_data(-1000,0,100)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #medium pyramid case list all
    pyramid_arr = random_test_data(-1000,1000,100)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #large pyramid case list positive
    pyramid_arr = random_test_data(0,1000,1000)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #large pyramid case list negative
    pyramid_arr = random_test_data(-1000,0,1000)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #large pyramid case list all
    pyramid_arr = random_test_data(-1000,1000,1000)
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    #simple 1 case list positive
    test_cases_list.append(gen_list(1,1,10))
    
    #simple 1 case list negative
    test_cases_list.append(gen_list(-1,-1,10))
    
    #medium 1 case list positive
    test_cases_list.append(gen_list(1,1,100))
    
    #medium 1 case list negative
    test_cases_list.append(gen_list(-1,1,100))
    
    #large 1 case list positive
    test_cases_list.append(gen_list(1,1,1000))
    
    #large 1 case list negative
    test_cases_list.append(gen_list(-1,-1,1000))
    
    #extra large 1 case list positive
    test_cases_list.append(gen_list(1,1,10000))
    
    #extra large 1 case list negative
    test_cases_list.append(gen_list(-1,-1,10000))
        
    return test_cases_list
    
In [24]:
    
print len(test_cases_fn())
    
    
In [25]:
    
print small_simple_data
    
    
In [26]:
    
list_1 =  small_simple_data
print list_1
list_1 = list(reversed(list_1))
print list_1
print small_simple_data
pyramid = []
#pyramid = small_simple_data.sort(reverse=True)
pyramid = list_1[:-1] + small_simple_data
print pyramid
    
    
In [27]:
    
pyramid_arr = random_test_data(0,1000,10)
 
print pyramid_arr
 
pyramid_test = (list(reversed(pyramid_arr)))[:-1] + pyramid_arr
 
print pyramid_test
    
    
In [28]:
    
import itertools
#print list(itertools.product([-1, 1], repeat=5))
for n in xrange(2):
    print list(itertools.product([-1, 1], repeat=n))
    
    
In [29]:
    
def test_cases_multiprocess(process_fn,counter):
    
    counter = 10   
    from multiprocessing import Lock,Queue,Process, current_process, Manager
    
    
    if __name__ == '__main__':
        
        manager1 = Manager()
        
        queue_1 = Queue()
        
        test_cases_list = manager1.list()
        
        
           
        for count in xrange(counter):
            p_process_list = list()
            
            
            p_process = Process(target= test_cases_fn, args= (test_cases_list))
            
            p_process.start()
            
            p_process_list.append(p_process)
                
            p_counter = 0
       
        for count in xrange(counter):
            
            p_process_list[p_counter].join()
            
            p_counter += 1
            
                
                
    return test_cases_list
    
In [30]:
    
test_cases_fn_test = test_cases_fn()
len(test_cases_fn())
test_cases_mp = test_cases_multiprocess(test_cases_fn(),5)
    
    
In [31]:
    
n = 3
print list(itertools.product([-1, 1], repeat=n))
print list(itertools.combinations('92516838962740',2))
    
    
In [32]:
    
perm = list(itertools.permutations((0,10,2)))
print perm
for items in perm:
    print items
    for element in items:
        print element
    
    
In [33]:
    
from random import randint
print randint(0,10)
    
    
In [34]:
    
list_test = list()
size = 10
for counter in xrange(size):
    list_test.append(randint(-1,1))
print list_test
    
    
In [35]:
    
print gen_list(-2000,2000,10)
    
    
Multiprocessing:
In [36]:
    
counter = 10   
from multiprocessing import Lock,Queue,Process, current_process, Manager
if __name__ == '__main__':
    
    manager1 = Manager()
    
    queue_1 = Queue()
    
    test_cases_list = manager1.list([[0]])
    
    
    p_process_list = list()
    for count in xrange(counter):
        #p_process_list = list()
        
        
        p_process = Process(target= test_cases_fn, args= (test_cases_list))
        
        p_process.start()
        
        p_process_list.append(p_process)
            
        p_counter = 0
        
        print len(p_process_list)
   
    for count in xrange(counter):
        
        print counter
        
        print p_counter
        
        print len(p_process_list)
        
        print p_process_list
        
        p_process_list[p_counter].join()
        
        p_counter += 1
        
        print test_cases_list
    
    
Multi processing V2.
Altering Test Case Function- Test Case Function V2
In [37]:
    
def test_cases_fn_2(test_cases_dict):
    
    #test_cases_list = None
    
    input_case = None
    
    test_cases_list = test_cases_list[input_case] = list()
            
    input_case =  'zero_element'
    
    test_cases_list.append(random_test_data(-1000,1000,0))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'single_element'
    
    test_cases_list.append(random_test_data(-1000,1000,1))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'double_element'
    test_cases_list.append(random_test_data(-1000,1000,2))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'simple_case_positive'
    
    test_cases_list.append(random_test_data(0,1000,10))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'simple_case_negative'
    
    test_cases_list.append(random_test_data(-1000,0,10))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'simple_case_all'
    
    test_cases_list.append(random_test_data(-1000,1000,10))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'medium_case_positive'
    
    test_cases_list.append(random_test_data(0,1000,100))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'medium_case_negative'
    
    test_cases_list.append(random_test_data(-1000,0,100))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'medium_case_all'
    
    test_cases_list.append(random_test_data(-1000,1000,100))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'large_case_positive'
    
    test_cases_list.append(random_test_data(0,1000,1000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'large_case_negative'
    
    test_cases_list.append(random_test_data(-1000,0,1000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'large_case_all'
    
    test_cases_list.append(random_test_data(-1000,1000,1000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'extra_large_case_positive'
    
    test_cases_list.append(random_test_data(0,10000,10000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'extra_large_case_negative'
    
    test_cases_list.append(random_test_data(-10000,0,10000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'extra_large_case_all'
    
    test_cases_list.append(random_test_data(-10000,10000,10000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'binary_case_list_positive'
    
    test_cases_list.append(gen_list(0,1,10))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'binary_case_negative'
    
    test_cases_list.append(gen_list(-1,0,10))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'binary_case_all'
    
    test_cases_list.append(gen_list(-1,1,10))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'simple_pyramid_case_positive'
    
    pyramid_arr = random_test_data(0,1000,10)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'simple_pyramid_case_negative'
    
    pyramid_arr = random_test_data(-1000,0,10)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'simple_pyramid_case_all'
    
    pyramid_arr = random_test_data(-1000,1000,10)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'medium_pyramid_case_positive'
    
    pyramid_arr = random_test_data(0,1000,100)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'medium_pyramid_case_negative'
    
    pyramid_arr = random_test_data(-1000,0,100)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'medium_pyramid_case_all'
    
    pyramid_arr = random_test_data(-1000,1000,100)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'large_pyramid_case_positive'
    
    pyramid_arr = random_test_data(0,1000,1000)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'large_pyramid_case_negative'
    
    pyramid_arr = random_test_data(-1000,0,1000)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'large_pyramid_case_all'
    
    pyramid_arr = random_test_data(-1000,1000,1000)
    
    test_cases_list.append( (list(reversed(pyramid_arr)))[:-1] + pyramid_arr )
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'simple_1_case__positive'
    
    test_cases_list.append(gen_list(1,1,10))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'simple_1_case_negative'
    
    test_cases_list.append(gen_list(-1,-1,10))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'medium_1_case_positive'
    
    test_cases_list.append(gen_list(1,1,100))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'medium_1_case_negative'
    
    test_cases_list.append(gen_list(-1,1,100))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'large_1_case_positive'
    
    test_cases_list.append(gen_list(1,1,1000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'large_1_case_negative'
    
    test_cases_list.append(gen_list(-1,-1,1000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'extra_large_1_case_positive'
    
    test_cases_list.append(gen_list(1,1,10000))
    
    test_cases_dict[input_case] = test_cases_list
    
    input_case = 'extra_large_1_case_negative'
    
    test_cases_list.append(gen_list(-1,-1,10000))
    
    test_cases_dict[input_case] = test_cases_list
    
Multiprocessing V2. Tricking the Manager to run as a dict() , while storing list() within it.
In [38]:
    
def mysubprocess(shared_dict):
    item = shared_dict['list_item'] = list()
    item.append('test')
    shared_dict['list_item'] = item
    print 'subprocess:', shared_dict
def test_cases_fn_3(test_cases_dict):
    
    input_case =  'zero_element'
    
    print random_test_data(-1000,1000,0)
    
    item = test_cases_dict[input_case] = list()
    
    item.append([random_test_data(-1000,1000,0)])
    
    test_cases_dict[input_case] = item
    
    print test_cases_dict
    
    #test_cases_list = random_test_data(-1000,1000,0)
    
    #input_case =  'zero_element'
    
    #test_cases_dict[input_case] = test_cases_list
            
    #input_case =  'zero_element'
    
    #test_cases_list.append(random_test_data(-1000,1000,0))
    
    #test_cases_dict[input_case] = test_cases_list
    
In [39]:
    
counter = 1
from multiprocessing import Lock,Queue,Process, current_process, Manager
if __name__ == '__main__':
    
    manager1 = Manager()
    
    queue_1 = Queue()
    
    test_cases_dict = manager1.dict()
    
    
    p_process_list = list()
    for count in xrange(counter):
        
        p_process = Process(target= , args= (test_cases_dict,))
        
        p_process.start()
        
        p_process_list.append(p_process)
            
        p_counter = 0
        
        print len(p_process_list)
        
        #test_cases_dict.clear()
   
    for count in xrange(counter):
        
        print counter
        
        print p_counter
        
        print len(p_process_list)
        
        print p_process_list
        
        p_process_list[p_counter].join()
        #test_cases_dict.clear()
        
        p_counter += 1
        
        print test_cases_dict
    
    
In [40]:
    
print random_test_data(0,10,10)
    
    
Multi Processing V3.
In [71]:
    
counter = 10
from multiprocessing import Lock,Queue,Process, current_process, Manager
from random import randint
def gen_list_mp(start, stop ,
                input_case_size_name,
                input_case_type_name,
                test_cases_list):
    
    from random import randint
    
    values_list = list()
    
    input_case_size = { 
        
        "zero" : 0,
        
        "single" : 1,
        
        "double" : 2,
        
        "simple" : 10,
        
        "medium" : 100,
        
        "large" : 1000,
        
        "extra_large" : 10000
    
    }
    
    
    input_case_type= {
        
        "pyramid" : 1,
        
        "none" : 0
    }
    
    #from random import randint
    
    #values_list = list()
    
    for num in xrange(input_case_size[input_case_size_name]):
        values_list.append(randint(start,stop))
    
    if input_case_type[input_case_type_name] == 1:
        arr = values_list
        
        #pyramid_arr = list()
        
        values_list = (
            (list(reversed(arr)))[:-1] + arr )
    
        
    test_cases_list.append(values_list)
    
if __name__ == '__main__':
    
    manager1 = Manager()
    
    queue_1 = Queue()
    
    test_cases_list = manager1.list()
    
    
    p_process_list = list()
    for count in xrange(counter):
        
        p_process = Process(target= gen_list_mp , args= (1,10,"simple","none",test_cases_list))
        
        p_process.start()
        
        p_process_list.append(p_process)
            
        p_counter = 0
        
        print len(p_process_list)
        
        #test_cases_dict.clear()
   
    for count in xrange(counter):
        
        print counter
        
        print p_counter
        
        print len(p_process_list)
        
        print p_process_list
        
        p_process_list[p_counter].join()
        #test_cases_dict.clear()
        
        p_counter += 1
        
print test_cases_list
    
    
In [42]:
    
print gen_list(0,0,0)
    
    
In [43]:
    
test_dict = {"zero_element" : random_test_data(-1000,1000,0)}
    
In [44]:
    
a = test_dict["zero_element"]
print a
    
    
In [49]:
    
test_dict_1 = { "test": [1]}
print (test_dict_1 ["test"] [0])
    
    
In [54]:
    
test_arr = [1,2,3,4,5,6,7]
 
print test_arr
arr = test_arr
        
pyramid_arr = list()
        
pyramid_arr = (
            (list(reversed(arr)))[:-1] + arr )
print pyramid_arr
    
    
MP V3.1
In [91]:
    
def tape_int_2_3_2(data):
    
    sums_list = list()
    
    if len(data) == 0:
        return 0
    
    elif len(data) == 1:
        left_side_sum = 0
        
        right_side_sum = data[0]
    else:
    
        left_side_sum = data[0]
        
        right_side_sum = sum(data[1:])
    
    min_diff = abs(left_side_sum - right_side_sum)
    
    sums_list.append([left_side_sum,right_side_sum,min_diff])
    
    pre_num = 0
    
    for i,num in enumerate(data):
        if i < 2:
            pre_num = num
            continue
        
        left_side_sum += pre_num
        
        right_side_sum -= pre_num
        
        current_diff = abs( left_side_sum - right_side_sum)
        
        sums_list.append([left_side_sum,right_side_sum,current_diff])
        
        pre_num = num
                           
        if min_diff > current_diff:
            min_diff = current_diff
    
    sums_list.append(min_diff)
            
    return sums_list
    
In [97]:
    
counter = 10
from multiprocessing import Lock,Queue,Process, current_process, Manager
from random import randint
def gen_list_mp(start, stop ,
                input_case_size_name,
                input_case_type_name,
                test_cases_list):
    
    from random import randint
    
    values_list = list()
    
    input_case_size = { 
        
        "zero" : 0,
        
        "single" : 1,
        
        "double" : 2,
        
        "simple" : 10,
        
        "medium" : 100,
        
        "large" : 1000,
        
        "extra_large" : 10000
    
    }
    
    
    input_case_type= {
        
        "pyramid" : 1,
        
        "none" : 0
    }
    
 
   
    for num in xrange(input_case_size[input_case_size_name]):
        values_list.append(randint(start,stop))
    
    if input_case_type[input_case_type_name] == 1:
        arr = values_list
        
        #pyramid_arr = list()
        
        values_list = (
            (list(reversed(arr)))[:-1] + arr )
    
        
    test_cases_list.append(values_list)
    
if __name__ == '__main__':
    
    manager1 = Manager()
    
    queue_1 = Queue()
    
    test_cases_list = manager1.list()
    
    
    p_process_list = list()
    for count in xrange(counter):
        
        p_process = Process(target= gen_list_mp , args= (1,10,"simple","pyramid",test_cases_list))
        
        p_process.start()
        
        p_process_list.append(p_process)
            
        p_counter = 0
           
    for count in xrange(counter):
        p_process_list[p_counter].join()
        
        p_counter += 1
        
print test_cases_list
    
    
In [106]:
    
test_tape = list()
for case in test_cases_list:
    #print case
    test_tape.append(tape_int_2_3_2(case))
    
print test_tape[0]
    
#print test_tape[:-1]
    
    
Linear Regression
In [ ]:
    
def lin_reg(data):
    """
    Analysis Training set results vs testing results
    :return: 
    """
    
I believe If i apply K-neareast neahbour to test_tape[0] and apply linear regression to the over all test sample. I should be receiving a decent prediction score. Moving on for now.To be continued.
In [ ]: