Konami Code

The Konami code is a sequence of key/button presses that is implemented in many video games to unloc…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

Any suggestion please, How do I solve this with pyton 3?

i tried it with python .but it gets cpu limit exceeded

Bhaiya,you can use regular expressions(re module).

pattern, please. Actually I do not understand what to do with this problem.

here’s how you can solve using python 3.

  1. take a substring of the same length as konami code, here 10
  2. declare an insatance counter variable, if that substring is konami code, add 1 to the instance count
  3. when you reac h the end of the input, print the instance count

It is easy for python 3. It just needs a line to be solved.
. Just take a string
. And count the ‘konami code’ from there uaing count method.
. Then print that.

thanks a lot. I was in misconfusion.

konami = str(input())
con=""
li = list(konami)
m=10
count=0
i=0
lenth = len(li)
for i in range(lenth):
    for j in range(i,m):
        con += li[j]
        if con=="UUDDLRLRBA":
            count+=1
    m+=1
    con=""
    if m>=lenth:
        break
print(count)

what is the problem my code
test case 7 has run time eroor

JewelScientist list needs to be used here
only input_string.count(‘UUDDLRLRBA’)

1 Like