WA ALETHIO

inCase = raw_input()
maxInt = 0
current = “”
cInt = [‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘0’]
LetterUse = False
index = 0

for element in inCase:
    if(element in cInt): ## is a number
        current+=element
    else:               ## is a letter       
        if(LetterUse == True):
            if(inCase[index-1] in cInt): ## previous element was a number 
                current=inCase[index-1] + "9"
            else: ## prev index not a number start from scratch 
                current = "9"
        else:
            current+="9"
            LetterUse = True
        
    if(int(current) > maxInt):
        maxInt = int(current)

    index+=1

print maxInt

Hey guys I really enjoyed the short contest this month and though I would solve 2 problems for sure but it seems that my code for ALETHIO has a bug which I wasn’t able to correct in time, and still can’t identify. Maybe another set of eyes will be able to help me out. I was thinking maybe the problem could be in the index I was using to check previous elements or the fact that I use a boolean variable but never set it false, but I haven’t been able to come up with cases that verify this. Thanks in advance for any insights. :slight_smile:

I found some of the test cases where your solution fails DDD (your answer=“99”, correct answer=“9”), DD3333D (your answer=“933339”, correct answer=“93333”)… refer this

i need help on this … I dont know on which test case does this fail.
If someone has some good test cases then pl tell me where does my code fails.
http://www.codechef.com/viewsolution/2292810
thanks

@gauravdrocker Your code if failing for pure numbers!! try “12”, the o/p your getting is 912, while it must be “12”

Forgive me if I am incorrect, but are you sure? I copied the code directly from this question, saved it as a python 2.7 file and ran it on the cases you have given. Yet for me it returns the answers you have specified as being correct.

I took your code from http://www.codechef.com/viewsolution/2292050

I mostly refer to a codechef successfully ran code… but ya both differs… well I will test the one you pasted too…

Ah I understand the confusion now. Please test your input on my 2nd most recently submitted solution or just use the code I posted here. I made this foolish move on last official submission out of desperation :slight_smile:

I did… all cases passed succesfully acc to me… http://ideone.com/hvgFs9

Now if you want more test cases, refer this http://ideone.com/zy8Rya, though the author of this solution haven’t got AC, but the same thing, we cant guess that case… and also if my solution(http://www.codechef.com/viewsolution/2291940) can help you, since it got the third fastest submission in Python, it might serve some help

1 Like

I did come across this case that my code fails. A70N2 correct answer: 7092 my answer: 970