Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/ABC-problem/Python/abc-problem-3.py
Normal file
16
Task/ABC-problem/Python/abc-problem-3.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
def mkword(w, b):
|
||||
if not w: return []
|
||||
|
||||
c,w = w[0],w[1:]
|
||||
for i in range(len(b)):
|
||||
if c in b[i]:
|
||||
m = mkword(w, b[0:i] + b[i+1:])
|
||||
if m != None: return [b[i]] + m
|
||||
|
||||
def abc(w, blk):
|
||||
return mkword(w.upper(), [a.upper() for a in blk])
|
||||
|
||||
blocks = 'BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM'.split()
|
||||
|
||||
for w in ", A, bark, book, treat, common, SQUAD, conFUsEd".split(', '):
|
||||
print '\'' + w + '\'' + ' ->', abc(w, blocks)
|
||||
Loading…
Add table
Add a link
Reference in a new issue