Last active
December 29, 2019 11:21
-
-
Save papiron/f756665dc65176ba1b86b2b84db3641f to your computer and use it in GitHub Desktop.
This file contains 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
問題のリンク | |
https://b.ueda.tech/?post=20191228_shellgei_45_q | |
問題データのgitリポジトリ | |
https://github.com/ryuichiueda/ShellGeiData.git | |
取得コマンド | |
$ git clone https://github.com/ryuichiueda/ShellGeiData.git | |
シェル芸勉強会過去問 | |
https://b.ueda.tech/?page=00684 | |
Q1解答例 | |
$ nkf data.csv | sort -t/ -r -V | sort -s -t, -k2,2 | awk -F, '!a[$2]++' | |
peeやspongeは moreutils に付属のコマンド | |
Q3解答例 | |
$ cmp -l <(tr -d '\n' < flags_a) <(tr -d '\n' < flags_b) | awk '!(NR%2){print $1/8}' | |
39 | |
65 | |
Q3解答例(上田さんより) | |
$ paste <(grep -o .. flags_a) <(grep -o .. flags_b) | awk '$1!=$2{print NR}' | |
39 | |
65 | |
Q5解答例(ただし処理が遅い) | |
$ cat message | awk -F '' '{for(i=1;i<=NF-3;i++){for(j=1;j<=NF-i;j++)print substr($0,i,j)}}' | while read l; do echo $l | pee cat rev | uniq -d; done | awk 'length>1' | |
Q5解答例(鳥海さん変態芸) | |
$ perl -C -lne '/..+(?{print$&})(?!)/' message | ruby -anle 'puts $_ + " " + $_.reverse' | awk '$1==$2' | awk '{print $1}' | |
Q6解答例(上田さんより) | |
$ cat message.ans | while read l; do grep $l -o message.ans; done | sort | uniq -u | |
おかしがすきすきすがしかお | |
きつつき | |
たけやぶやけた | |
とまと | |
ゆんゆ | |
んゆん | |
Q7解答例(上田さん) | |
$ echo 1 7 | awk '{print "0.";a=$1;while(1){print int(10*a/$2);a=(10*a)%$2}}' | tr -d \\n | head -c 100 | |
Q7解答例(田代のズルい解答、無限ではなく10万桁まで) | |
$ echo 1 7 | sed 's@\(.\) \(.\)@scale=1000000;\1/\2@' | bc | tr -d '\\\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment