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
300
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
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
180
愛される翻訳の秘訣
kishikawakatsumi
3
370
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
160
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
340
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
2.1k
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
0
460
Denoのセキュリティに関する仕組みの紹介 (toranoana.deno #23)
uki00a
0
220
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
620
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
130
Implementation Patterns
denyspoltorak
0
150
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
210
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
1.4k
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.7k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
270
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
78
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
140
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
4 Signs Your Business is Dying
shpigford
187
22k
Side Projects
sachag
455
43k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
880
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
360
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
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