Question: Relabel a list of lists so that the third occurrence of each number becomes that number+1?

Hi,

Help please! Maple beginner here. I'm trying to relabel a list of lists and sets so that the third occurrence of each number becomes that number+1,

 

eg. [[1],[{1,2}],[{1,2}]] ----->  [[1],[{1,2}],[{2,3}]]

or [[1],[{1,2,3}],[{1,2}]] -----> [[1],[{1,2,3}],[{2,3}]]

 

I think because there are sublists and subsets, I can't use things like member(x, s, 'p') or SearchAll (ListTools), so not sure what to do. Any suggestions?

Cheers

Please Wait...