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

×

why do i get wrong answer in the following question (CLFIBD|python3.6)

Question code: CLFIBD

My code:for i in range(int(input())): str1=input() l=list(str1) s=set(l) l2=[] if len(s)<3: print("Dynamic") else: for x in s: a=l.count(x) l2.append(a) l2.sort() b=len(l2) ans=True for y in range(0,b-2): if l2[y]+l2[y+1]==l2[y+2]: ans=ans and True else: ans=ans and False if ans ==True: print ("Dynamic") else: print ("Not")

asked 07 Nov, 19:31

v_shah's gravatar image

2★v_shah
93
accept rate: 0%

edited 07 Nov, 19:35


You need to take into account this case:

abbcccdddd

which is Dynamic under the permutation (b,a,c,d).

link

answered 07 Nov, 20:00

joffan's gravatar image

4★joffan
6457
accept rate: 12%

Oh correct. Thanks a lot

(08 Nov, 00:17) v_shah2★
toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×401
×242
×16

question asked: 07 Nov, 19:31

question was seen: 56 times

last updated: 08 Nov, 00:17