import random
import time

TIMES = 1000

def add_remove_tuple(x):
	el = random.randint(0,len(x)-1)
	idx = x.index(el)
	x = x[:idx] + x[idx+1:]
	x = x + (el,)

def add_remove_list(x):
	el = random.randint(0,len(x)-1)
	x.remove(el)
	#idx = x.index(el)
	#x.pop(idx)
	x.append(el)

def time_tuple():
	x = tuple(i for i in range(20000))
	t = time.time()
	for i in range(TIMES):
		add_remove_tuple(x)
	return time.time() - t

def time_list():
	x = [i for i in range(20000)]
	t = time.time()
	for i in range(TIMES):
		add_remove_list(x)
	return time.time() - t
	
print("%d repetitions of add/remove at random position using tuple: %.3f seconds" % (
	TIMES, time_tuple()))

print("%d repetitions of add/remove at random position using list: %.3f seconds" % (
	TIMES, time_tuple()))