Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- texts = [['a','a','b'], ['a','a','a','b','b','c'], ['b','a','b'], ['a','c','a','b','a','b']]
- for text in texts:
- highest = 1
- thing = {highest: []}
- for t in text:
- found = False
- for h in xrange(highest, 0, -1):
- if h == 0:
- continue
- for x in thing[h]:
- if found:
- break
- if x == t:
- found = True
- if highest == h:
- highest+=1
- thing[highest] = []
- thing[h+1].append(t)
- if found:
- while t in thing[h]:
- thing[h].remove(t)
- thing[h+1].append(t)
- if not found:
- thing[1].append(t)
- print thing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement