Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Auto Painting by Sim0000
def checkio(capacity, number):
return ','.join([''.join([str(i) for i in range(number)]*2)[i:i+min(capacity, number)] for i in range(0, 2*number, min(capacity, number))])
# 2nd version (1 line)
# 1. make string '012012' repeated twice
# 2. divide string of length min(capacity, number), ['01','20','12']
# 3. make string with ',' inserted using join
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
print(checkio(2, 3)) # "01,12,02"
print(checkio(6, 3)) # "012,012"
print(checkio(3, 6)) # "012,012,345,345"
print(checkio(1, 4)) # "0,0,1,1,2,2,3,3"
print(checkio(2, 5)) # "01,01,23,42,34"
Feb. 21, 2014
Comments: