Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Auto Painting by Ricky
def checkio(capacity, number):
sides = [x for x in range(number)] * 2
spliter = (capacity, number)[capacity >= number]
return ','.join([''.join(map(str, sides[i:i + spliter])) for i in range(0, len(sides), spliter)])
if __name__ == '__main__':
#This part is using only for self-checking and not necessary for auto-testing
def check_solution(func, k, n, max_steps):
result = func(k, n)
actions = result.split(",")
if len(actions) > max_steps:
print("It can be shorter.")
return False
details = [0] * n
for act in actions:
if len(act) > k:
print("The system can contain {0} detail(s).".format(k))
return False
if len(set(act)) < len(act):
print("You can not place one detail twice in one load")
return False
for ch in act:
details[int(ch)] += 1
if any(d < 2 for d in details):
print("I see no painted details.")
return False
if any(d > 2 for d in details):
print("I see over painted details.")
return False
return True
assert check_solution(checkio, 2, 3, 3), "1st Example"
assert check_solution(checkio, 6, 3, 2), "2nd Example"
assert check_solution(checkio, 3, 6, 4), "3rd Example"
assert check_solution(checkio, 1, 4, 8), "4th Example"
assert check_solution(checkio, 2, 5, 5), "5th Example"
Sept. 30, 2016
Comments: