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
1
320
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
大量のiOSシミュレータにアプリをインストールする
gurrium
0
80
作りながら紹介するマンガビューワの機能
gurrium
0
3.7k
プライベートでも毎日コードを書く暮らし / Hatena Engineer Seminar #18
gurrium
0
1.7k
Other Decks in Programming
See All in Programming
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
S3ストレージクラスの「見える」「ある」「使える」は全部違う ─ 体験から見た、仕様の深淵を覗く
ya_ma23
0
960
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
610
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
590
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
1.1k
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
360
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
300
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
7
3.1k
20260313 - Grafana & Friends Taipei #1 - Kubernetes v1.36 的開發雜記:那些困在 Alpha 加護病房太久的 Metrics
tico88612
0
230
ロボットのための工場に灯りは要らない
watany
12
3.2k
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
500
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
780
Featured
See All Featured
Building the Perfect Custom Keyboard
takai
2
720
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
210
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
200
The agentic SEO stack - context over prompts
schlessera
0
710
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.2k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
300
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
300
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
400
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Unsuck your backbone
ammeep
672
58k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
210
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
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