Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

WA ALETHIO

$
0
0
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. :)


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>