+ 3

Encryptology ChallengešŸ†šŸ†!!

Encryptology is the process of encoding a string to another form in such a way that it cannot be decoded by an unauthorized person. You are to encode a program in your language to encrypt the string in such a way that each character of the string is replaced with a character at a mentioned gap (say, move). If move is positive then the characters are replaced by characters ahead by the given move while for a negative move, the opposite occurs. In case the move is 0 then the same string is produced. The characters are wrapped, i.e, Z is followed by A and A is followed by Z considering the moves to be negative and positive respectively. E.g: ABZ can be encrypted as CDB if move = 2 ABZ can be encrypted as YZX if move = -2 Best of Luck!! And Happy Coding!

28th Dec 2017, 5:40 PM
Karan Kumar
Karan Kumar - avatar
8 Answers
+ 8
If the gap is constant, decrypting is childishly easy, as you have a fairly low number of attempts to go. Perhaps the gap itself could vary according to a certain pattern? If so, then see my first attempt - the gap increases with each character and does not follow a simple 'tit for tat' schema: https://code.sololearn.com/cuKnuo01NOb9/?ref=app
28th Dec 2017, 8:05 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
3rd Jan 2018, 8:07 AM
Abhishek Tandon
Abhishek Tandon - avatar
28th Dec 2017, 5:40 PM
Karan Kumar
Karan Kumar - avatar
+ 2
encript=lambda s,gap,a="abcdefghijklmnopqrstuvwxyz":join(a[(a.index(c)+gap)%len(a)] for c in s)
28th Dec 2017, 5:46 PM
VcC
VcC - avatar
29th Dec 2017, 5:04 AM
Kodirbek Makharov
Kodirbek Makharov - avatar
+ 1
My PHP solution with strtr and substr. https://code.sololearn.com/wRET0SyV22F7
28th Dec 2017, 10:29 PM
Bidch Arvil
Bidch Arvil - avatar
+ 1
@Kuba Even I was thinking of making it a bit more difficult as it is easy but I myself wasn't getting the code :P
29th Dec 2017, 11:40 AM
Karan Kumar
Karan Kumar - avatar