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
1
290
FizzBuzz code golf by ruby
FizzBuzz code golf for hiroshima.rb #062
gurrium
February 22, 2018
Tweet
Share
More Decks by gurrium
See All by gurrium
作りながら紹介するマンガビューワの機能
gurrium
0
3.6k
プライベートでも毎日コードを書く暮らし / Hatena Engineer Seminar #18
gurrium
0
1.6k
Other Decks in Programming
See All in Programming
Jetpack XR SDKから紐解くAndroid XR開発と技術選定のヒント / about-androidxr-and-jetpack-xr-sdk
drumath2237
1
200
「コードは上から下へ読むのが一番」と思った時に、思い出してほしい話
panda728
PRO
39
26k
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
160
SwiftUIで本格音ゲー実装してみた
hypebeans
0
510
クラウドに依存しないS3を使った開発術
simesaba80
0
180
これならできる!個人開発のすゝめ
tinykitten
PRO
0
130
複雑なUI設計への銀の弾丸 「オブジェクト指向UIデザイン」
teamlab
PRO
2
110
認証・認可の基本を学ぼう後編
kouyuume
0
250
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
220
GoLab2025 Recap
kuro_kurorrr
0
780
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
1.9k
Canon EOS R50 V と R5 Mark II 購入でみえてきた最近のデジイチ VR180 事情、そして VR180 静止画に活路を見出すまで
karad
0
140
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
260
The World Runs on Bad Software
bkeepers
PRO
72
12k
Designing Experiences People Love
moore
143
24k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
0
22
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
590
Git: the NoSQL Database
bkeepers
PRO
432
66k
Amusing Abliteration
ianozsvald
0
72
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
130
SEO for Brand Visibility & Recognition
aleyda
0
4.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.2k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
79
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
0
290
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