ルール(2014/09/24)
- Rubyのversionは2.0.0と2.1.0に対応しています。
- 最初のオブジェクトは何でもOK
- 現在のオブジェクトで使用できるメソッドをつなげる
- 既出のメソッドの使用禁止( レシーバのクラスが異なる場合も同一視する )
- 既存のクラス、メソッドのオーバーライド禁止
- 実行時間が1秒を超える処理の禁止
- 繋げられるメソッドが無くなるまで続けます
- require, autoloadなどの追加のファイルを読み込むメソッドは禁止
require 'benchmark' | |
Benchmark.bm do |x| | |
cnt = 50000000 | |
fixnum = 1 | |
bignum = 1 << 64 | |
# Fixnum#succ | |
x.report(:Fixnum_succ) do | |
a = fixnum |
require 'benchmark' | |
Benchmark.bm do |x| | |
cnt = 100000000 | |
fixnum = 1 | |
bignum = 1 << 64 | |
x.report("+=1 Fixnum") do | |
a = fixnum |
require 'prime' | |
limit = 500 | |
prime_list = Prime::EratosthenesGenerator.new | |
# prime_listはnextメソッドを呼び出すたびに次の素数を取得できる。 | |
p1 = prime_list.next | |
p2 = prime_list.next | |
prime_queue = [] |
require 'benchmark' | |
Benchmark.bm do |x| | |
obj = "Hello" | |
cnt = 10_000_000 | |
x.report do | |
cnt.times do | |
!!obj | |
end |
a=/a/ | |
b=/b/ | |
x=[a,b].sample | |
case x.to_s | |
when a | |
puts "a" | |
when b | |
puts "b" | |
else | |
raise "shouldn't happen" |
def singleton(klass) | |
class << klass; self end | |
end | |
klass = Numeric | |
ObjectSpace.each_object(singleton(klass)) do |subclass| | |
if klass != subclass | |
p subclass | |
p subclass.methods | |
#object_list(subclass) unless @tree.has_key?(subclass) |
ルール(2014/09/24)
18446744073709551616.times.map.collect.find{ true }.gcd(1).succ.chr.encoding.==(Encoding::UTF_8).to_s.slice("s").force_encoding(Encoding::CP932).next.next!.gsub(/u/){ BasicObject }.chars.take(0).reverse.reverse!.<<("Hello Ruby").pack('m').upcase.downcase.upcase!.unpack('m').shift.split('').first.scan(/./).unshift.take_while{ false }.to_a.+([]).join(' ').each_line.each.dup.max.to_i.pred.class.extend(Module.new).is_a?(Fixnum).===(false).inspect.concat(" false").=~(/[a-z]/).&(1).methods.flatten.pop.intern.to_proc.arity.|(1).divmod(0.2).min.-(-5).zero?.singleton_methods.sort.sort_by{ rand }.push("Hello Ruby").[](-1).downcase!.sub(/r/){ binding }.swapcase.%([]).to_str.delete('A-Z').to_f.*(1).fdiv(1)./(0.0).-@.abs.**(0).round.floor.ceil.freeze.odd?.object_id.to_r.eql?(0).method(:class).call.superclass.new.singleton_class.__id__.ord.even?.instance_eval{ (1..10) }.begin.div(1).^(5).!.nil?.send(:exit) |
[user] | |
name = siman-man | |
email = k128585@ie.u-ryukyu.ac.jp | |
[color] | |
ui = true |
require 'open-uri' | |
require 'nokogiri' | |
require 'yaml' | |
require 'pp' | |
type = ARGV[0] || "String" | |
url = "http://docs.ruby-lang.org/ja/2.1.0/class/#{type}.html" | |
charset = nil | |
html = open(url) do |f| |