You are viewing a single comment's thread. Return to all comments →
#!/bin/python3 from collections import deque def separateNumbers(s): d = 1 n = len(s) while d < n: dq = deque(list(s[d:])) first = s[:d] a = s[:d] b = "" while dq: if not a or a[0] == '0': break if all(n == '9' for n in a): d += 1 for _ in range(d): if dq: b += dq.popleft() if not b or b[0] == '0' or int(b) - int(a) != 1: break if not dq: print(f"YES {first}") return else: a, b = b + '', '' d = len(first) + 1 print("NO") return
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 →