Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
rows -> columns -> min(count('#')) solution in Clear category for The Stone Wall by Merzix
def stone_wall(wall):
rows = wall.splitlines()[1:]
columns = list(map(''.join, zip(*rows)))
gap = [(i,x.count('#')) for i,x in enumerate(columns)] # [(index, thickness), ...]
return min(gap, key=lambda m:m[1])[0]
if __name__ == '__main__':
assert stone_wall('''
##########
####0##0##
00##0###00
''') == 4
assert stone_wall('''
#00#######
#######0##
00######00
''') == 1
assert stone_wall('''
#####
#####
#####
''') == 0
assert stone_wall('''
#####
##000
#####
''') == 2
assert stone_wall('''
####0#
#0#00#
#0#0##
''') == 1
Sept. 7, 2018