Upload the last of the Boggle files, start the Route Finding assignment.
This commit is contained in:
parent
29c46717d9
commit
01f18dd14a
5 changed files with 220 additions and 0 deletions
25
Boggle/04_generator.py
Normal file
25
Boggle/04_generator.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
__author__ = 'Eck'
|
||||
|
||||
## VITAL: MUST be run using Python 3.6 or better...else random.choices fails. New in 3.6
|
||||
import sys, string, random
|
||||
'''
|
||||
Utility script. creates a random boggle board of given size. Two commands line args:
|
||||
N = the size of board desired
|
||||
outFile = name of desired output file
|
||||
'''
|
||||
|
||||
N=int(sys.argv[1])
|
||||
outFile= sys.argv[2]
|
||||
out = open(outFile,'w')
|
||||
|
||||
|
||||
charlist= string.ascii_uppercase
|
||||
|
||||
for z in range(0,N):
|
||||
line = ' '.join(random.choices(charlist,k=N))
|
||||
out.write((line+"\n"))
|
||||
|
||||
out.close()
|
||||
|
||||
print("tada!")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue