-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Added enigma machine emulator #2345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added Enigma machine file to 'ciphers' section
Hey @TrapinchO, TravisCI finished with status TravisBuddy Request Identifier: 3e824c80-e3d4-11ea-ae1e-a7d25f4a9615 |
Hey @TrapinchO, TravisCI finished with status TravisBuddy Request Identifier: 99fa2c30-e3d5-11ea-ae1e-a7d25f4a9615 |
Hey @TrapinchO, TravisCI finished with status TravisBuddy Request Identifier: d2718430-e3d7-11ea-ae1e-a7d25f4a9615 |
Travis tests have failedHey @TrapinchO, TravisBuddy Request Identifier: 4d0d14a0-e3da-11ea-ae1e-a7d25f4a9615 |
I see no log |
Travis tests have failedHey @TrapinchO, TravisBuddy Request Identifier: 64aeec30-e3e6-11ea-ae1e-a7d25f4a9615 |
Travis tests have failedHey @TrapinchO, TravisBuddy Request Identifier: bf3232b0-e3e7-11ea-ae1e-a7d25f4a9615 |
Travis tests have failedHey @TrapinchO, TravisBuddy Request Identifier: 3e5bf340-e3e9-11ea-ae1e-a7d25f4a9615 |
Hey @TrapinchO, TravisCI finished with status TravisBuddy Request Identifier: a4a28c30-e3ea-11ea-ae1e-a7d25f4a9615 |
ciphers/enigma_machine2.py
Outdated
raise TypeError('PLugboard setting isn\'t type string (' | ||
+ str(type(pbl)) + ')') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise TypeError('PLugboard setting isn\'t type string (' | |
+ str(type(pbl)) + ')') | |
raise TypeError(f"Plugboard setting isn't type string ({type(pbl)})") |
Hey @TrapinchO, TravisCI finished with status TravisBuddy Request Identifier: 825b4720-e453-11ea-ae1e-a7d25f4a9615 |
Added option to separate pair for plugboard by spaces
ciphers/enigma_machine2.py
Outdated
{'P': 'O', 'O': 'P', 'L': 'A', 'A': 'L', 'N': 'D', 'D': 'N'} | ||
|
||
Pairs can be separated by spaces | ||
:param pbl: string containing plugboard setting for the Enigma machine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pbl
is a cyptic variable name? Why force your reader to guess what it means? Why not use a more self-documenting variable name like pegboard
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats even more cryptic (at least for me)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is pbstring
better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or inputpb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With all these names, the reader will always ask... What does pb stand for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add it to documentation
ciphers/enigma_machine2.py
Outdated
|
||
Pairs can be separated by spaces | ||
:param pbl: string containing plugboard setting for the Enigma machine | ||
:return: dictionary of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dictionary of ???
ciphers/enigma_machine2.py
Outdated
tmppbl = set() | ||
for i in pbl: | ||
if i not in abc: | ||
raise Exception('Not in list of symbols') | ||
elif i in tmppbl: | ||
raise Exception(f'Duplicate symbol ({i})') | ||
else: | ||
tmppbl.add(i) | ||
del tmppbl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tmppbl = set() | |
for i in pbl: | |
if i not in abc: | |
raise Exception('Not in list of symbols') | |
elif i in tmppbl: | |
raise Exception(f'Duplicate symbol ({i})') | |
else: | |
tmppbl.add(i) | |
del tmppbl | |
if not all(char in abc for char in pbl): | |
raise ValueError(f'Not characeters are in {abc}') | |
if len(set(pbl)) != len(pbl): | |
<your code goes here> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you tell the user which symbol is invalid/duplicate?
Improved the invalid symbol exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad_symbols = [key for key, value in collections.Counter(pbl) if key not in abc or value > 1]
if bad_symbols:
raise ValueError(<your code here>)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my version is easier to understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
* Added Enigma machine file Added Enigma machine file to 'ciphers' section * Added doctest to validator * Fixed typo * Shortened some lines * Shortened some lines * Update enigma_machine.py * Shortened some lines * Update enigma_machine.py * Update enigma_machine.py * Update enigma_machine2.py * Update enigma_machine2.py * added f-strings * Update enigma_machine2.py * Update enigma_machine2.py * Updated some numbers * Plugboard improvement Added option to separate pair for plugboard by spaces * renamed variable * renamed some variables * improved plugboard exception * Update enigma_machine2.py * Update enigma_machine2.py
Added Enigma machine file to 'ciphers' section
Describe your change:
Added emulator of the enigma machine from WWII into 'ciphers' folder.
PS: Couldn't open the 'automated testing on Travis CI' in CONTRIBUTING.md. It says
Checklist:
Fixes: #{$ISSUE_NO}
.