RubyでBasicObjectからhello, world!を出力する

数字が作れればどうとでもなる

bo = BasicObject.new
zero = bo.__id__ ^ bo.__id__
one  = zero.succ
space    = (one << one << one << one << one << one).chr
exclam   = ((one << one << one << one << one << one) ^ one).chr
dquote   = ((one << one << one << one << one << one) ^ (one << one)).chr
conma    = ((one << one << one << one << one << one) ^ (one << one << one << one) ^ (one << one << one)).chr
minus    = ((one << one << one << one << one << one) ^ (one << one << one << one) ^ (one << one << one) ^ one).chr
a = (one.to_s + zero.to_s + zero.to_s).to_i - one - one - one
b = a.succ
c = b.succ
d = c.succ
e = d.succ
f = e.succ
g = f.succ
h = g.succ
i = h.succ
j = i.succ
k = j.succ
l = k.succ
m = l.succ
n = m.succ
o = n.succ
p = o.succ
q = p.succ
r = q.succ
s = r.succ
t = s.succ
u = t.succ
v = u.succ
w = v.succ
x = w.succ
y = x.succ
z = y.succ
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z = a.chr, b.chr, c.chr, d.chr, e.chr, f.chr, g.chr, h.chr, i.chr, j.chr, k.chr, l.chr, m.chr, n.chr, o.chr, p.chr, q.chr, r.chr, s.chr, t.chr, u.chr, v.chr, w.chr, x.chr, y.chr, z.chr

zero.instance_eval(p + u + t + s + space + dquote + h + e + l + l + o + conma + space + w + o + r + l + d + exclam + dquote)
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.