Skip to content

Optimized encrypt.py python script #4

Open
AOrps wants to merge 2 commits into
CrypTools:masterfrom
AOrps:pyEncrypt
Open

Optimized encrypt.py python script #4
AOrps wants to merge 2 commits into
CrypTools:masterfrom
AOrps:pyEncrypt

Conversation

@AOrps

@AOrps AOrps commented Mar 20, 2021

Copy link
Copy Markdown

Purpose

  • Optimize Script to run faster

Details

  • I noticed that this code ran at O(n) just fine but was instead running at O(n^2) because it was trying to convert a multi-dimensional array into a string. So I just eliminated some abstractions of the script, that might prove costly to large test cases

Technical Details

fence = ["" for i in range(n) ]
  • Instead of doing a list comprehension on a list in python (which creates a multi-dimensional list), you can do one with a string. Which then allows for one iteration the list as opposed to 2.
return "".join(fence)
  • This is used to join all the strings of the list together as one string.

@CLAassistant

CLAassistant commented Mar 20, 2021

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@AOrps

AOrps commented Mar 23, 2021

Copy link
Copy Markdown
Author

I haven't the slightest idea of why the checks aren't passing but let me know what to fix so I can update it accordingly whenever the maintainer of this repository gets the chance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants