Given an ordered list of values, I want to group any members having the same value and output a count of each value:
For example,
input: [1,1,1,3,3,2,1,1]
output:
[(1,3),(3,2),(2,1),(1,2)]
input:['a','a','b','b','c','a']
output:
[('a',2),(b,2),(c,1),(a,1)]
Additionally, I want to treat the first and last values specially. What is the optimal way to do this?