itertools recipe from python docs solution in Speedy category for All the Same by Phil15
from itertools import groupby
"Returns True if all the elements are equal to each other"
g = groupby(iterable)
return next(g, True) and not next(g, False)
March 6, 2020