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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
gurrium
February 22, 2018
Programming
330
1
Share
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
120
作りながら紹介するマンガビューワの機能
gurrium
0
3.8k
プライベートでも毎日コードを書く暮らし / Hatena Engineer Seminar #18
gurrium
0
1.7k
Other Decks in Programming
See All in Programming
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
130
AI時代になぜ書くのか
mutsumix
0
380
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
160
ハーネスエンジニアリングとは?
kinopeee
13
6.9k
空間オーディオの活用
objectiveaudio
0
150
Agentic Elixir
whatyouhide
0
450
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
JCON - Create Agentic AI Apps, The Easy Way!
kdubois
1
110
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
410
AI時代だからこそ「Bloc」を採用する価値があるのかもしれない
takuroabe
0
160
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
180
サプライチェーン攻撃対策「層を重ねて落ちない壁」を10日間で組み上げた話 #TechLeadConf2026
kashewnuts
1
250
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
The Spectacular Lies of Maps
axbom
PRO
1
740
How to make the Groovebox
asonas
2
2.2k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
370
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
140
How STYLIGHT went responsive
nonsquared
100
6.1k
Thoughts on Productivity
jonyablonski
76
5.1k
Darren the Foodie - Storyboard
khoart
PRO
3
3.3k
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