Sierpinski's shoes

Posted by Jonas Elfström Wed, 14 Nov 2007 22:50:00 GMT

There were no cross-platform windowing toolkits for Ruby so _why made one and he calls it Shoes. Not even close to 1.0, it's already yummy in a chunky kind of way and since it came from _why I simply had to try it out. Something simple.

Shoes.app :width => 1024, :height => 768 do  
  corners = [ {:x => 256, :y => 10}, {:x => 12, :y => 378}, {:x => 506, :y => 378} ]
  xpos,ypos,c = 256,10,0
  srand
  2111.times do
      c=rand(3)
      xpos += (corners[c][:x]-xpos)>>1
      ypos += (corners[c][:y]-ypos)>>1
      star xpos, ypos, 5, 10
  end
end

The result.

Posted in ,  | no comments

Huge number factored into primes

Posted by Jonas Elfström Wed, 23 May 2007 05:12:00 GMT

Recently 2^1039-1 were factored. Is this the end of 1024 RSA encryption? Lenstra, one of the researchers, addresses this question: "Last time, it took nine years for us to generalize from a special to a non-special hard-to factor number (155 digits). I won't make predictions, but let's just say it might be a good idea to stay tuned."

2^1039-1 is a special number that the RSA algorithm would never use so 1024 RSA might still be secure for the time being but if you want to be future safe 2048 bits or more would be the way to go.

Posted in ,  | no comments

Find primes in regexp

Posted by Jonas Elfström Fri, 30 Mar 2007 05:33:00 GMT

In an earlier post the example code did find prime numbers. Recently I stumbled over a really cool regexp hack that also deals with primes. This is how you execute that regexp in Ruby:

puts 'Prime' unless ('1' * 43) =~ /^1$|^(11+?)\1+$/

Change 43 to whatever you like and you will get Prime as output if it's a prime number. EDIT: As you can see in the comments Neil Kandalonkar explained how the regexp by Abigail works.

Posted in ,  | 2 comments