Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 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