A = [3,1,2,4,3]

"""
Explanation: 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.
Defining the Function:

left_side_sum = P[0:N-1]
right_side_sum = P[N:]

Difference = absolute(left_side_sum - right_side_sum)

Range:
N = [2,100,000]
P = [-1000, 1000]

Complexity
Time = O^n
Space = O^n

Answer:
Minimum_Difference
End of explanation
"""


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

print A

print tape_int_1(A)

"""
Explanation: V1. broken Testing. Changing the iteration values to be used.
Designing the function
End of explanation
"""


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

print A
print tape_int_2(A)

"""
Explanation: V2.
End of explanation
"""


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

"""
Explanation: 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
End of explanation
"""


empty_list  = list()
print empty_list

print empty_list

print tape_int_2_1(empty_list)

"""
Explanation: Testing  - the code
Empty List
End of explanation
"""


def random_test_data(start,stop,size):
    import random
    
    return random.sample(xrange(start,stop), size)

small_simple_data = random_test_data(0,10,10)

print small_simple_data

print type(small_simple_data)

print tape_int_2_1(small_simple_data)

"""
Explanation: Designing Data function for testing
End of explanation
"""


double_list = [1,2]

print double_list

print tape_int_2_1(double_list)

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

print double_list

print tape_int_2_2(double_list)

double_list_1 = [-2000,2000]

print double_list

print tape_int_2_2(double_list_1)

"""
Explanation: V_2_2 test cases
End of explanation
"""


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

double_list_1 = [-2000,2000]

print double_list

print tape_int_2_3(double_list_1)

print tape_int_2_3(empty_list)

print A

print tape_int_2_3(A)

single_list = random_test_data(-2000,2000,1)

print single_list

print (len(single_list))

print tape_int_2_3(single_list)

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

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

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

print len(test_cases_fn())

print small_simple_data

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

pyramid_arr = random_test_data(0,1000,10)
 
print pyramid_arr
 
pyramid_test = (list(reversed(pyramid_arr)))[:-1] + pyramid_arr
 
print pyramid_test

import itertools

#print list(itertools.product([-1, 1], repeat=5))

for n in xrange(2):
    print list(itertools.product([-1, 1], repeat=n))

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

test_cases_fn_test = test_cases_fn()

len(test_cases_fn())

test_cases_mp = test_cases_multiprocess(test_cases_fn(),5)

n = 3

print list(itertools.product([-1, 1], repeat=n))



print list(itertools.combinations('92516838962740',2))

perm = list(itertools.permutations((0,10,2)))

print perm

for items in perm:
    print items
    for element in items:
        print element

from random import randint

print randint(0,10)

list_test = list()
size = 10

for counter in xrange(size):
    list_test.append(randint(-1,1))

print list_test

print gen_list(-2000,2000,10)

"""
Explanation: V2_3
End of explanation
"""


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

"""
Explanation: Multiprocessing:
End of explanation
"""


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

"""
Explanation: Multi processing V2.
Altering Test Case Function- Test Case Function V2
End of explanation
"""


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

"""
Explanation: Multiprocessing V2. Tricking the Manager to run as a dict() , while storing list() within it.
End of explanation
"""


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

print random_test_data(0,10,10)

"""
Explanation: http://stackoverflow.com/questions/35202278/cannot-append-items-to-multiprocessing-shared-list
End of explanation
"""


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

print gen_list(0,0,0)

test_dict = {"zero_element" : random_test_data(-1000,1000,0)}

a = test_dict["zero_element"]

print a

test_dict_1 = { "test": [1]}

print (test_dict_1 ["test"] [0])

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

"""
Explanation: Multi Processing V3.
End of explanation
"""


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

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

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]

"""
Explanation: MP V3.1
End of explanation
"""


def lin_reg(data):
    """
    Analysis Training set results vs testing results
    :return: 
    """

"""
Explanation: Linear Regression
End of explanation
"""


