Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
range and lambda solution in Clear category for The Stone Wall by rafal.pawlowski
def stone_wall(wall):
wall = [el for el in wall.split('\n') if el != '']
wall_rot = [list(reversed(x)) for x in zip(*wall)]
maxi = [row.count('0') for row in wall_rot]
return max(range(len(maxi)), key = lambda x : maxi[x])
if __name__ == '__main__':
print("Example:")
print(stone_wall('''
##########
####0##0##
00##0###00
'''))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert stone_wall('''
##########
####0##0##
00##0###00
''') == 4
assert stone_wall('''
#00#######
#######0##
00######00
''') == 1
assert stone_wall('''
#####
#####
#####
''') == 0
print("Coding complete? Click 'Check' to earn cool rewards!")
Feb. 18, 2019
Comments: