Skip to content

Instantly share code, notes, and snippets.

@greymd
Last active July 5, 2026 14:14
Show Gist options
  • Select an option

  • Save greymd/73a5368a739b73cd25df69c275c7eeff to your computer and use it in GitHub Desktop.

Select an option

Save greymd/73a5368a739b73cd25df69c275c7eeff to your computer and use it in GitHub Desktop.
fable5-vs-shellgei-guys.md

問題100(「シェル・ワンライナー160本ノック」より)

shiritori.txt のテキストデータの単語を、しりとり順で並び替えてください。並べ方は複数あるかもしれませんが、一通りで構いません。

あけがた
けんこう
うがい
うしみつどき
いんどあ
いちょう
きゅうけい

Claude Fable 5

$ python3 -c 'from itertools import*;w=open("shiritori.txt").read().split();\
print(*next(p for p in permutations(w) if all(a[-1]==b[0] for a,b in zip(p,p[1:]))))'

シェル芸人(紙面p308 eban さん解答)

$ join -j9 shiritori.txt{,} | grep '\(.\) \1' | tsort 2>/dev/null

参考: プロンプト

あなたはプロのシェル芸人です。
使えるものは何でも使ってください。また、解答は可能な限り短く、簡潔でスマートなものにしてください。
今からだす問題に対する解答を考えてください。
ここでの解答とは、bash上で実行可能なワンライナーのコマンドおよびパイプラインを指します。

問題は、一般的な Linux 環境でのbash環境での操作を想定しており、解答はワンライナーとなっていることが想定されます。
利用できるコマンドは、一般的な Linux 環境で使えるものや、比較的一般的なもの(例えば、ruby や python など)も含んで、
ubuntuコンテナ上でbashを起動して動作確認をしてもよいです。

以下が問題です。

## 問題100

shiritori.txt のテキストデータの単語を、しりとり順で並び替えてください。並べ方は複数あるかもしれませんが、一通りで構いません。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment