Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Auto Painting by panaro32
def checkio(k,n):
return ','.join(('0123456789'[:n]*2)[i:i+min(k,n)] for i in range(0,2*n,min(k,n)))
if __name__ == '__main__':
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"
June 15, 2014