Skip to content

Instantly share code, notes, and snippets.

@bgnori
Created October 24, 2017 08:54
Show Gist options
  • Save bgnori/9d1306030bb03ae66c5df35460fc9a67 to your computer and use it in GitHub Desktop.
Save bgnori/9d1306030bb03ae66c5df35460fc9a67 to your computer and use it in GitHub Desktop.
ws = ["イアラ","ウェイト","オメガロ","ガルヒ","ガングリオンズ","クリオ","ジェノバ","スノウガ","ズビズバ","スペシウム","タグアズ","ドドンパ","トルネ","ネメシス","バイナリル","ハザード","パリピファイア","バルース","ヒラケゴマ","フェイク","プリズマ","ホルーガ","マッハ","マホマホ","ムート","ラリホフ","ランス","ループ","ロールウェイブ","ワロス"]
conn = {}
for w in ws:
for v in ws:
if w[-1] == v[0]:
conn[(w, v)] = True
print(conn)
def rest(xs, n):
return xs[:n]+xs[n+1:]
def search(xs, ys):
found = False
for i, y in enumerate(ys):
if (xs[-1], y) in conn:
found = True
search(xs+[y], rest(ys, i))
if not found:
print(len(xs), xs)
for j, _ in enumerate(ws):
print(j, ws[j])
search([ws[j]], rest(ws, j))
print("="*30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment