Created
December 2, 2015 14:35
-
-
Save mikkun/fc2c9e24facbd2f43ea7 to your computer and use it in GitHub Desktop.
「シェル芸勉強会の前座的な手抜き」の解答例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
「シェル芸勉強会の前座的な手抜き」の解答例 | |
問題URL: http://techlion.jp/archives/9691 | |
問題 | |
連結したら素数になるという素数のペアを、ワンライナーでなるべくたくさん挙げてみましょう。 | |
例: 2と3(連結したら23で素数。) | |
解答例 | |
$ echo {2..100}" "{2..100} | factor | sed -rz 's/([^\n]+)\n([^\n]+)\n/\1 \2\n/g' | awk 'NF==4{print $2,$4;system("factor "$2$4)}' | sed -rz 's/([^\n]+)\n([^\n]+)\n/\1 \2\n/g' | awk 'NF==4{print $1,$2}' | |
2 3 | |
2 11 | |
2 23 | |
2 29 | |
2 41 | |
2 71 | |
2 83 | |
3 7 | |
3 11 | |
3 13 | |
(...中略...) | |
83 53 | |
83 89 | |
89 23 | |
89 29 | |
89 41 | |
89 71 | |
97 7 | |
97 19 | |
97 43 | |
97 67 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment