I have an assignment in which I have to create a program which decodea message. As an input I am given a file with keys and messages. The file format is
no of key/message pairs
The message I have is always lowercase string seperated by spaces, for example : hello world. The key I am provided it always integer, for example : 1595.
Now, what I have to do here is that I have to decode and the logic for that is that I have to shift the letters in the message by the given number and I have to move from left to right and then right to left for the number. For example : considering the above key and the message
h+1=i, e+5=j, l+9=u, l+5=q
Now that we used all the digits, we do it again from right to left:
o+5=t, the space is discarded, w+9=f, o+5=t, r+1=s
we repeat the process, starting from left to right:
The result is: ijuqt ftsmi.
So, i achieve this result but my program fails because it exceeds the memory limit. Below is my program if someone can help me I would be grateful