Encrypted In Numbers!
brainfuck, 66 bytes
,[>>>+<[-<+>>-<]<[->+<],]>[<<,>>[-<+>]<-]<<<[>[-<->>+<]<<]>.>>[.>]
Input is the encrypted string. Assumes infinite sized cells and 0 on EOF.
How it Works:
,[>>>+<[-<+>>-<]<[->+<],] Gets input and the number of characters divided by 2
>[<<,>>[-<+>]<-]<<< Remove the second half of the string (the multiplication part)
[>[-<->>+<]<<] Subtract each character from the previous one, while keeping a copy of the previous one.
>.>>[.>] Print the characters
Haskell, 45 35 bytes
map toEnum.scanr1(-).fst.span(<245)
Try it online!
Explanation
fst.span(<245)
takes all numbers from the beginning of the list that are smaller than 245. Those are only the numbers from the summation part, because the largest possible summation isz + z = 122 + 122 = 244
, and the smallest possible product isA * A = 65 * 65 = 4225
.scanr1(-)
takes the last value of the list and uses it as initial accumulator. Then from back to front each element of the list is subtracted by the current accumulator, and the result is used as the next accumulator and and added to a list.map toEnum
replaces each number in the list with the corresponding character to recreate the string.
Husk, 7 6 bytes
mcĠ≠←½
Try it online! According to the documentation the leading m
should not be needed, but there seems to be a bug currently.
Edit: -1 byte thanks to Zgarb!
Explanation:
½ -- split input list into half
← -- take first list
Ġ≠ -- subtract each list element from the previous one
mc -- convert list of code points to string