Skip to content

Instantly share code, notes, and snippets.

@jtarang
Last active December 10, 2018 03:57
Show Gist options
  • Save jtarang/dad89e89adedb0fe1b40a34a53d88ad6 to your computer and use it in GitHub Desktop.
Save jtarang/dad89e89adedb0fe1b40a34a53d88ad6 to your computer and use it in GitHub Desktop.
from random import randint
def pick_the_first_recurring(choices=None, tracker=None):
keep_going = True
while keep_going:
for _ in choices:
rr = choices[randint(0,len(choices))-1]
if rr in tracker:
keep_going = False
tracker[rr] += 1
return rr
tracker[rr] = 1
if __name__ == "__main__":
choices_dict = 'Goodsons,Lupe,Becks Prime,Kirin'.split(',')
tracker_dict = dict()
for _ in range(0,20):
pick_the_first_recurring(choices=choices_dict, tracker=tracker_dict)
print(tracker_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment