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
320
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
100
作りながら紹介するマンガビューワの機能
gurrium
0
3.8k
プライベートでも毎日コードを書く暮らし / Hatena Engineer Seminar #18
gurrium
0
1.7k
Other Decks in Programming
See All in Programming
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
280
アーキテクチャモダナイゼーションとは何か
nwiizo
19
5.3k
JOAI2026 1st solution - heron0519 -
heron0519
0
140
ハーネスエンジニアリングとは?
kinopeee
10
5.3k
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
140
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
220
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
3
510
Vibe NLP for Applied NLP
inesmontani
PRO
0
440
おれのAgentic Coding 2026/03
tsukasagr
1
150
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
140
Kingdom of the Machine
yui_knk
2
330
Featured
See All Featured
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
180
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
160
Designing Experiences People Love
moore
143
24k
Faster Mobile Websites
deanohume
310
31k
HDC tutorial
michielstock
2
630
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
180
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Speed Design
sergeychernyshev
33
1.6k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
370
How GitHub (no longer) Works
holman
316
150k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.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