Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple solution in Clear category for The Square Chest by nakanohito_piyo
def checkio(lines_list):
lines_list = [sorted(x) for x in lines_list] #sort each element
ret = 0
ret += sum([1 for i in [1,2,3,5,6,7,9,10,11] if single(lines_list, i)])
ret += sum([1 for i in [1,2,5,6] if double(lines_list, i)])
ret += sum([1 for i in [1] if triple(lines_list, i)])
return ret
def single(lines_list,start):
return all([\
[start, start+1] in lines_list,
[start, start+4] in lines_list,
[start+1, start+5] in lines_list,
[start+4, start+5] in lines_list])
def double(lines_list,start):
return all([\
[start, start+1] in lines_list,
[start+1, start+2] in lines_list,
[start+2, start+6] in lines_list,
[start+6, start+10] in lines_list,
[start+9, start+10] in lines_list,
[start+8, start+9] in lines_list,
[start+4, start+8] in lines_list,
[start, start+4] in lines_list])
def triple(lines_list,start):
return all([\
[start, start+1] in lines_list,
[start+1, start+2] in lines_list,
[start+2, start+3] in lines_list,
[start+3, start+7] in lines_list,
[start+7, start+11] in lines_list,
[start+11, start+15] in lines_list,
[start+14, start+15] in lines_list,
[start+13, start+14] in lines_list,
[start+12, start+13] in lines_list,
[start+8, start+12] in lines_list,
[start+4, start+8] in lines_list,
[start, start+4] in lines_list])
June 26, 2015