Re: security code



On Sep 20, 12:14 am, m...@xxxxxxx (Mark Brader) wrote:
Anil Tendulakar:

Say you have a number lock having number keys from 1 to 5. You are
allowed to press either single keys or a pair of number keys
simultaneously.
Also you cannot press 3 keys simultaneously or repeat a key which was
pressed previously. The order in which the keys were pressed matters
but when a pair is pressed simultaneously, there is no order between
them

If a total of 5 keys are pressed, there are 5! sequences using single
keypresses.  Two consecutive keypresses could be replaced by a double
keypress at any of 4 places in the sequence, but then the order of the
two presses before they were replaced does not matter, so we drop a
factor of 2.  This replacement could also be done in two places in the
sequence in any of 3 ways (the sequence of double and single presses
could be dds, dsd, sdd) and again we drop a factor of 2 with each
replacement.  So that's 5! * (1 + 4/2 + 3/4) = 450.

If a total of 3 or 4 keys are pressed, each of these is equivalent to a
sequence with 5 keys, but with a final double or single keypress removed,
respectively.  So that's another 450 combinations.

If 2 keys are pressed separately, there are 5*4 = 20 combinations,
and if together, 5*4/2 = 10.  And if just 1 key is pressed, there are
5 combinations.

So the total number of possible combinations is 935.
--
Mark Brader, Toronto | "Courtesy, hell.  We're programmers not humans."
m...@xxxxxxx          |                             -- S. M. Ryan

My text in this article is in the public domain.

yup i got the same!
Single key (S, 2S, 3S, 4S, 5S): 5P1 + 5P2 + 5P3 + 5P4 + 5P5 = 325
Double key once (P, PS, P2S, P3S): 5C2 (3P0 + 3P1*2 + 3P2*3 + 3P3*4) =
490
Double key twice :( 2P, 2PS): 5C2*3C2*(3+1) = 120
TOTAL: 935
.



Relevant Pages

  • Re: security code
    ... allowed to press either single keys or a pair of number keys ... Two consecutive keypresses could be replaced by a double ... keypress at any of 4 places in the sequence, but then the order of the ... sequence in any of 3 ways (the sequence of double and single presses ...
    (rec.puzzles)
  • How to detect multiple simultaneous key presses? And a thread question
    ... detect multiple simultaneous key presses in C# let me know (in the ... keys c and d being pressed simultaneously or nearly so). ... public bool externalBoolMagicNumber; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: keypad scanner
    ... >> Or four keys pressed along a diagonal. ... Without diodes, ... but wnen it's low it's pulled low. ... >multiple key presses? ...
    (comp.arch.embedded)
  • termios and keyboard medium raw mode
    ... tcsetattr (fd, TCSAFLUSH, &newkbd); ... rotational velocity) when the user presses the arrow keys or the WASD ...
    (comp.lang.c)
  • Re: Detecting shift/alt keys
    ... >>>How do I detect when a user presses the shift or alt keys? ...
    (comp.lang.pascal.delphi.misc)