?

Log in

No account? Create an account
Lost Combo - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Lost Combo [Jul. 27th, 2000|01:44 pm]
Brad Fitzpatrick
[Tags|, ]

My mom's been losing keys and passwords left and right lately. The last one she forgot was the combination for our key box outside. It's a 4 digit (0-9) code, where order doesn't matter---- 4 keys press in, then you pull down a switch to test it. My mom is offering Cole $10 if he can figure out the code, thinking it next to impossible. Remembering my statistics, I realized it wasn't really that hard at all: there are only 210 possibilities. Nine lines of Perl later, I emailed Cole a list of possible combos and he's out there now in a lawn chair trying them all. I wanted $5 for my effort, but he's a stingy bastard.

foreach $a (0..9) {
  foreach $b (grep { $_ != $a } (0..9)) {
    foreach $c (grep { $_ != $a && $_ != $b } (0..9)) {
      foreach $d (grep { $_ != $a && $_ != $b && $_ != $c } (0..9)) {
        my $sorted = join(", ", sort { $a <=> $b } ($a,  $b, $c, $d));
        unless ($used{$sorted}++) {
        print "$sorted\n";
} } } } }
Well, that's 8 if you don't count the #!/usr/bin/perl.

Update! My brother found it! He just came and gave me a dollar. Woohoo! Time to quit my day job! (wait ... I don't have a day job...)

LinkReply

Comments:
[User Picture]From: nick
2000-07-27 01:59 pm (UTC)

hmmm... 210 eh?

when you guys going on vacation again... not that getting keys really matters, as long as you are the last one to leave the garage door will be wide open. :-p
(Reply) (Thread)
[User Picture]From: sandy
2000-07-27 03:25 pm (UTC)

Re: hmmm... 210 eh?

He tells all for the whole world, doesn't he. Well, Nick you are correct that they will leave not only the garage door open, but all of the windows open or unlocked. If you did try to get in you would then have to get by the security system. The only problem is, if we turn it on, Brad does not remember the code to get in. We have only lived here 2+ years. We are still trying to teach him where all of the light switches are, so he will turn them off.
(Reply) (Parent) (Thread)
[User Picture]From: aaron
2000-07-27 03:50 pm (UTC)

Re: hmmm... 210 eh?

Heh heh! That won't be so tough, we'll just get Brad to write us perl program to, wait a minute...
(Reply) (Parent) (Thread)
[User Picture]From: bradfitz
2000-07-27 06:08 pm (UTC)

Re: hmmm... 210 eh?

we can pick how many digits the code is.

if we used 0 digit: 1 code (all off)
if we used 1 digit: 10 codes
if we used 2 digits: 45 codes
if we used 3 digits: 120 codes
if we used 4 digits: 210 codes
if we used 5 digits: 252 codes
if we used 6 digits: 210 codes (4 off)
if we used 7 digit: 120 codes (3 off)
if we used 8 digits: 45 codes (2 off)
if we used 9 digits: 10 codes (1 off)
if we used 10 digits: 1 codes (all on)

In any case, this lock is not secure at all. I wouldn't trust house keys in it.



(Reply) (Parent) (Thread)
[User Picture]From: bradfitz
2000-07-27 06:10 pm (UTC)

Re: hmmm... 210 eh?

However, I guess the intruder doesn't know how many digits we used, which makes the code space be:

1 + 10 + 45 + 210 + 252 + 210 + 45 + 10 + 1 = 784 possibilities.

Still pretty pathetic.
(Reply) (Parent) (Thread)
From: (Anonymous)
2000-07-27 07:22 pm (UTC)

Re: hmmm... 210 eh?

well now they do...
(Reply) (Parent) (Thread)
[User Picture]From: faith
2000-07-27 01:59 pm (UTC)

Nerd-riffic

That is hysterical.
(Reply) (Thread)
[User Picture]From: muerte
2000-07-27 04:17 pm (UTC)

Coming soon to the NSA

Brad, he's a coder, he's an html guru, he's a sys-admin, and now he's a code cracker!
(Reply) (Thread)
[User Picture]From: bradfitz
2000-07-27 04:19 pm (UTC)

Re: Coming soon to the NSA

brute-force on a 210 possibility code space won't impress the NSA too much, I'm afraid.
(Reply) (Parent) (Thread)
[User Picture]From: yizhe
2000-07-28 12:42 am (UTC)

Re: Coming soon to the NSA

He is not a code breaker. He is just someone who knows statistic and probability + a big brain for perl.
(Reply) (Parent) (Thread)
[User Picture]From: d4b
2000-07-27 07:34 pm (UTC)

Re: day job

> (wait ... I don't have a day job...)

We can't pay you if you don't invoice us....
(Reply) (Thread)
[User Picture]From: bradfitz
2000-07-27 07:44 pm (UTC)

Re: day job

um, where's that server? :-P
(Reply) (Parent) (Thread)
[User Picture]From: d4b
2000-07-27 07:53 pm (UTC)

Re: day job

> um, where's that server? :-P

um, where's that database schema? :-P

(and no, I don't want you posting it publicly ;-)
(Reply) (Parent) (Thread)
[User Picture]From: bradfitz
2000-07-27 07:57 pm (UTC)

Re: day job

what's the harm in making it public?

i made livejournal's public.

as for your's, I haven't even done it all yet. I've had so much to do with my servers non-stop that I don't have time to work on a system I have no way to test or work w/ whitaker on. we had a server at one point, but vince wiped it for no real good reason... that kinda upset me.

but there's a upside to all this for you: you won't be getting a big invoice from me this month. :/
(Reply) (Parent) (Thread)