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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
gurrium
February 22, 2018
Programming
340
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
130
作りながら紹介するマンガビューワの機能
gurrium
0
3.9k
プライベートでも毎日コードを書く暮らし / Hatena Engineer Seminar #18
gurrium
0
1.7k
Other Decks in Programming
See All in Programming
dRuby over BLE
makicamel
2
380
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
410
さぁV100、メモリをお食べ・・・
nilpe
0
150
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
400
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
140
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
260
ふつうのFeature Flag実践入門
irof
8
4.1k
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
850
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
170
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
13k
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
190
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.3k
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
720
Un-Boring Meetings
codingconduct
0
320
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
540
Everyday Curiosity
cassininazir
0
230
Optimising Largest Contentful Paint
csswizardry
37
3.7k
What's in a price? How to price your products and services
michaelherold
247
13k
Odyssey Design
rkendrick25
PRO
2
700
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
Color Theory Basics | Prateek | Gurzu
gurzu
0
370
WENDY [Excerpt]
tessaabrams
11
38k
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