Brute Force Ruby II

Talking about “More is Less”, my dear friend and collegue Tobias Fors managed to distill the code a bit:

for k in 1...100000
  t = (k * k).to_s
  if t.length == 10 and t.split(//).sort.join == "0123456789"
    print k, " * ", k, " = ", t, "n"
  end
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s