Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
FizzBuzz code golf by ruby
Search
gurrium
February 22, 2018
Programming
350
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
FizzBuzz code golf by ruby
FizzBuzz code golf for hiroshima.rb #062
gurrium
February 22, 2018
More Decks by gurrium
See All by gurrium
大量のiOSシミュレータにアプリをインストールする
gurrium
0
170
作りながら紹介するマンガビューワの機能
gurrium
0
4k
プライベートでも毎日コードを書く暮らし / Hatena Engineer Seminar #18
gurrium
0
1.7k
Other Decks in Programming
See All in Programming
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
840
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
2
580
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.4k
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
370
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
210
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
190
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.2k
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
4
2.3k
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
130
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
180
初めての模倣学習とVLA
natsutan
0
350
プロポーザルを書いてもらう
pvcresin
0
590
Featured
See All Featured
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
220
The agentic SEO stack - context over prompts
schlessera
0
880
Mind Mapping
helmedeiros
PRO
1
340
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
180
GraphQLとの向き合い方2022年版
quramy
50
15k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Navigating Weather and Climate Data
rabernat
0
500
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
Speed Design
sergeychernyshev
33
2k
Exploring anti-patterns in Rails
aemeredith
3
480
Become a Pro
speakerdeck
PRO
31
6.2k
Transcript
FizzBuzz code golf
first code
(1..100).each do |i| puts "#{i} " if i % 3
== 0 if i % 5 == 0 puts 'fizzbuzz' next else puts 'fizz' next end end if i % 5 == 0 puts 'buzz' next end end count 207
if…else…end -> ? :
(1..100).each do |i| print "#{i} " if i % 3
== 0 puts i % 5 == 0 ? 'fizzbuzz' : 'fizz' next end puts i % 5 == 0 ? 'buzz' : nil end count 148
nest conditional operator
(1..100).each do |i| print "#{i} " puts i % 3
== 0 ? i % 5 == 0 ? 'fizzbuzz' : 'fizz' : i % 5 == 0 ? 'buzz' : nil end count 122
do…end -> {…}
(1..100).each { |i| print "#{i} " puts i % 3
== 0 ? i % 5 == 0 ? 'fizzbuzz' : 'fizz' : i % 5 == 0 ? 'buzz' : nil } count 119
join lines
(1..100).each { |i| print "#{i} ";puts i % 3 ==
0 ? i % 5 == 0 ? 'fizzbuzz' : 'fizz' : i % 5 == 0 ? 'buzz' : nil } count 115
nil -> ''
(1..100).each { |i| print "#{i} “; puts i % 3
== 0 ? i % 5 == 0 ? 'fizzbuzz' : 'fizz' : i % 5 == 0 ? 'buzz' : '' } count 114
into string
(1..100).each { |i| puts "#{i} #{'fizz' if i % 3
== 0}#{'buzz' if i % 5 == 0}" } count 81
(1..100).each -> Integer#upto
1.upto(100) { |i| puts "#{i} #{'fizz' if i % 3
== 0}#{'buzz' if i % 5 == 0}" } count 79
i == 0 -> i < 1
1.upto(100) { |i| puts "#{i} #{'fizz' if i % 3
< 1}#{'buzz' if i % 5 < 1}" } count 77
delete whitespace
1.upto(100){|i|puts"#{i} #{'fizz'if i%3<1}#{'buzz'if i%5<1}"} count 62