Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Square Chest by UFO665
lstGrid = [[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12],
[13, 14, 15, 16]]
def lines(leftTop, length):
x, y = leftTop
topSide = [[lstGrid[x][y + i], lstGrid[x][y + i + 1]] for i in range(length)]
leftSide = [[lstGrid[x + i][y], lstGrid[x + i + 1][y]] for i in range(length)]
rightSide = [[lstGrid[x + i][y + length], lstGrid[x + i + 1][y + length]] for i in range(length)]
bottomSide = [[lstGrid[x + length][y + i], lstGrid[x + length][y + i + 1]] for i in range(length)]
return topSide + leftSide + rightSide + bottomSide
def squares():
lst = []
for i in range(3):
for j in range(3):
lst += [lines([i, j], l) for l in range(1, 4 - max([i, j]))]
return lst
def checkio(lst):
lst = [sorted(line) for line in lst]
return sum(all(line in lst for line in lines) for lines in squares())
Dec. 25, 2015