We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Logic is to create sequence string from each number
s = '99910001001'
91011121314, 99100101102, 99910001001
whichever matches our input string print YES else NO
def separateNumbers(s):
for i in range(1, len(s)):
length = len(s)
i_seq = [int(s[:i])] # individual sequence
ns = ''
while len(ns) < length:
i_seq.append(i_seq[-1] + 1)
ns = ''.join([str(i) for i in i_seq])
if ns == s:
print(f'YES {i_seq[0]}')
return
print('NO')
Cookie support is required to access HackerRank
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 →
Logic is to create sequence string from each number s = '99910001001' 91011121314, 99100101102, 99910001001 whichever matches our input string print YES else NO
def separateNumbers(s):