Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
The square chest solution in Uncategorized category for The Square Chest by capback250
# migrated from python 2.7
def checkio(coords):
sqares = 0
sqares = find_small(coords) + find_med(coords) + find_max(coords)
return sqares
def find_small(coords):
sqar = 0
for x in range(1,17):
if ([x, x+1] in coords or [x+1, x] in coords) and ([x+1, x+5] in coords or [x+5, x+1] in coords) and \
([x, x+4] in coords or[x+4, x] in coords) and ([x+4, x+5] in coords or [x+5, x+4] in coords):
sqar += 1
print("small", sqar)
return sqar
def find_med(coords):
sqar = 0
for x in range(1,17):
if ([x, x+1] in coords or [x+1, x] in coords) and ([x+1, x+2] in coords or [x+2, x+1] in coords) \
and ([x, x+4] in coords or [x+4, x] in coords) and ([x+4, x+8] in coords or [x+8, x+4] in coords) \
and ([x+2, x+6] in coords or [x+6, x+2] in coords) and ([x+6, x+10] in coords or [x+10, x+6] in coords) \
and ([x+8, x+9] in coords or [x+9, x+8] in coords) and ([x+9, x+10] in coords or [x+10, x+9] in coords):
sqar += 1
print("med", sqar)
return sqar
def find_max(coords):
if ([1, 2] in coords or [2, 1] in coords) and ([2, 3] in coords or [3, 2] in coords) and ([3, 4] in coords or [4, 3] in coords) and ([1, 5] in coords or [5, 1] in coords) \
and ([5, 9] in coords or [9, 5] in coords) and ([9, 13] in coords or [13, 9] in coords) and ([13, 14] in coords or [14, 13] in coords) \
and ([14, 15] in coords or [15, 14] in coords) and ([15, 16] in coords or [16, 15] in coords)and ([4, 8] in coords or [8, 4] in coords) \
and ([8, 12] in coords or [12, 8] in coords) and ([12, 16] in coords or [16, 12] in coords):
print("max")
return 1
else:
return 0
Aug. 28, 2015