forked from WryHarpy/Enigma-Machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWheelBuilder.py
More file actions
43 lines (38 loc) · 1.42 KB
/
WheelBuilder.py
File metadata and controls
43 lines (38 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Nick Demanche
# 22 October 2019
# CIS220 - Object Oriented Programming
# Wheel Builder
import random
letterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -,."
letterSetList = list(letterSet)
letterSetDict = { i : letterSetList[i] for i in range(0, len(letterSetList))}
# Takes in the original letterset and randomizes it then returns that as a string
def randomizeList(input):
# Creates a randomized list of numbers
randomNumbers = random.sample(range(0, len(input)), len(input))
# Takes each number and places the corresponding piece from the letter set into a list
list = []
for i in randomNumbers:
list.append(input[i])
# Turns the list into a simple string of the new randomized letter set
string = ''
for i in list:
string += i
return string
# Given the amount of wheels you want and the letter set, creates
# a dictionary containing each wheel as a key:value Pair
def wheelBuilder(amount, input):
wheelDict = {}
number = 1
# For each wheel, runs randomizeList and adds that to the full dictionary
while number <= amount:
key = 'w{}'.format(number)
value = randomizeList(input)
dict = {key: value}
wheelDict.update(dict)
number += 1
f = open("evWheels.py", 'w')
f.write('Wheels = ' + str(wheelDict))
f.close()
return wheelDict
wheelBuilder(50, letterSetDict)