Code surprise for today

A little code surprise today for all my beloved readers 🙂
You find out what it does 😉

Hint: executing it might help and is harmless

Proc.new {
def d(s) $stdout << s << "\r"; sleep 0.05 end
m, r, o = 37, (65..90), 0
s = ' '*m
z = [ [ lambda{|x| x*(x*(x*(x - 306) + 34953) - 1766360) + 33321600}, 1, 0, [2, 3], 4 ],
  [ lambda{|x| x*(x*(x - 234) + 18171) - 468234}, 1, 0, 2 ],
  [ lambda{|x| x*(x*(x*(x - 305) + 34697) - 1744867) + 32731530}, 2, 1, 3, 0 ]
].each do | f, *l |
  n = 0
  r.each_with_index do |c, i|
    if (f.call(c) == 0)
      [l[n]].to_a.flatten.each do |p|
        t, k = nil, 0
        i.step(p,(p-i)/(p-i).abs) do |j|
          s[o+k] = t if !t.nil?
          t, k = s[o+j], j
          s[o+j] = c.chr
          d s
        end
      end
      n += 1
    else
      s[o+i] = c.chr.downcase if s[o+i].ord < 65
    end
    d s
  end
  o += l.flatten.size + 1
  s[o-1..m-1] = ' '*(m-o+1)
  d s
end
$stdout << "\n" << m*s.size+(o+o+z[0][3][1]*z[0][4])*z.flatten.size+(z[2][2].to_s+z[0][4].to_s).to_i << "!\n"
}.call

Enjoy, with all my best wishes for this year!

Muriel

About Muriel Salvan

I am a freelance project manager and polyglot developer, expert in Ruby and Rails. I created X-Aeon Solutions and rivierarb Ruby meetups. I also give trainings and conferences on technical topics. My core development principles: Plugins-oriented architectures, simple components, Open Source power, clever automation, constant technology watch, quality and optimized code. My experience includes big and small companies. I embrace agile methodologies and test driven development, without giving up on planning and risks containment methods as well. I love Open Source and became a big advocate.
My life, Ruby , , , , ,

1 comment


Leave a Reply

Your email address will not be published. Required fields are marked *