I am solving Daily Codin Problem #7 with Python [Recurssion] Can anyone explain this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

I am solving Daily Codin Problem #7 with Python [Recurssion] Can anyone explain this code?

Firstly I did it on my own by checking each string element and from a variable = 1 i plus 1 if the element were 1 or 2 (checking first if there werent 0s and in case of 2 the next element were less than 7) but it didnt work properly. The code is from internet where i seek for answers and explanation but i dont get this recurssion. Problem: This problem was asked by Facebook. Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded. For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'. You can assume that the messages are decodable. For example, '001' is not allowed. https://code.sololearn.com/cYD13bYJ62EB/?ref=app

15th Oct 2021, 11:23 AM
Marc Aguilar
Marc Aguilar - avatar
3 Answers
+ 2
https://www.geeksforgeeks.org/count-possible-decodings-given-digit-sequence/ Hope this will help you understand...
15th Oct 2021, 1:19 PM
Arun Ruban SJ
Arun Ruban SJ - avatar
+ 2
Thanks Arun for the link above. I had already seen it but it doesnt make the code clear. I dont understand how the recursive adds up the number of possible decodings as there isn't '+1'...
15th Oct 2021, 2:15 PM
Marc Aguilar
Marc Aguilar - avatar
0
Problem Statement: Decode the logic and print the Pattern that corresponds to given input using c program. If N = 3 then pattern will be: 10203010011012 4050809 ****607 If N = 4 then pattern will be: 1020304017018019020 **50607014015016 ****809012013 Constraints: Z <= N <= 100 Input Format First line contains T, the number of test cases, each test case contains a single integer N Output Format First line print Case #i where i is the test case number, In the subsequent line, print thepattern Sample Input 3 Sample Output Case #1 10203010011012 **4050809 .*** 607 Case #2 1020304017018019020 **50607014015016 ****809012013 Case #3 102030405026027028029030 **6070809022023024028****10011012019020021 ******13014017018 ***15016
10th Nov 2023, 5:44 PM
kamal suresh (Pushpa)
kamal suresh (Pushpa) - avatar