Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Stone Wall by lucas234
from collections import Counter
def stone_wall(stone_str):
if "0" not in stone_str:
return 0
stone_str = stone_str.split()
index = [index1 for index, i in enumerate(stone_str) for index1, j in enumerate(i) if j == "0"]
return sorted(Counter(index).items(), key=lambda x:(x[1],-x[0]),reverse=True)[0][0]
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!")
April 8, 2019