You are viewing a single comment's thread. Return to all comments →
from itertools import count def check_rest(start,remains): for i in count(start+1): if not remains: return True if not remains.startswith(str(i)): return False remains = remains[len(str(i)):] def is_beautiful(s): for i in range(1,len(s)//2+1): if check_rest(int(s[:i]),s[i:]): print "YES %s"%s[:i] return print "NO" print is_beautiful("991992")
was my solution
Seems like cookies are disabled on this browser, please enable them to open this website
Separate the Numbers
You are viewing a single comment's thread. Return to all comments →
was my solution