Last active
December 10, 2018 03:57
-
-
Save jtarang/dad89e89adedb0fe1b40a34a53d88ad6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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