O(n) Rotational Cipher in Python

Djamgatech
Djamgatech
Developer: Djamgatech Corp
Price: Free+
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
‎Djamgatech
‎Djamgatech
Developer: DjamgaTech Corp
Price: Free+
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot

Rotational Cipher: One simple way to encrypt a string is to “rotate” every alphanumeric character by a certain amount. Rotating a character means replacing it with another character that is a certain number of steps away in normal alphabetic or numerical order. For example, if the string “Zebra-493?” is rotated 3 places, the resulting string is “Cheud-726?”. Every alphabetic character is replaced with the character 3 letters higher (wrapping around from Z to A), and every numeric character replaced with the character 3 digits higher (wrapping around from 9 to 0). Note that the non-alphanumeric characters remain unchanged. Given a string and a rotation factor, return an encrypted string.

Signature

string rotationalCipher(string input, int rotationFactor)

Input

1 <= |input| <= 1,000,000 0 <= rotationFactor <= 1,000,000

Output

Return the result of rotating input a number of times equal to rotationFactor.

Example 1

input = Zebra-493?

rotationFactor = 3

output = Cheud-726?

Example 2

input = abcdefghijklmNOPQRSTUVWXYZ0123456789

rotationFactor = 39

output = nopqrstuvwxyzABCDEFGHIJKLM9012345678

O(n) Solution in Python:

Test 1:

Djamgatech
Djamgatech
Developer: Djamgatech Corp
Price: Free+
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
‎Djamgatech
‎Djamgatech
Developer: DjamgaTech Corp
Price: Free+
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot

PS C:\dev\scripts> .\test_rotational_cipher_python.py
Length Dic Numbers : 10
Length Dic lowercase : 26
Length Dic uppercase : 26
Input: Zebra-493?
Output: Cheud-726?

Test2:

PS C:\dev\scripts> .\test_rotational_cipher_python.py
Length Dic Numbers : 10
Length Dic lowercase : 26
Length Dic uppercase : 26
Input: abcdefghijklmNOPQRSTUVWXYZ0123456789
Output: nopqrstuvwxyzABCDEFGHIJKLM9012345678





Djamgatech PRO
Djamgatech PRO
Developer: Djamgatech Corp
Price: $7.99
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
  • Djamgatech PRO Screenshot
Djamgatech
Djamgatech
Developer:
Djamgatech Corp
Price:
Free+

  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot
  • Djamgatech Screenshot


‎Djamgatech
‎Djamgatech
Developer:
DjamgaTech Corp
Price:
Free+

  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot
  • ‎Djamgatech Screenshot


AWS Cloud Practitioner CCP PRO
AWS Cloud Practitioner CCP PRO
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot
  • AWS Cloud Practitioner CCP PRO Screenshot


AWS Certified Cloud Practitioner Mock Exams Pro
AWS Certified Cloud Practitioner Mock Exams Pro
Developer:
‪Etienne Noumen‬
Price:
$3.89

  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot
  • AWS Certified Cloud Practitioner Mock Exams Pro Screenshot


taimienphi.vn