Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mass = [[[None],[None]] for _ in range(10)]
- def to_hash(x):
- res = [bin(ord(i)) for i in x]
- res = ''.join([i[2:] for i in res])
- x = int(res, 2) % len(mass)
- return x
- def add_after(ind, val):
- global mass
- i = len(mass[ind][0]) - 1
- mass[ind][0] += [val]
- mass[ind][1] += [mass[ind][1][i]]
- mass[ind][1][i] = len(mass[ind][0]) - 1
- add_after(to_hash('Bill'), 'Bill:Clinton')
- add_after(to_hash('Ronald'), 'Ronald:Reagan')
- add_after(to_hash('John'), 'John:Fitzgerald Kennedy')
- add_after(to_hash('Harry'), 'Harry:S. Truman')
- add_after(to_hash('Joe'), 'Joe:Biden')
- add_after(to_hash('Jimmy'), 'Jimmy:Carter')
- add_after(to_hash('Barack'), 'Barack:Obama')
- add_after(to_hash('Theodore'), 'Theodore:Roosevelt')
- add_after(to_hash('James'), 'James:Garfield')
- add_after(to_hash('Lyndon'), 'Lyndon:Johnson')
- def find_in_list(name):
- ind = to_hash(name)
- k = 0
- while mass[ind][1][k] is not None:
- #print(mass[ind][0][k + 1])
- result = mass[ind][0][k + 1].split(':')
- if result[0] == name:
- return result[1]
- k = mass[ind][1][k]
- print(find_in_list(input('Name of president ').capitalize()))
Advertisement
Add Comment
Please, Sign In to add comment