Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Group Equal consecutive by rafal.pawlowski
def group_equal(els):
if not els:
return []
i = 0
new_list = True
temp_list = []
solution = []
while i < len(els):
if new_list or els[i] == els[i-1]:
temp_list += [els[i]]
new_list = False
i += 1
else:
solution += [temp_list[::]]
temp_list = []
new_list = True
solution += [temp_list]
return solution
July 7, 2019