web: home-page: Add new page
[lcapit-junk-code.git] / time
blob198decaadbe83f29212cb178d56b83001c271505
1 #!/usr/bin/python
3 import random
4 from sys import argv, exit
5 from time import time
7 def get_names(filename):
8 file = open(filename)
9 names = file.readlines()
10 file.close()
11 return names
13 def choose_time1(names):
14 time1 = []
15 random.seed(time())
16 max = len(names) - 1
17 while True:
18 nr = random.randint(0, max)
19 if names[nr] not in time1:
20 time1.append(names[nr])
21 if len(time1) == (max + 1) / 2:
22 return time1
24 def show_times(time1, names):
25 print 'Time 1'
26 for name in time1:
27 print name,
28 print
29 print 'Time 2'
30 for name in names:
31 if name not in time1:
32 print name,
34 def main():
35 names = get_names(argv[1])
36 if len(names) % 2 != 0:
37 print 'Tem que ser par tio'
38 exit(1)
39 time1 = choose_time1(names)
40 show_times(time1, names)
42 if __name__ == '__main__':
43 main()