Skip to content

Instantly share code, notes, and snippets.

Chuancong Gao chuanconggao

Block or report user

Report or block chuanconggao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chuanconggao
chuanconggao / prefixspan.py
Last active Nov 5, 2018
The original minimal 15 lines implementation of PrefixSpan. Full library at https://github.com/chuanconggao/PrefixSpan-py.
View prefixspan.py
from collections import defaultdict
def frequent_rec(patt, mdb):
results.append((len(mdb), patt))
occurs = defaultdict(list)
for (i, startpos) in mdb:
seq = db[i]
for j in range(startpos + 1, len(seq)):
l = occurs[seq[j]]
@chuanconggao
chuanconggao / anagrams.py
Last active Mar 8, 2018 — forked from jMuzsik/anagrams.py
Code for computing anagrams that works on both string and list.
View anagrams.py
def anagrams(s):
return [s] if len(s) == 0 else [
w[:pos] + s[:1] + w[pos:]
for w in anagrams(s[1:])
for pos in range(len(w) + 1)
]
anagrams("abc")
# returns ['abc', 'bac', 'bca', 'acb', 'cab', 'cba']
You can’t perform that action at this time.