Does anyone has the solution to Secret Message problem from the code coach section? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Does anyone has the solution to Secret Message problem from the code coach section?

I did find a solution but the 4th test case is giving an error and since that test case is hidden I am unable to pinpoint the real error. Here is the code. https://code.sololearn.com/cnXZEHChdJI6/?ref=app

26th Dec 2019, 4:54 PM
dolam62331
11 Answers
+ 5
Here is a code: https://code.sololearn.com/cjGMmQQWusF6/?ref=app Of course I have to say that I don't agree with such an action (copy a code from another) but I can partly understand you. (Please always try to do things on your own 🙂.)
26th Dec 2019, 5:13 PM
Elen V
Elen V - avatar
+ 3
Alexey Rubtsov Your one liner inspired me to try and figure out how to do the same with the Pig Latin challenge. Also only for those who have already solved the challenge. https://code.sololearn.com/cz8dF9nN8Wl8/?ref=app Thanks for the inspiration!
7th Jan 2020, 12:54 AM
Paul K Sadler
Paul K Sadler - avatar
+ 2
Thomas, of course I agree with you and I wrote what I think. Also I posted a code which is already public.
26th Dec 2019, 5:22 PM
Elen V
Elen V - avatar
+ 2
Here is another solution in one string. Only for those who have already solved. https://code.sololearn.com/cGqWPwDJL9xJ/?ref=app
4th Jan 2020, 4:39 PM
Alexey Rubtsov
Alexey Rubtsov - avatar
+ 1
Elen V not so nice to post a complete solution 😞
26th Dec 2019, 5:18 PM
Coding Cat
Coding Cat - avatar
0
dolam62331 there goes some thing wrong in your code. Input: nm becomes the same output: mm Maybe you should check this
26th Dec 2019, 5:20 PM
Coding Cat
Coding Cat - avatar
0
I thought of the solution this way: There are 26 nos. so 26/2 = 13 is the middle position to decide if the given letter has a lesser position than 13 or does it have greater position than 13. If the letter has the position 13 i.e., ascii =109 which is 'm', then i print m directly.
26th Dec 2019, 5:25 PM
dolam62331
0
But if n - > m and m -> m it makes no sence I did it with a dict. This works for all test cases. Have a look at this d = {'a':'z', 'b':'y', 'c':'x', 'd':'w', 'e':'v', 'f':'u', 'g':'t', 'h':'s', 'i':'r', 'j':'q', 'k':'p', 'l':'o', 'm':'n', 'n':'m', 'o':'l', 'p':'k', 'q':'j', 'r':'i', 's':'h', 't':'g', 'u':'f', 'v':'e', 'w':'d', 'x':'c', 'y':'b', 'z':'a'}
26th Dec 2019, 5:32 PM
Coding Cat
Coding Cat - avatar
0
Yes I understood what you are saying. Thanks a lot for helping me.
26th Dec 2019, 6:44 PM
dolam62331
0
You're welcome
26th Dec 2019, 6:45 PM
Coding Cat
Coding Cat - avatar
3rd Jan 2020, 8:44 AM
Paul K Sadler
Paul K Sadler - avatar