Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from time import time, sleep
- from random import randint
- from numpy import random as r
- RUTS = ['19.470.140-3',
- '20.067.784-k',
- '10.481.357-7',
- '11.624.369-5',
- '15.753.502-1',
- '19.124.836-8',
- '19.154.575-5',
- '15.324.128-k',
- '17.684.932-5',
- '12.789.123-0']
- def load_ruts():
- ruts = []
- try:
- with open('ruts.txt') as f:
- for line in f:
- # para omitir comentarios!
- if "#" in line:
- continue
- ruts.append(line.strip())
- except:
- with open('ruts.txt', 'w') as f:
- f.write("# importante seguir el formato!")
- for rut in RUTS:
- f.write(rut + '\n')
- ruts = RUTS
- return ruts
- RUTS = load_ruts()
- def get_random():
- return RUTS[randint(0, len(RUTS) - 1)]
- def generate_rut():
- start = '{:,}'.format(randint(1000000, 25000000)).replace(',', '.')
- end = r.choice(map(str, range(0, 10)) + ['k'])
- return start + '-' + end
- def limpiar(texto):
- return texto.replace('.','').replace('-k','10').replace('-','0')
- if __name__ == "__main__":
- diff = raw_input('generar rut o conocidos (1 o 2): ')
- if diff == '1':
- func = generate_rut
- else:
- func = get_random
- # Cantidad de ruts a ingresar
- Q = 10
- n = Q
- for i in range(1,4):
- print(4-i)
- sleep(1)
- print("ahora!")
- choice = get_random()
- start = time()
- while n != 0:
- print("Escribe '%s'" % choice)
- t = str(raw_input())
- if t.strip() != limpiar(choice):
- print("\nerror, escribir de nuevo\n")
- continue
- else:
- print("\nfaltan %d veces\n" % n - 1)
- n -= 1
- choice = func()
- end = time()
- print("Tardaste %f segundos" % (end - start))
- user = raw_input('ingresa nombre: ')
- with open('results.csv', 'a') as f:
- f.write('{0};{1};{2}\n'.format(user, end - start, Q))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement