You are viewing a single comment's thread. Return to all comments →
Python Solution:
def waiter(number, q): lower = 2 upper = 10000 p = [i for i in range(lower, upper + 1) if all(i % j != 0 for j in range(2, i))] ans = [] stackA = [] stackB = [] for i in range(q): if i == 0: s = number else: s = stackA stackA = [] for j in range(len(s)): x = s.pop() if x % p[i] == 0: stackB.append(x) else: stackA.append(x) while stackB: ans.append(stackB.pop()) while stackA: ans.append(stackA.pop()) return ans
Seems like cookies are disabled on this browser, please enable them to open this website
Waiter
You are viewing a single comment's thread. Return to all comments →
Python Solution: