|
Prev: Why can't I return "Threads.list" Array in DRb?
Next: rjb heap size OR call ruby methods from java
From: Eric I. on 29 Jun 2008 12:58 On Jun 29, 12:14 pm, Tj Superfly <nonstickg...(a)verizon.net> wrote: > Okay, why not! Here's what I'm trying to do. > > The website has urls for all their pet images, each having one of the > random combination's inside of it. As such: > > http://pets.neopets.com/cp/rbm2vqzv/1/2.png > > So, basically I want to create some sort of list / program that searches > though them and tells me if they exist or not, so I can see new pets > when they are eventually uploaded. > > P.S. That's where I got random generation, because each url is random, > but I guess ultimately my list is 'complete' so, sorry about that. > > Best Regards, > > TJ > -- > Posted viahttp://www.ruby-forum.com/. First realize that if you're looking for an 8 digit sequence, where each digit is one of 36 characters, then there are 36**8, or 2,821,109,907,456 combinations. Are you really going to hit the web site with nearly 3 trillion requests? And if you try, can we place bets on which will happen first: 1) You get contacted by the web site's lawyers. 2) You get contacted by a law enforcement agency. 3) You get cut off by your ISP. That said, the following code will generate all 46,656 possibilities of size 3 (and by changing one variable you can get combinations of a different size): char_count = 3 base = 36 0.upto(base**char_count - 1) do |value| puts value.to_s(base).rjust(char_count, '0') end Eric ==== LearnRuby.com offers Rails & Ruby HANDS-ON public & ON-SITE workshops. Please visit http://LearnRuby.com for all the details.
|
Pages: 1 Prev: Why can't I return "Threads.list" Array in DRb? Next: rjb heap size OR call ruby methods from java |