Brute Force Ruby I

Is there a number (k) that multiplied by itself yields a result (t) that contains all the digits 0-9 and nothing else? 

def contains0to9(tarr)
  tarr.index("0") and tarr.index("1") and tarr.index("2") and tarr.index("3") and tarr.index("4") and tarr.index("5") and tarr.index("5") and tarr.index("6") and tarr.index("7") and tarr.index("8") and tarr.index("9")                 

for k in 1...100000
  t = k * k
  tarr = t.to_s.split("")
  if tarr.length == 10 and contains0to9(tarr)
    print k, " * ", k, " = ", tarr, "n"

Leave a Reply

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

You are commenting using your 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