Skip to content

Instantly share code, notes, and snippets.

View aolle's full-sized avatar

Àngel Ollé Blázquez aolle

View GitHub Profile
code1.py
import re
s = 'aaaaabbbbccccccaaaaaaa'
d = tuple((c[0], len(c)) for c in [m.group(0) for m in re.finditer(r"(\w)\1*", s)])
l = [(str(t[1]),t[0]) for t in d]
''.join(str(j) for i in l for j in i)
Coarse grained benchmark time: 0.028s
@aolle
aolle / test.py
Last active April 10, 2018 04:49
A python test for an interview #1 - LinkedIn
import re
s = 'aaabbbaaa'
d = tuple((c[0], len(c)) for c in [m.group(0) for m in re.finditer(r"(\w)\1*", s)])
l = [(str(t[1]),t[0]) for t in d]
''.join(str(j) for i in l for j in i)