From adcd0f72ac3845ceced62966fa45d37a57c5b6bd Mon Sep 17 00:00:00 2001 From: Mike Szczys Date: Sat, 28 Dec 2013 09:46:41 -0600 Subject: [PATCH] Initial Commit --- README.md | 4 ++++ unique-string-gen/unique-string-gen.py | 32 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 README.md create mode 100644 unique-string-gen/unique-string-gen.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..c5e3a45 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +nfc-voting +========== + +Python script generates unique values diff --git a/unique-string-gen/unique-string-gen.py b/unique-string-gen/unique-string-gen.py new file mode 100644 index 0000000..5b71fd8 --- /dev/null +++ b/unique-string-gen/unique-string-gen.py @@ -0,0 +1,32 @@ +########### +# Generate Unique Strings +# - Store them as a pickle file +########### + +# References: +# http://stackoverflow.com/questions/2257441/python-random-string-generation-with-upper-case-letters-and-digits + +import string +import random +import pickle + +setSize = 500 +uniqueLen = 4 + +uniqueSet = [] + +print "Generating Set" +while (len(uniqueSet) < setSize): + if len(uniqueSet)%50 == 49: + print str(len(uniqueSet)+1) + " values have been generated" + n = random.choice(range(0xFFFF)) + if n not in uniqueSet: + uniqueSet.append(n) + +pickle.dump(uniqueSet, open( "uniqueSet.pkl", "wb")) + +print "Saved to uniqueSet.pkl" +print + + +