-
Notifications
You must be signed in to change notification settings - Fork 0
/
man_saved_data.py
48 lines (40 loc) · 1.01 KB
/
man_saved_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import pickle
from termcolor import cprint
import math
sprint = lambda x : cprint('\t' + x, 'magenta')#, attrs=['bold'])
rprint = lambda x : cprint('\t\t' + x, 'red')
cyan = lambda x: cprint(x, 'cyan')
data = pickle.load(open("saved_data"))
"""
data <type 'list'>
data[0] <type 'tuple'>
(data[0])[0] <type 'float'>
(data[0])[1] <type 'int'>
(float distance, int index)
"""
cyan(pickle.load(open("input7_vs_input7")))
"""
#cprint(data, 'cyan')
#cyan(type((data[0])[1]))
(x, y) = data[0]
cyan(x)
print y
def radix_sort(arr):
max = -1
for (row, row2) in arr:
num = int(math.log10(row)) + 1
if num > max:
max = num
buckets = [[] for i in range(0, 10)] #buckets for each digit
for digit in range(0, max):
for (number, row2) in arr:
x = int(number)
buckets[x / 10**digit % 10].append(number)
del arr[:]
for bucket in buckets:
arr.extend(bucket)
del bucket[:]
return arr
cyan(radix_sort(data))
"""