SlideShare una empresa de Scribd logo
1 de 11
Descargar para leer sin conexión
5分間hangmanで遊ぶ!
@ksmakoto(きしもと)
hangmanとは?
● 昔はUnix(BSD)に標準添付だったゲームのひとつ
●
いわゆる単語当てゲーム
●
単語中に含まれないアルファベットを答えると、
吊るされている人(hangman)が描き加えられる
● /usr/share/dict/words ファイルから出題
●
日本人にはつらい
● Unixコマンドを使って(チートではなく)楽をしよう
hangmanの入手とビルド
● bsdgamesのような名前のportsやパッケージに
ごった煮状態で入っている(rogue, mille等)
● 私が確認したFreeBSDのportsで入る版にはバグ
(出題の単語中に大文字が含まれるが、大文字は回
答できない)
● 現在ソースをメンテしてるのはDragonFly BSDプロ
ジェクトなので、DragonFlyのリポジトリから最新版を
取ってきてビルド!
アルファベットの頻度(1)
● 有名な「ETAOIN SHRDLU」 → これは使えない
アルファベットの頻度(2)
● 「ETAOIN SHRDLU」は、「通常の英文」の頻度
● hangmanのような「辞書の見出し語」の頻度ではない
● 例: 辞書には「the」や「that」や「they」が出てくるの
は、1回だけ
● hangmanでは単語の長さもヒントになるが、調べてみる
とそれだけでもアルファベットの頻度は変動する
アルファベットの頻度(3)
● hangman用の頻度調査
● wordsファイルを使うので「あるアルファベットが出現する
行(単語)はいくつか?」をかぞえるawkスクリプト
● その他はおなじみのgrepとsortで
アルファベットの頻度(3)cont
BEGIN {
split("", count)
}
END {
for (c in count) {
print(count[c] " '" c "'")
}
print NR " lines"
}
{
split($0, arr1, "")
for (n in arr1) {
arr2[arr1[n]] = 1
}
for (c in arr2) {
count[c] += 1
}
delete arr2
}
実例
● 出題: Word: --------- (9文字)
● grep -i '^.........$' /usr/shate/dict/words |
./hang_count.awk |
sort -nk 1
● 19171 'a'
20073 'I'
22456 'e'
32407 lines
実例
● Word: -er-tri-e
● grep -i '^.er.tri.e$' /usr/shate/dict/words |
./hang_count.awk | sort -nk 1
● 3 'z'
5 'e'
5 'I'
5 'r'
5 't'
5 lines … ここで ”z” は外れた
実例
● Word: -er-tri-e
● grep -i '^.er.tri.e$' /usr/shate/dict/words |
grep -v -e z | ./hang_count.awk
● pedotribe
veratribe
● 本当は「.」もマッチし過ぎている(既に出ている以外の
文字、に絞りたい)が、grepで簡単に表現する方法が
ない( . の代わりに [^erti] のようなのを並べるしかない)
まとめ
● hangmanを簡単なスクリプトとコマンドで攻略する方
法を紹介した
● まだ詰められる点はあるが、発表者による30分ほどの評
価では、おおむねほぼ全てのゲームでwin可

Más contenido relacionado

La actualidad más candente

x86 CPUにejectコマンドを組み込みたい!
x86 CPUにejectコマンドを組み込みたい!x86 CPUにejectコマンドを組み込みたい!
x86 CPUにejectコマンドを組み込みたい!furandon_pig
 
俺のGentooがこんなに可愛いわけがない
俺のGentooがこんなに可愛いわけがない俺のGentooがこんなに可愛いわけがない
俺のGentooがこんなに可愛いわけがないTakuto Matsuu
 
TddでFizzBuzzしてみる in Swift
TddでFizzBuzzしてみる in SwiftTddでFizzBuzzしてみる in Swift
TddでFizzBuzzしてみる in SwiftShoichi Matsuda
 
今最もアツイdistribution Gentoo Linuxについて
今最もアツイdistribution Gentoo Linuxについて今最もアツイdistribution Gentoo Linuxについて
今最もアツイdistribution Gentoo LinuxについてTakuto Matsuu
 
マウスを使わないでキーボードで快適に生活する方法(GNU Screen/tmux/byobu/awesome)
マウスを使わないでキーボードで快適に生活する方法(GNU Screen/tmux/byobu/awesome)マウスを使わないでキーボードで快適に生活する方法(GNU Screen/tmux/byobu/awesome)
マウスを使わないでキーボードで快適に生活する方法(GNU Screen/tmux/byobu/awesome)Kenichiro MATOHARA
 
doctest を書こう @ pycon kansai
doctest を書こう @ pycon kansaidoctest を書こう @ pycon kansai
doctest を書こう @ pycon kansaiYosukeHojo
 
Pythonでクラウド上のスクリプトを実行する
Pythonでクラウド上のスクリプトを実行するPythonでクラウド上のスクリプトを実行する
Pythonでクラウド上のスクリプトを実行するaoshiman
 
シェルスクリプトを極める
シェルスクリプトを極めるシェルスクリプトを極める
シェルスクリプトを極めるbsdhack
 
謎PCとの付き合い方(LILO東海道 2015/5発表分)
謎PCとの付き合い方(LILO東海道 2015/5発表分)謎PCとの付き合い方(LILO東海道 2015/5発表分)
謎PCとの付き合い方(LILO東海道 2015/5発表分)shimadah
 
Ren’pyの御紹介
Ren’pyの御紹介Ren’pyの御紹介
Ren’pyの御紹介zgock
 
ほんとはこわくない Gentoo Linux
ほんとはこわくない Gentoo Linuxほんとはこわくない Gentoo Linux
ほんとはこわくない Gentoo Linuxgion_XY
 
20130126 第2回福岡debian勉強会 debian wheezyとdebian installerのはなし
20130126 第2回福岡debian勉強会 debian wheezyとdebian installerのはなし20130126 第2回福岡debian勉強会 debian wheezyとdebian installerのはなし
20130126 第2回福岡debian勉強会 debian wheezyとdebian installerのはなしTsuyoshi Yamada
 
エンジニアのための痔の話
エンジニアのための痔の話エンジニアのための痔の話
エンジニアのための痔の話Kouhei Maeda
 
S2s websrv201011-presen
S2s websrv201011-presenS2s websrv201011-presen
S2s websrv201011-presenKouhei Maeda
 
冴えないデータセットの育て方
冴えないデータセットの育て方冴えないデータセットの育て方
冴えないデータセットの育て方Kazuhiro Sasao
 
[Vitocha.iso] FreeBSDカスタムiso作ってみた
[Vitocha.iso] FreeBSDカスタムiso作ってみた[Vitocha.iso] FreeBSDカスタムiso作ってみた
[Vitocha.iso] FreeBSDカスタムiso作ってみたshutingrz
 
Lets talk about ubuntu from now (Japanese only)
Lets talk about ubuntu from now (Japanese only)Lets talk about ubuntu from now (Japanese only)
Lets talk about ubuntu from now (Japanese only)Hidetsugu Takahashi
 

La actualidad más candente (20)

x86 CPUにejectコマンドを組み込みたい!
x86 CPUにejectコマンドを組み込みたい!x86 CPUにejectコマンドを組み込みたい!
x86 CPUにejectコマンドを組み込みたい!
 
俺のGentooがこんなに可愛いわけがない
俺のGentooがこんなに可愛いわけがない俺のGentooがこんなに可愛いわけがない
俺のGentooがこんなに可愛いわけがない
 
TddでFizzBuzzしてみる in Swift
TddでFizzBuzzしてみる in SwiftTddでFizzBuzzしてみる in Swift
TddでFizzBuzzしてみる in Swift
 
今最もアツイdistribution Gentoo Linuxについて
今最もアツイdistribution Gentoo Linuxについて今最もアツイdistribution Gentoo Linuxについて
今最もアツイdistribution Gentoo Linuxについて
 
マウスを使わないでキーボードで快適に生活する方法(GNU Screen/tmux/byobu/awesome)
マウスを使わないでキーボードで快適に生活する方法(GNU Screen/tmux/byobu/awesome)マウスを使わないでキーボードで快適に生活する方法(GNU Screen/tmux/byobu/awesome)
マウスを使わないでキーボードで快適に生活する方法(GNU Screen/tmux/byobu/awesome)
 
doctest を書こう @ pycon kansai
doctest を書こう @ pycon kansaidoctest を書こう @ pycon kansai
doctest を書こう @ pycon kansai
 
Pythonでクラウド上のスクリプトを実行する
Pythonでクラウド上のスクリプトを実行するPythonでクラウド上のスクリプトを実行する
Pythonでクラウド上のスクリプトを実行する
 
シェルスクリプトを極める
シェルスクリプトを極めるシェルスクリプトを極める
シェルスクリプトを極める
 
謎PCとの付き合い方(LILO東海道 2015/5発表分)
謎PCとの付き合い方(LILO東海道 2015/5発表分)謎PCとの付き合い方(LILO東海道 2015/5発表分)
謎PCとの付き合い方(LILO東海道 2015/5発表分)
 
Ren’pyの御紹介
Ren’pyの御紹介Ren’pyの御紹介
Ren’pyの御紹介
 
卒制Ne wver
卒制Ne wver卒制Ne wver
卒制Ne wver
 
ほんとはこわくない Gentoo Linux
ほんとはこわくない Gentoo Linuxほんとはこわくない Gentoo Linux
ほんとはこわくない Gentoo Linux
 
20130126 第2回福岡debian勉強会 debian wheezyとdebian installerのはなし
20130126 第2回福岡debian勉強会 debian wheezyとdebian installerのはなし20130126 第2回福岡debian勉強会 debian wheezyとdebian installerのはなし
20130126 第2回福岡debian勉強会 debian wheezyとdebian installerのはなし
 
エンジニアのための痔の話
エンジニアのための痔の話エンジニアのための痔の話
エンジニアのための痔の話
 
Hostsの活用
Hostsの活用Hostsの活用
Hostsの活用
 
S2s websrv201011-presen
S2s websrv201011-presenS2s websrv201011-presen
S2s websrv201011-presen
 
冴えないデータセットの育て方
冴えないデータセットの育て方冴えないデータセットの育て方
冴えないデータセットの育て方
 
[Vitocha.iso] FreeBSDカスタムiso作ってみた
[Vitocha.iso] FreeBSDカスタムiso作ってみた[Vitocha.iso] FreeBSDカスタムiso作ってみた
[Vitocha.iso] FreeBSDカスタムiso作ってみた
 
Vimpulse について
Vimpulse についてVimpulse について
Vimpulse について
 
Lets talk about ubuntu from now (Japanese only)
Lets talk about ubuntu from now (Japanese only)Lets talk about ubuntu from now (Japanese only)
Lets talk about ubuntu from now (Japanese only)
 

Destacado

TOEIC: Causative Verbs
TOEIC: Causative Verbs TOEIC: Causative Verbs
TOEIC: Causative Verbs ULCO
 
Passe compose with avoir
Passe compose with avoirPasse compose with avoir
Passe compose with avoirellsley
 
Concepcão Ioruba da alma (bascom)
Concepcão Ioruba da alma (bascom)Concepcão Ioruba da alma (bascom)
Concepcão Ioruba da alma (bascom)Luiz L. Marins
 
Procedimiento administrativo EIA
Procedimiento administrativo EIAProcedimiento administrativo EIA
Procedimiento administrativo EIAPelodytes
 
Network ap is for future internet
Network ap is for future internetNetwork ap is for future internet
Network ap is for future internetShahzeeb Pk
 
The Paulinian Story & History
The Paulinian Story & HistoryThe Paulinian Story & History
The Paulinian Story & HistoryMonte Christo
 
Arachnida dan myriapoda
Arachnida dan myriapodaArachnida dan myriapoda
Arachnida dan myriapodailyabasma
 
Historia e se Drejtes 3
Historia e se Drejtes 3Historia e se Drejtes 3
Historia e se Drejtes 3Ferdi Nuredini
 
Etre With Passe Compose
Etre With Passe ComposeEtre With Passe Compose
Etre With Passe ComposeOdessa78
 
Paternalism v autonomy.
Paternalism v autonomy.Paternalism v autonomy.
Paternalism v autonomy.Siti Azhar
 
How can Training & Development increase employee retention?
How can Training & Development increase employee retention?How can Training & Development increase employee retention?
How can Training & Development increase employee retention?Tchissole Carvalho
 
Amylases and pectinases
Amylases and pectinasesAmylases and pectinases
Amylases and pectinasessudha rajput
 
Introduction letter 2014
Introduction letter 2014 Introduction letter 2014
Introduction letter 2014 mmaquasystems
 

Destacado (20)

TOEIC: Causative Verbs
TOEIC: Causative Verbs TOEIC: Causative Verbs
TOEIC: Causative Verbs
 
Passe compose with avoir
Passe compose with avoirPasse compose with avoir
Passe compose with avoir
 
Concepcão Ioruba da alma (bascom)
Concepcão Ioruba da alma (bascom)Concepcão Ioruba da alma (bascom)
Concepcão Ioruba da alma (bascom)
 
Procedimiento administrativo EIA
Procedimiento administrativo EIAProcedimiento administrativo EIA
Procedimiento administrativo EIA
 
Topic 004
Topic 004Topic 004
Topic 004
 
Network ap is for future internet
Network ap is for future internetNetwork ap is for future internet
Network ap is for future internet
 
Pasquin
PasquinPasquin
Pasquin
 
Peritonitis 2
Peritonitis 2Peritonitis 2
Peritonitis 2
 
The Paulinian Story & History
The Paulinian Story & HistoryThe Paulinian Story & History
The Paulinian Story & History
 
Arachnida dan myriapoda
Arachnida dan myriapodaArachnida dan myriapoda
Arachnida dan myriapoda
 
Historia e se Drejtes 3
Historia e se Drejtes 3Historia e se Drejtes 3
Historia e se Drejtes 3
 
Paternalism
PaternalismPaternalism
Paternalism
 
pedological anatomy
pedological anatomypedological anatomy
pedological anatomy
 
Etre With Passe Compose
Etre With Passe ComposeEtre With Passe Compose
Etre With Passe Compose
 
Paternalism v autonomy.
Paternalism v autonomy.Paternalism v autonomy.
Paternalism v autonomy.
 
Pedophilia
PedophiliaPedophilia
Pedophilia
 
How can Training & Development increase employee retention?
How can Training & Development increase employee retention?How can Training & Development increase employee retention?
How can Training & Development increase employee retention?
 
Amylases and pectinases
Amylases and pectinasesAmylases and pectinases
Amylases and pectinases
 
Pectinase
PectinasePectinase
Pectinase
 
Introduction letter 2014
Introduction letter 2014 Introduction letter 2014
Introduction letter 2014
 

Más de Makoto Kishimoto (9)

CHP survey
CHP surveyCHP survey
CHP survey
 
some SHA1 implementation
some SHA1 implementationsome SHA1 implementation
some SHA1 implementation
 
Visulan intro
Visulan introVisulan intro
Visulan intro
 
20151121
2015112120151121
20151121
 
Shizuoka go lang csp
Shizuoka go lang cspShizuoka go lang csp
Shizuoka go lang csp
 
FZ and DAZ in denormals
FZ and DAZ in denormalsFZ and DAZ in denormals
FZ and DAZ in denormals
 
Subprocess no susume
Subprocess no susumeSubprocess no susume
Subprocess no susume
 
Node handson
Node handsonNode handson
Node handson
 
app-c.odp
app-c.odpapp-c.odp
app-c.odp
 

Tech oyaji ksmakoto_presen