SlideShare a Scribd company logo
@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

PPTX
201308 回路部ワークショップ(ランプ)資料
PPTX
La Recreación
PDF
RCEC Email 5.19.03 (c)
PDF
OPIC Released Documents 21-30
PDF
CAR Email 3.25.02
PDF
Handwritten Notes (f)
PDF
Summer camp for kids in Kolkata
PDF
Bombardier reference
201308 回路部ワークショップ(ランプ)資料
La Recreación
RCEC Email 5.19.03 (c)
OPIC Released Documents 21-30
CAR Email 3.25.02
Handwritten Notes (f)
Summer camp for kids in Kolkata
Bombardier reference

Viewers also liked (17)

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

More from aomori ringo (7)

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

Mathematicaでgolf