XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).
Moderator: General Moderators
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Fri Jun 22, 2007 11:39 pm
I wanted to find the number of permutations with repitition using the numbers a-z, letters, 0-9, and underscores (which gives a total of 37 characters) for a screenname that can be 1-25 characters long. So I came up with this coding:
Code: Select all
C:\Users\HP_Administrator>php -r "$n = 37; $s = array(); for($r=1;$r<26;$r++){ $
s[] = pow($n, $r); } $s = array_sum($s); echo $s;"
1.6479435273673E+039
What is 1.6479435273673E+039 if you evaluate the E+039 =[
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Fri Jun 22, 2007 11:45 pm
37 to the power of 25 = 1,603,404,513,114,153,724,313,506,335,083,015,711,557
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Fri Jun 22, 2007 11:48 pm
But that's if you only used screennames that were 25 characters in length. Screennames can be between 1 and 25 characters in length, which is why i stuck it in a for() loop. Correct?
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Fri Jun 22, 2007 11:53 pm
I think I just move the decimal point to the right 39 places.
and get, 1,647,943,527,367,300,000,000,000,000,000,000,000,000
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Fri Jun 22, 2007 11:54 pm
Yeah, so assume the number is > than that.
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Fri Jun 22, 2007 11:58 pm
Cool. There was just a discussion about this on another forum, and I had to be the smarty and figure out the possible number of combinations.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sat Jun 23, 2007 12:22 am
It's safe to assume there are more combinations than grains of sand on the earth.
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Sat Jun 23, 2007 3:07 am
I'm going to move this thread to "miscellaneous". This section is not for code discussion (although I must admit. I forget that often as well
)
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Sat Jun 23, 2007 3:37 am
I think it is 38 to the power of 25. 37 + blank.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sat Jun 23, 2007 10:22 am
ole wrote: I think it is 38 to the power of 25. 37 + blank.
That would allow for characters after the first blank character and hence would be > than the actual combinations.
Ollie Saunders
DevNet Master
Posts: 3179 Joined: Tue May 24, 2005 6:01 pm
Location: UK
Post
by Ollie Saunders » Sat Jun 23, 2007 12:59 pm
Yeah you're right. Only just woke up when I said that.
alex.barylski
DevNet Evangelist
Posts: 6267 Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg
Post
by alex.barylski » Sat Jun 23, 2007 1:32 pm
Sounds like somebody is trying to develop a brute force algorithm
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Sat Jun 23, 2007 4:01 pm
Compute this:
Σpow(37, i) - where i runs from 1 to 25
Which is a finite geometric series, therfore: # of possible names = (a1*(1 - q^n)) / (1 - q) = (37*(1 - 37^25)) / (1 - 37) = (37 - 37^26) / -36
Last edited by
Oren on Sat Jun 23, 2007 5:31 pm, edited 1 time in total.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sat Jun 23, 2007 5:04 pm
I'll leave that to you Oren
Oren
DevNet Resident
Posts: 1640 Joined: Fri Apr 07, 2006 5:13 am
Location: Israel
Post
by Oren » Sat Jun 23, 2007 5:06 pm
Oh man... it's after 1AM now and I made so many mistakes... I had already edited the previous post so many times before. I just hope I didn't make a mistake this time, as I said... it's after 1AM