## CS124 Programming Assignment 3
## HUIDs: 70940507 and 60940371
## random_kk.py

from bisect import insort_left
import numpy as np
from copy import copy

import sys

if len(sys.argv) != 2:
	print("usage: python kk.py infile")
	quit()

infile = sys.argv[1]

A = np.loadtxt(infile).tolist()

def KK(A_p): # O(n*n), so not what we want
	A = copy(A_p)
	A.sort() # O(n log n)
	n = len(A)
	while n > 1: # O(n) times to insort * O(n) insort
		delta = abs(A.pop() - A.pop()) 
		insort_left(A, delta)
		n -= 1
	return A[0]

print(KK(A))
d8b77a6e055414b4fbdf72004e0dea3ded7c582d
<mask token>


def KK(A_p):
    A = copy(A_p)
    A.sort()
    n = len(A)
    while n > 1:
        delta = abs(A.pop() - A.pop())
        insort_left(A, delta)
        n -= 1
    return A[0]


<mask token>

<mask token>
if len(sys.argv) != 2:
    print('usage: python kk.py infile')
    quit()
<mask token>


def KK(A_p):
    A = copy(A_p)
    A.sort()
    n = len(A)
    while n > 1:
        delta = abs(A.pop() - A.pop())
        insort_left(A, delta)
        n -= 1
    return A[0]


print(KK(A))

<mask token>
if len(sys.argv) != 2:
    print('usage: python kk.py infile')
    quit()
infile = sys.argv[1]
A = np.loadtxt(infile).tolist()


def KK(A_p):
    A = copy(A_p)
    A.sort()
    n = len(A)
    while n > 1:
        delta = abs(A.pop() - A.pop())
        insort_left(A, delta)
        n -= 1
    return A[0]


print(KK(A))

from bisect import insort_left
import numpy as np
from copy import copy
import sys
if len(sys.argv) != 2:
    print('usage: python kk.py infile')
    quit()
infile = sys.argv[1]
A = np.loadtxt(infile).tolist()


def KK(A_p):
    A = copy(A_p)
    A.sort()
    n = len(A)
    while n > 1:
        delta = abs(A.pop() - A.pop())
        insort_left(A, delta)
        n -= 1
    return A[0]


print(KK(A))

## CS124 Programming Assignment 3
## HUIDs: 70940507 and 60940371
## random_kk.py

from bisect import insort_left
import numpy as np
from copy import copy

import sys

if len(sys.argv) != 2:
	print("usage: python kk.py infile")
	quit()

infile = sys.argv[1]

A = np.loadtxt(infile).tolist()

def KK(A_p): # O(n*n), so not what we want
	A = copy(A_p)
	A.sort() # O(n log n)
	n = len(A)
	while n > 1: # O(n) times to insort * O(n) insort
		delta = abs(A.pop() - A.pop()) 
		insort_left(A, delta)
		n -= 1
	return A[0]

print(KK(A))