Jump to content

Recommended Posts

The lottery is only 6 numbers, any idea on the combination of those numbers.

 

It depends which country. Lotteries where I'm from are 6 number sets, with the potential of each one having up to 2 numbers in each set.

 

And those numbers are supposed to be randomly generated. (Conspiracy people such as myself believe otherwise...)

watch?v=ewfFcmdSdck

 

The codes are case sensitive and appear to be 11 characters that can be a-zA-Z0-9_-.

 

 

So, 26*2 + 10 + 2 = 64

 

64^11 options:

 

73786976294838206464

 

 

That's how they do it :).

 

He isn't saying if its possible to have 180 million different combination within 12 or 11 characters. He is saying how do they generate the id. Whats the formula.

Ahhhh....  I read the generate part then entirely forgot about it when I read the 180 million part :).

 

But regarding to what he wants, what do you think it could be? I find it hard to be the name of the youtube video. Possibly they are just number ids, except being just numbers, they are turned into letters/numbers.

 

Is it possible for youtube videos ID to change after its been uploaded?

 

Also, dreamwest, could you get me two video ids that were uploaded right after another?

probably some type of hash i guess...

 

changing video ID... probably not, although they could assign different names to those ID's probably

 

"could you get me two video ids that were uploaded right after another?"

 

being that there are thousands of people probably uploading videos at a time... thats probably not possible

probably some type of hash i guess...

 

There is one problem with hashes though. Uh, well I forgot the term, but its when there are two somethings with the same hash. I suppose the odds wouldn't be great to any degree. As corb calculated it to 73786976294838206464 different hashes which would bring the chances to near 0. So I suppose they hashed it.

 

being that there are thousands of people probably uploading videos at a time... thats probably not possible

 

Eh, thats true. >:(

probably some type of hash i guess...

 

There is one problem with hashes though. Uh, well I forgot the term, but its when there are two somethings with the same hash. I suppose the odds wouldn't be great to any degree. As corb calculated it to 73786976294838206464 different hashes which would bring the chances to near 0. So I suppose they hashed it.

 

 

Hash collision?

 

 

When generating unique identities, avoiding collisions is fairly easy:

 

do {

    code = generate code;

}

while(code exists);

 

 

(There are of course locking problems since theoretically in the time that code was said to not exist and actually inserted the same code could have been generated.)

 

 

As far as collisions go, imagine how unlikely a collision would be on this:

 

md5(video name . microtime(true));

 

 

(Of course they're not using md5 since the format doesn't match it, but you get the point.)

I cooked up this:

 

function video_gen($min=6,$max=6,$id){ /*has a default min value of 6 and maximum value of 6*/
$vid=""; // to store generated password
for($i=0;$i<rand($min,$max);$i++){
  $num=rand(48,122);
  if(($num >= 97 && $num <= 122))     $vid.=chr($num);
  else if(($num >= 65 && $num <= 90))  $vid.=chr($num);
  else if(($num >=48 && $num <= 57))    $vid.=chr($num);
  else    $i--;
}
return $vid;
}

$vid = video_gen(6,6, 87458 );

$result = mysql_query("SELECT id FROM videos WHERE vid='{$vid}' ");
if($result){

$video_num = mysql_num_rows( $result );

if ($video_num == 0) { 
mysql_query("insert into videos set vid ='{$vid}' ");
}
}

 

Outputs somthing like "WcAEwG"

 

Thus resulting in unique ids for every video......HOWEVER i think it would be a problem checking 180million + rows.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.