Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Auto Painting by Moff
def checkio(k, n):
parts = list(range(n))
if k >= n:
result = [parts, parts]
else:
r = n % k
result = []
for i in range(0, n - r - k, k):
for _ in range(2):
result.append(parts[i:i+k])
parts = parts[n-k-r:]
result.append(parts[:k])
result.append(parts[-k:])
if r > 0:
rest = parts[:r]+parts[-r:]
for i in range(0, len(rest), k):
result.append(rest[i:i+k])
return ','.join(''.join(map(str, s)) for s in result)
July 28, 2015