2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RubyでFizzBuzzのコードゴルフ(58bytes)

Posted at

以下のページを参考に作成しました。

東京Ruby会議10で行われたコードゴルフの解答例を紹介します

fizzbuzz_58bytes.rb
1.upto(100){|x|p"#{[:Fizz][x%3]}#{[:Buzz][x%5]}"[/.+/]||x}

メモ

  • 1..100の要素生成・取り出しは 1.upto(100){} が最短っぽい
  • puts を p に変えることで3字節約。ただしエスケープシーケンスを用いるコードが利用できなくなる欠点がある
  • こちらのサイトによると50bytesが可能らしいが、ここから8bytesどう削るのか皆目検討が付かない
2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?