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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
380
Programming with a DJ Controller — not vibe coding
m_seki
3
820
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
200
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
680
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
7
2.5k
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
160
2026-04-15 Spring IO - I Can See Clearly Now
jonatan_ivanov
1
190
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
150
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.6k
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
500
開発とはなにか、Essenceカーネルで見えるもの
ukin0k0
0
130
Featured
See All Featured
Building Adaptive Systems
keathley
44
3k
Color Theory Basics | Prateek | Gurzu
gurzu
0
310
What's in a price? How to price your products and services
michaelherold
247
13k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
210
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Agile that works and the tools we love
rasmusluckow
331
21k
Building AI with AI
inesmontani
PRO
1
980
Un-Boring Meetings
codingconduct
0
290
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Docker and Python
trallard
47
3.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Claude Code のすすめ
schroneko
67
220k
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