Skip to content

Commit

Permalink
Cleanup and performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cptalpdeniz authored Jan 14, 2018
1 parent b0f4fa8 commit 6882c6f
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions Selcal Gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,23 @@
for i in range(n):
l = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'P', 'Q', 'R', 'S']
while True:
selcal1 = random.choice(l)
if (selcal1 == 'S'):
continue
else:
break
while True:
code = random.choice(l)
if (selcal1[0] < code):
selcal1 = selcal1[:] + code
selcal1i = random.choice(range(len(l)))
selcal1 = l[selcal1i]
if (selcal1 != 'S'): #check if first letter of the code is "S"
break
code = random.choice(l[selcal1i:])
selcal1 = selcal1[:] + code
while True:
selcal2 = random.choice(l)
if (selcal1[0] == selcal2 or selcal1[1] == selcal2):
continue
if (selcal2 == 'S'):
continue
else:
selcal2i = random.choice(range(len(l)))
selcal2 = l[selcal2i]
if (selcal1[0] != selcal2 or selcal1[1] != selcal2 or selcal2 != 'S'): #another check to make sure code is within the rules
break
while True:
code = random.choice(l)
code = random.choice(l[selcal2i:])
if (selcal1[0] == code or selcal1[1] == code):
continue
if (selcal2[0] < code):
selcal2 = selcal2[:] + code
break
selcal = selcal1 + '-' + selcal2
print selcal
print selcal

0 comments on commit 6882c6f

Please sign in to comment.