<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Hi Mikhail and Scilabers<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Thank you Mikhail for the equation with
factorials, the URL to Wikipedia, and confirming my findings are
OK (I really wasn't sure).</div>
<div class="moz-cite-prefix">Although the specifics of my case (with
codes on a lock) seems very constrained and 'special' - I suppose
it is common after all.</div>
<div class="moz-cite-prefix">It is interesting to see the math is
quite simple.<br>
</div>
<div class="moz-cite-prefix">It is also interesting to see the
'distribution' of combinations:</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">
<table width="873" cellspacing="0" cellpadding="0" border="0">
<colgroup><col
style="mso-width-source:userset;mso-width-alt:3840;width:79pt"
width="105"> <col style="width:48pt" width="64" span="12">
</colgroup><tbody>
<tr style="height:15.0pt" height="20">
<td style="height:15.0pt;width:79pt" width="105" height="20">Buttons
pushed</td>
<td style="width:48pt" width="64" align="right">0</td>
<td style="width:48pt" width="64" align="right">1</td>
<td style="width:48pt" width="64" align="right">2</td>
<td style="width:48pt" width="64" align="right">3</td>
<td style="width:48pt" width="64" align="right">4</td>
<td style="width:48pt" width="64" align="right">5</td>
<td style="width:48pt" width="64" align="right">6</td>
<td style="width:48pt" width="64" align="right">7</td>
<td style="width:48pt" width="64" align="right">8</td>
<td style="width:48pt" width="64" align="right">9</td>
<td style="width:48pt" width="64" align="right">10</td>
<td style="width:48pt" width="64">Sum =</td>
</tr>
<tr style="height:15.0pt" height="20">
<td style="height:15.0pt" height="20">Combinations</td>
<td align="right">1</td>
<td align="right">10</td>
<td align="right">45</td>
<td align="right">120</td>
<td align="right">210</td>
<td align="right">252</td>
<td align="right">210</td>
<td align="right">120</td>
<td align="right">45</td>
<td align="right">10</td>
<td align="right">1</td>
<td align="right">1024</td>
</tr>
</tbody>
</table>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">It is not that 'safe' of a lock because
someone can decode it within an hour or so. If you take e.g. 5
seconds for trying each combo, we're talking about 1,4 hours to
try all of them and maybe you hit jackpot somewhere in the middle.</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">It is not advisable to choose 0 or 1
buttons for the code. Coding 5 random numbers to be pushed on the
lock will give the highest number of combinations, but 4-6 buttons
gives a suitable range of codes, 7 could also be OK. Although more
buttons pushed gives fewer combinations, it's unlikely that e.g. a
thief will start with a high number of buttons pushed (pure
psychology).<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">From a decoding point of view, the most
interesting part of the lock is that it isn't as simple as
decoding a combination lock with 3 dials where you can easily keep
track of how far you are. It becomes complicated and one kinda
needs a look-up table to try all the combinations and it requires
more concentration to go through all the combinations.<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Cheers,</div>
<div class="moz-cite-prefix">Claus<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">On 15-04-2022 17:59, Mikhail Urusov
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAOKci2fsbA6Txi=Md6LwP2HODYBSG-6ApX29VV3auJYnvsenbA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Dear Claus,</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Just in case you have not got an answer yet:</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">> I can 'invent' a calculation, which could
be : =10*9*8/(3*2*1) = 120 ... if this indeed shows the
internal workings, I'd like to know why. Sorry my
combinatorics is so bad ... I </div>
<div dir="ltr"><br>
</div>
<div>This is right. In general, the formula for the number of
k-combinations of n elements is</div>
<div>n! / ( k! (n-k)! ).</div>
<div>Alternatively, you can write this as</div>
<div>n*(n-1)*....*(n-k+1) / (k!).</div>
<div>(This is the way you have written it above for n = 10 and
k = 3.)</div>
<div>The explanation in general is quite similar to this case:</div>
<div>
<p>> Two buttons pushed. There's 10 * 9 / 2 = 45
combinations. Each button can only be pushed once, so once
you've selected the first button, there's only 9 left, but
also we divide by two because the combination are doubled,
I mean for example the combination 1-2 = 2-1 ... the lock
doesn't know the difference. If you spread out the
possibilities in a 2D plane, it's like ignoring the
diagonal (like pushing the same button twice) and also we
either ignore the upper or lower triangle. Makes sense?</p>
<div>For example, for n=10 and k=4:</div>
If you consider "arrangements", i.e., the combinations,
where the order matters (e.g., 1-2-5-7 and 2-7-5-1 are
different), then you have 10*9*8*7 such arrangements (for
the first button you have 10 variants, for the second one 9
variants, etc), but each "combination" (that is, where the
order does not matter) is counted 4! (=1*2*3*4) times
(number of permutations of 4 elements), so you need to
divide: (10*9*8*7)/(4!).</div>
<div>For more information, see <a
href="https://en.wikipedia.org/wiki/Combination"
target="_blank" moz-do-not-send="true"
class="moz-txt-link-freetext">https://en.wikipedia.org/wiki/Combination</a></div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div>
<div dir="ltr">
<div><br>
</div>
<div>Best regards,</div>
<div>Mikhail</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Am Do., 14. Apr. 2022 um
13:51 Uhr schrieb Claus Futtrup <<a
href="mailto:cfuttrup@gmail.com" moz-do-not-send="true"
class="moz-txt-link-freetext">cfuttrup@gmail.com</a>>:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div>
<p>Dear Scilabers</p>
<p>I hope you can help me out. My combinatorics is a bit
rusty.</p>
<p>So, the spouse has purchased a lock and I wondered how
many combinations are available?</p>
<p>The lock has 10 push buttons, they are numbered
1-2-3-4-5-6-7-8-9-0.</p>
<p>From a programming point of view, any of the numbers
can be set on or off, meaning there are 2^10 = 1024
combinations, as far as I can see.</p>
<p>I wonder how they are distributed, and how many of the
numbers I should activate in the lock to maximize the
number of combinations?</p>
<p>Let's see, we have:</p>
<p>None (none of the buttons are activated), there's
exactly 1 combination for this situation. The lock is
delivered from the manufacturer in this state.</p>
<p>All (all of the buttons are activated), there's exactly
1 combination for this situation as well (no
variability).</p>
<p>One button pushed. There's obviously 10 possible
combinations (push any one of the 10 buttons).</p>
<p>Two buttons pushed. There's 10 * 9 / 2 = 45
combinations. Each button can only be pushed once, so
once you've selected the first button, there's only 9
left, but also we divide by two because the combination
are doubled, I mean for example the combination 1-2 =
2-1 ... the lock doesn't know the difference. If you
spread out the possibilities in a 2D plane, it's like
ignoring the diagonal (like pushing the same button
twice) and also we either ignore the upper or lower
triangle. Makes sense?</p>
<p>Here starts my trouble. Three buttons pushed. Instead
of looking at a 2D plane, I guess you spread out in 3D.
The diagonal line is more than that - we have several
planes where two of the three numbers are the same (and
which are not allowed).</p>
<p>To help myself out, I've tried to write all
combinations where one of the push buttons is number 1.
We select all combinations with the second button being
either 2-3-4 and so on, and how many combinations do we
then have for the third option? See table below:</p>
<p> </p>
<table width="128" cellspacing="0" cellpadding="0"
border="0">
<colgroup><col style="width:48pt" width="64" span="2"> </colgroup><tbody>
<tr style="height:15pt" height="20">
<td style="height:15pt;width:48pt" width="64"
height="20">1-2-x</td>
<td style="width:48pt" width="64" align="right">8</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">1-3-x</td>
<td align="right">7</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">1-4-x</td>
<td align="right">6</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">1-5-x</td>
<td align="right">5</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">1-6-x</td>
<td align="right">4</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">1-7-x</td>
<td align="right">3</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">1-8-x</td>
<td align="right">2</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">1-9-0</td>
<td align="right">1</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20"><br>
</td>
<td align="right">36</td>
</tr>
</tbody>
</table>
<p>We can then do the same for the first button = number
2, and we get : 7 + 6 + 5 + 4 + 3 + 2 + 1 = 28
combinations and so on. We get:<br>
</p>
<p> </p>
<table width="128" cellspacing="0" cellpadding="0"
border="0">
<colgroup><col style="width:48pt" width="64" span="2"> </colgroup><tbody>
<tr style="height:15pt" height="20">
<td style="height:15pt;width:48pt" width="64"
height="20">1-x-y</td>
<td style="width:48pt" width="64" align="right">36</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">2-x-y</td>
<td align="right">28</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">3-x-y</td>
<td align="right">21</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">4-x-y</td>
<td align="right">15</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">5-x-y</td>
<td align="right">10</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">6-x-y</td>
<td align="right">6</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">7-x-y</td>
<td align="right">3</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20">8-9-0</td>
<td align="right">1</td>
</tr>
<tr style="height:15pt" height="20">
<td style="height:15pt" height="20"><br>
</td>
<td align="right">120</td>
</tr>
</tbody>
</table>
<p>OK, so that was with three buttons pushed. It's always
good to know the answer (if it's correct :-/ I hope it
is), but it's a tedious process and I was wondering if
you could point me to an easy calculation instead? ...
Ideally something that expands to 4 and 5 buttons.</p>
<p>I can 'invent' a calculation, which could be :
=10*9*8/(3*2*1) = 120 ... if this indeed shows the
internal workings, I'd like to know why. Sorry my
combinatorics is so bad ... I haven't played in this
field for a while.<br>
</p>
Best regards,
<p>Claus<br>
</p>
</div>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank"
moz-do-not-send="true" class="moz-txt-link-freetext">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users"
rel="noreferrer" target="_blank" moz-do-not-send="true"
class="moz-txt-link-freetext">http://lists.scilab.org/mailman/listinfo/users</a><br>
</blockquote>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>