Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Compact solution with numpy and scipy.ndimage solution in 3rd party category for The Buttons by rodka81
import numpy as np
from scipy.ndimage import label
def buttons(ceiling):
m = np.asarray([list(x) for x in ceiling.splitlines() if x]).astype(int)
labeled_array, num_features = label(m)
return sorted([np.asscalar(np.sum(m[labeled_array == i]))
for i in range(1, num_features+1)], reverse=True)
Sept. 23, 2018
Comments: