LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 07-05-2004, 08:33 AM   #1
gumpo_mun
LQ Newbie
 
Registered: Dec 2003
Location: London
Distribution: Mandrake 9.2
Posts: 12

Rep: Reputation: 0
Why u need to be careful when using /dict/words...


A big warning:
**always follow Murphy's laws to their full extent!**

I was working on a php application which uses log-ins.
The client wanted some friendly way to have users remember their password, maybe something with a combination of real words, -fine- said I.
As a prototype I prepared a simple script which used the /dict/words file, nothing over the top, the script would output a combination of two hyphenated word, so that the guy could play with it and tell me if he liked it.
Would you ever believe that the first two words the script produced where sh**-head?
Need I to say that the guy was NOT pleased at all?
Anybody fancies calculating the chances of that happening?
 
Old 07-05-2004, 09:39 AM   #2
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Well, wc says mine contains 45427 words. So, any two-word combination should be 1-in-(45427-squared), or 1-in-2-billion-ish. It's the same odds for "soda-pop" as it is for "dog-sh**".

According to the California Lottery page, your chance of winning the big pay-off are 1-in-41-million-ish. << http://www.calottery.com/games/super...lus/howtoplay/ >>
 
Old 07-06-2004, 01:37 AM   #3
nerdbebo
LQ Newbie
 
Registered: Jun 2004
Location: Arlington, Texas
Posts: 17

Rep: Reputation: 0
Go buy a lottery ticket. Great story, I just told everyone here at the office.
 
Old 07-06-2004, 03:00 AM   #4
gumpo_mun
LQ Newbie
 
Registered: Dec 2003
Location: London
Distribution: Mandrake 9.2
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by nerdbebo
Go buy a lottery ticket. Great story, I just told everyone here at the office.
Got my Lotto ticket
 
Old 07-09-2004, 06:24 AM   #5
gumpo_mun
LQ Newbie
 
Registered: Dec 2003
Location: London
Distribution: Mandrake 9.2
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by ranger_nemo
Well, wc says mine contains 45427 words. So, any two-word combination should be 1-in-(45427-squared), or 1-in-2-billion-ish.
Apologies for this, my math is a bit rusty, you used something like:
Dn,k=n.(n-1)....(n-k+1) where k=2 and n=45427 to calculate it? Dunno what is called in english.
 
Old 07-09-2004, 08:47 AM   #6
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Quote:
...you used something like: Dn,k=n.(n-1)....(n-k+1) where k=2 and n=45427 to calculate it?
No, I just used a simple squaring... If there were only five words [ A,B,C,D,E ], then all possible combinations would be...

A-A ,A-B,A-C,A-D,A-E
B-A,B-B ,B-C,B-D,B-E
C-A,C-B,C-C ,C-D,C-E
D-A,D-B,D-C,D-D ,D-E
E-A,E-B,E-C,E-D,E-E

If you are picking completely at random, it is possible to pick the same word twice, and thereby the number of combos is N-squared. I didn't bother to put it on the calculator, but it should be about 2.064-billion-ish.

If you are removing the first word picked, then you would need to subtract one from N for the second word, and thereby the number of combos would be N(N-1), or NN-N, or 2.064-billion-ish minus 45427, which is still 2.064-billion-ish. Remove the red combos above.
 
Old 07-09-2004, 05:31 PM   #7
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
LOL, i cant seem to stop laughing at this,... just you luck eh?

/me is reminded of a Dilbert comic strip
 
Old 07-12-2004, 03:25 AM   #8
gumpo_mun
LQ Newbie
 
Registered: Dec 2003
Location: London
Distribution: Mandrake 9.2
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by ranger_nemo
No, I just used a simple squaring... If there were only five words [ A,B,C,D,E ], then all possible combinations would be...

A-A ,A-B,A-C,A-D,A-E
B-A,B-B ,B-C,B-D,B-E
C-A,C-B,C-C ,C-D,C-E
D-A,D-B,D-C,D-D ,D-E
E-A,E-B,E-C,E-D,E-E

If you are picking completely at random, it is possible to pick the same word twice, and thereby the number of combos is N-squared. I didn't bother to put it on the calculator, but it should be about 2.064-billion-ish.

If you are removing the first word picked, then you would need to subtract one from N for the second word, and thereby the number of combos would be N(N-1), or NN-N, or 2.064-billion-ish minus 45427, which is still 2.064-billion-ish. Remove the red combos above.
Yes, the combination did not include repetition, the idea was to have unique values, althought the positioning of the words would have been random, that way A-B != B-A although A and B are the same words.
The D(n,k) would be D(n,k)=45427*(45427-1) I think, which would be fairly close to the square of the number.

Cheers!
 
Old 07-12-2004, 03:28 AM   #9
gumpo_mun
LQ Newbie
 
Registered: Dec 2003
Location: London
Distribution: Mandrake 9.2
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by SciYro
LOL, i cant seem to stop laughing at this,... just you luck eh?

/me is reminded of a Dilbert comic strip
I have removed all the "naughty"words from the word list so that it should give less "entertaining" results. Was thinking of setting up a cron to run the program and save the result to db, and then check to see what comes out of it. You know the thing about monkeys, typewriters and eternity
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Be Careful W/ That Rm Command, Kids! iatemyfingers Linux - Newbie 3 06-24-2005 03:12 PM
Search and Replace: Asian Words to English Words ieeestd802 Linux - Software 0 10-27-2004 07:48 PM
ispell on slackware? /usr/dict/words : no such device doublefailure Slackware 4 03-12-2003 02:19 PM
Careful! Newbie question! :) Bernhard Programming 7 01-31-2002 05:29 AM
when they say be careful doin something its a good idea to be careful lol eagle0669 Linux - Newbie 3 08-10-2001 08:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 11:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration