SlideShare a Scribd company logo
1 of 31
Download to read offline
@aomoriringo


ゴルフ



Code Golf

◦ 少ない打数でカップにボール入れる

◦ 少ない文字数で目的の出力をする






ショートコーディングのサイト
http://golf.shinh.org/
83の言語に対応
(Mathematicaは当然未対応)
言語別の文字数ランキングも閲覧可
Mathematicaで勝手に
ランキング1位を目指してみよう


“Hello, world!” と出力せよ。



Input



Output

◦ なし

◦ Hello, world!
Hello, world! (13byte)
“Hello, world!” (15byte)
“Hello, world!”
(15 byte)
Rank

Lang

Size

2

bash

11

4

PHP
m4
fish
A+
sed

13

1

3

5

goruby

Zsh

Ruby
Perl
Universal Lambda

1

12

14




1から100までの整数を出力せよ。
ただし 3の倍数のときは”Fizz”,
5の倍数のときは”Buzz”,
15の倍数のときは”FizzBuzz”,
と数字の代わりに出力せよ。
Output
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13
14 FizzBuzz 16 17 . . .
Rank

Lang

2

GolfScript

1
3

4
5

6
7
8
9

10

Size

FlogScript

36

Bash

41

Perl6
J

goruby
Vi

Perl

Z80

Postscript
Ruby

37

44
45
46
47
48
49
50


自然定数eを100桁表示せよ。



Input



Output

◦ なし

◦ 27182818284590452353602874713526624977
57247093699959574966967627724076630353
5475945713821785251664274
N[E,101]


2.71828182845904523536028747135266
2497757247093699959574966967627724
0766303535475945713821785251664274




2.71828182845904523536028747135266
2497757247093699959574966967627724
0766303535475945713821785251664274

2718281828459045235360287471352662
4977572470936999595749669676277240
766303535475945713821785251664274
N[E,101]
2.718281828459045235360287471352662
4977572470936999595749669676277240
766303535475945713821785251664274
ToString[N[E,101]]
“2.718281828459045235360287471352662
4977572470936999595749669676277240
766303535475945713821785251664274”
StringSplit[ToString[N[E,101]],”.”]

{“2”,”71828182845904523536028747135266
24977572470936999595749669676277240
766303535475945713821785251664274”}
“”<>StringSplit[ToString[N[E,101]],”.”]

“27182818284590452353602874713526624
97757247093699959574966967627724076
6303535475945713821785251664274”
“”<>ToString[E~N~101]~StringSplit~”.”

“27182818284590452353602874713526624
97757247093699959574966967627724076
6303535475945713821785251664274”
“”<>ToString[E~N~101]~StringSplit~”.”

37 byte
Rank

Lang

2

J

1

3

4
5
6
7
8
9

10

Size

GolfScript

17

bc

27

goruby
Ruby
Perl

Bash
Zsh

21
30
32
33
37

Groovy
dc

38

Python

41

fish

40





f(1)=1, f(2)=1, f(x)=f(x-1)+f(x-2)とする.
f(1)からf(46)を出力せよ.
Output
1, 1, 2, 3, 5, 8, 13, 21, . . .
Fibonacci[n]
n番目のFibonacci数を出力する
Array[f,5]
{f[1],f[2],f[3],f[4],f[5]}
Array[Fibonacci,5]
{1,1,2,3,5}
Array[Fibonacci,46]
Array[Fibonacci,46]
Fibonacci~Array~46
Array[Fibonacci,46]
Fibonacci~Array~46
18byte
Rank

Lang

2

GolfScript

1
3

4
5
6
7
8
9

Size

FlogScript

12

PostScript

17

Minus
J

13
18

dc

19

vi

22

A+
Bash
fish

25

goruby
Perl6
Ruby
bc

21

24
Code Golf コワイ
皆さんもお好きな言語で
お試しください

More Related Content

Viewers also liked

Tce bacia do RIO carimã
Tce bacia do RIO carimãTce bacia do RIO carimã
Tce bacia do RIO carimãDafné José
 
August 1980 The Eleventh Annual Report Of The Council On Env
August 1980 The Eleventh Annual Report Of The Council On EnvAugust 1980 The Eleventh Annual Report Of The Council On Env
August 1980 The Eleventh Annual Report Of The Council On EnvObama White House
 
Press release Yan Pei-Ming’s “PaintingThe History” Exhibition 1.9.12 - English
Press release Yan Pei-Ming’s “PaintingThe History” Exhibition 1.9.12 - EnglishPress release Yan Pei-Ming’s “PaintingThe History” Exhibition 1.9.12 - English
Press release Yan Pei-Ming’s “PaintingThe History” Exhibition 1.9.12 - EnglishQma Markdept
 
MOJO-Ad New Business Campaign
MOJO-Ad New Business CampaignMOJO-Ad New Business Campaign
MOJO-Ad New Business CampaignBreckyn Crocker
 
回想支援ツールNFC仏壇
回想支援ツールNFC仏壇回想支援ツールNFC仏壇
回想支援ツールNFC仏壇Yasuhiro Ohsaka
 
~ Cloud First から Cloud Optimized へ ~ .NET on Cloud が描くモダナイゼーション
~ Cloud First から Cloud Optimized へ ~ .NET on Cloud が描くモダナイゼーション~ Cloud First から Cloud Optimized へ ~ .NET on Cloud が描くモダナイゼーション
~ Cloud First から Cloud Optimized へ ~ .NET on Cloud が描くモダナイゼーションAkira Inoue
 
Hmc installation .
Hmc installation . Hmc installation .
Hmc installation . Ksd Che
 
Всероссийский литературный фестиваль "Белое птяно"
Всероссийский литературный фестиваль "Белое птяно"Всероссийский литературный фестиваль "Белое птяно"
Всероссийский литературный фестиваль "Белое птяно"Novosibirsk regional universal research library
 
LibreOffice No coding extention(ClipArt)
LibreOffice No coding extention(ClipArt)LibreOffice No coding extention(ClipArt)
LibreOffice No coding extention(ClipArt)Makoto Takizawa
 
Q3 2014 Investor Factbook
Q3 2014 Investor FactbookQ3 2014 Investor Factbook
Q3 2014 Investor FactbookTMUS_IR
 
Team-Based Product Ownership
Team-Based Product OwnershipTeam-Based Product Ownership
Team-Based Product OwnershipMark Weeks
 
Guião actividade em GSP - Perspectiva de cubo
Guião actividade em GSP - Perspectiva de cuboGuião actividade em GSP - Perspectiva de cubo
Guião actividade em GSP - Perspectiva de cuboAna Paula Jesus
 

Viewers also liked (17)

TGIX sept 2/9/10
TGIX sept 2/9/10TGIX sept 2/9/10
TGIX sept 2/9/10
 
Tce bacia do RIO carimã
Tce bacia do RIO carimãTce bacia do RIO carimã
Tce bacia do RIO carimã
 
August 1980 The Eleventh Annual Report Of The Council On Env
August 1980 The Eleventh Annual Report Of The Council On EnvAugust 1980 The Eleventh Annual Report Of The Council On Env
August 1980 The Eleventh Annual Report Of The Council On Env
 
SERA Email 12.23.02
SERA Email 12.23.02SERA Email 12.23.02
SERA Email 12.23.02
 
FOTOinformator 1/2016
FOTOinformator 1/2016FOTOinformator 1/2016
FOTOinformator 1/2016
 
Press release Yan Pei-Ming’s “PaintingThe History” Exhibition 1.9.12 - English
Press release Yan Pei-Ming’s “PaintingThe History” Exhibition 1.9.12 - EnglishPress release Yan Pei-Ming’s “PaintingThe History” Exhibition 1.9.12 - English
Press release Yan Pei-Ming’s “PaintingThe History” Exhibition 1.9.12 - English
 
MOJO-Ad New Business Campaign
MOJO-Ad New Business CampaignMOJO-Ad New Business Campaign
MOJO-Ad New Business Campaign
 
回想支援ツールNFC仏壇
回想支援ツールNFC仏壇回想支援ツールNFC仏壇
回想支援ツールNFC仏壇
 
~ Cloud First から Cloud Optimized へ ~ .NET on Cloud が描くモダナイゼーション
~ Cloud First から Cloud Optimized へ ~ .NET on Cloud が描くモダナイゼーション~ Cloud First から Cloud Optimized へ ~ .NET on Cloud が描くモダナイゼーション
~ Cloud First から Cloud Optimized へ ~ .NET on Cloud が描くモダナイゼーション
 
4 the rest of_wisconsin
4 the rest of_wisconsin4 the rest of_wisconsin
4 the rest of_wisconsin
 
Investment in Technology for non-profit @ Diffusion Pune 2012
Investment in Technology for non-profit @ Diffusion Pune 2012Investment in Technology for non-profit @ Diffusion Pune 2012
Investment in Technology for non-profit @ Diffusion Pune 2012
 
Hmc installation .
Hmc installation . Hmc installation .
Hmc installation .
 
Всероссийский литературный фестиваль "Белое птяно"
Всероссийский литературный фестиваль "Белое птяно"Всероссийский литературный фестиваль "Белое птяно"
Всероссийский литературный фестиваль "Белое птяно"
 
LibreOffice No coding extention(ClipArt)
LibreOffice No coding extention(ClipArt)LibreOffice No coding extention(ClipArt)
LibreOffice No coding extention(ClipArt)
 
Q3 2014 Investor Factbook
Q3 2014 Investor FactbookQ3 2014 Investor Factbook
Q3 2014 Investor Factbook
 
Team-Based Product Ownership
Team-Based Product OwnershipTeam-Based Product Ownership
Team-Based Product Ownership
 
Guião actividade em GSP - Perspectiva de cubo
Guião actividade em GSP - Perspectiva de cuboGuião actividade em GSP - Perspectiva de cubo
Guião actividade em GSP - Perspectiva de cubo
 

More from aomori ringo

Distributed Systems 第10章 Distributed Object-Based Systems (後編)
Distributed Systems 第10章 Distributed Object-Based Systems (後編)Distributed Systems 第10章 Distributed Object-Based Systems (後編)
Distributed Systems 第10章 Distributed Object-Based Systems (後編)aomori ringo
 
Mathematicaをはじめよう
MathematicaをはじめようMathematicaをはじめよう
Mathematicaをはじめようaomori ringo
 
Distributed Systems 第10章 Distributed Object-Based Systems
Distributed Systems 第10章 Distributed Object-Based SystemsDistributed Systems 第10章 Distributed Object-Based Systems
Distributed Systems 第10章 Distributed Object-Based Systemsaomori ringo
 
Distributed Systems 第1章 Introduction
Distributed Systems 第1章 IntroductionDistributed Systems 第1章 Introduction
Distributed Systems 第1章 Introductionaomori ringo
 
Source monitorと複雑度のはなし
Source monitorと複雑度のはなしSource monitorと複雑度のはなし
Source monitorと複雑度のはなしaomori ringo
 
md5のアルゴリズム
md5のアルゴリズムmd5のアルゴリズム
md5のアルゴリズムaomori ringo
 
すごいHaskell楽しく学ぼう 第6章
すごいHaskell楽しく学ぼう 第6章すごいHaskell楽しく学ぼう 第6章
すごいHaskell楽しく学ぼう 第6章aomori ringo
 

More from aomori ringo (7)

Distributed Systems 第10章 Distributed Object-Based Systems (後編)
Distributed Systems 第10章 Distributed Object-Based Systems (後編)Distributed Systems 第10章 Distributed Object-Based Systems (後編)
Distributed Systems 第10章 Distributed Object-Based Systems (後編)
 
Mathematicaをはじめよう
MathematicaをはじめようMathematicaをはじめよう
Mathematicaをはじめよう
 
Distributed Systems 第10章 Distributed Object-Based Systems
Distributed Systems 第10章 Distributed Object-Based SystemsDistributed Systems 第10章 Distributed Object-Based Systems
Distributed Systems 第10章 Distributed Object-Based Systems
 
Distributed Systems 第1章 Introduction
Distributed Systems 第1章 IntroductionDistributed Systems 第1章 Introduction
Distributed Systems 第1章 Introduction
 
Source monitorと複雑度のはなし
Source monitorと複雑度のはなしSource monitorと複雑度のはなし
Source monitorと複雑度のはなし
 
md5のアルゴリズム
md5のアルゴリズムmd5のアルゴリズム
md5のアルゴリズム
 
すごいHaskell楽しく学ぼう 第6章
すごいHaskell楽しく学ぼう 第6章すごいHaskell楽しく学ぼう 第6章
すごいHaskell楽しく学ぼう 第6章
 

Mathematicaでgolf