Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created October 13, 2015 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/b342711b0b98280ae494 to your computer and use it in GitHub Desktop.
Save whatalnk/b342711b0b98280ae494 to your computer and use it in GitHub Desktop.
TopCoder SRM 647 Div2
# SRM 647 Div2 Easy
# http://community.topcoder.com/stat?c=problem_statement&pm=13632
class PeacefulLine():
def makeLine(self, x):
d = {}
for i in x:
if i in d.keys():
d[i] += 1
else:
d[i] = 1
if len(x) % 2 == 0:
lim = len(x)//2 + 1
else:
lim = len(x)//2 + 2
if max(d.values()) < lim:
return "possible"
else:
return "impossible"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment