You are not logged in. Please login at www.codechef.com to post your questions!

×

# Which test case my code is failing? (TYPING|python3.6)

 1 Question code: TYPING My code: s=set() l=["d","f"] r=["j","k"] for i in range (int(input())): a=[] for j in range (int(input())): str1=input() t=0 li=list(str1) b=len(str1) if str1 not in s: s.add(str1) for x in range(0,b-1): if (li[x] in l and li[x+1] in l) or (li[x] in r and li[x+1] in r): t=t+1 ans =(b+t)*0.2 #this is actually (b-t)*0.2 +t*0.4 a.append(ans) else: for x in range(0,b-1): if (li[x] in l and li[x+1] in l) or (li[x] in r and li[x+1] in r): t=t+1 ans =(b+t)*0.1 a.append(ans) fans=sum(a)*10 print (int(fans)) asked 08 Nov, 15:58 2★v_shah 9●3 accept rate: 0%

 0 Your system for adding a time penalty per same-hand letter pair seems accurate. You would do better to work in integers throughout, basically adjusting so that your units of time are deciseconds (tenths of a second). I don't think that it is causing a problem here, with low numbers, but you could avoid the issue completely. However your actual main problem is that you don't reset your set s of known words between test cases. So encountering a word for the first time in a test case, you may score it like it is not the first time. answered 09 Nov, 04:41 5★joffan 914●8 accept rate: 12% Thanks a lot! (09 Nov, 17:13) v_shah2★
 0 I tried to understand what's happening when "str1 in s" and "not in s" but it's too late here and I'm sleepy. Here check my solution, everything is clear there: solution link answered 09 Nov, 03:57 4★tieros 73●4 accept rate: 12%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×416
×249
×15

question asked: 08 Nov, 15:58

question was seen: 110 times

last updated: 09 Nov, 17:13