Advertisement
Madmouse

stoner code lol

Jul 8th, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. def string_tokens(l):
  2.     result = list()
  3.     for s in l:
  4.         token = str()
  5.         for c in s:
  6.             token += "N" if is_number(c) else "A" if is_alpha(c) else "S" if is_white(c) else "-"
  7.         result.append(token)
  8.     return list(set(result))
  9.  
  10. def group_tokens(l):
  11.     r = list()
  12.     for s in l:
  13.         i = 0
  14.         x = 0
  15.         o = s[0]
  16.         t = list()
  17.         for c in s:
  18.             if c != o:
  19.                 t.append(s[x : i])
  20.                 x = i
  21.             i += 1
  22.             o = c
  23.         if x != i:
  24.             t.append(s[x:])
  25.         r.append(t)
  26.     return r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement