matthew.moss.coder
3/28/2006 2:54:00 PM
I think part of the problem was that it didn't matter which modifier
key you hit, the system would confirm the code. So while 150,000 is
right if you need to test every combo with every modifier, 50,000 is
what the problem was looking for (i.e., every combo with _any_
modifier).
On 3/28/06, semmons99@gmail.com <semmons99@gmail.com> wrote:
> You are right that there are 10,000 unique codes, but each of those
> codes can have any of the three unique modifier keys attached to it so
> 10,000 * 3 = 30,000 unique combinations you must press. And, since
> there are 5 keys in the 4 key code + 1 modifier key, it is 30,000 * 5 =
> 150,000. At first I didn't realize this until I wrote the loop to
> generate all of the unique code/modifier key combinations. The one key
> to this I believe, is that you have to treat the modifier key (1,2,3)
> as part of the code not a seperate entity. Here is some code to prove
> the solution.
>
> <code>
>
> output, num_codes = '', 0
>
> 10.times do |x1| 10.times do |x2| 10.times do |x3|
> 10.times do |x4| 3.times do |x5|
> output += x1.to_s + x2.to_s + x3.to_s + x4.to_s + x5.to_s
> num_codes += 1
> end end
> end end end
>
> print "number codes: ", num_codes.to_s, "\n"
> print "output length: ", output.length, "\n"
>
> </code>
>
>
>