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.
defwaiter(number,q):# Write your code hereprim=[]forjinrange(2,5*10**4):n=2whilej%n:n+=1ifn==j:prim.append(j)iflen(prim)==len(number):breakans=[]foriinrange(q):b=[]forjinrange(len(number)-1,-1,-1):ifnumber[j]%prim[i]==0:b.append(number[j])number.pop(j)number=number[::-1]ans+=b[::-1]returnans+number[::-1]
As usual, when you see the completion percentage for a question go below 90% you can suspect that it's going to be a bit nasty...
This problem has two parts: generating the first 'q' primes, and then doing the plate sorting/stacking.
Python 3:
C#
JavaScript...
Python