*In each issue of the Automation Notebook we feature a section of brainteasers. These are the brainteaser answers from Issue 31, 2015 of Automation Notebook. The brainteaser questions are repeated in black. The answers to the brainteaser questions are highlighted in red with explanations. You can view the brainteasers from Issue 31, 2015 without the answers here.*

## 1.) Fitting Splitting

Two engineers went to the AutomationDirect Web store and bought 30 NITRA pneumatic quick-disconnect fittings (some with chrome-plating, some without). As they discussed divvying up the cost, Fred pointed out that his portion of the order contained half of the chrome-plated fittings, but only one third of the plain fittings. He also declared (correctly) that his portion of the order totaled $27.

Four chrome-plated fittings cost the same as five plain fittings. *How much was Wilma’s portion of the order?*

**Answer: Fitting Splitting**

Wilma’s total was $39. There were 18 regular and 12 chrome-plated fittings in the order. The regular fittings are $2.00, and the chrome plated are $2.50.

**2.) ZipPort Assort Report**

An eccentric customer called our Sales department recently and said “I have exactly $200 to spend on ZipPort Multi-wire Connector accessories. I need some Cable Glands ($1 each), ten times that many Couplers ($2 each), and fill the balance of the order with Threaded Adapters ($5 each)”. Our sales staff took his order with no further information about the quantities required. *How many of each product did we ship?*

**Answer: ZipPort Assort Report**

The smallest number of Cable Glands and Couplers that could be sold is $21 worth (1 CG and 10 Couplers). The other possibilities (without exceeding $200) are $42, $63, $84, $105, $126, $147, $168, & $189. The only one of these whose remainder – from the $200 total -is evenly divisible by $5 (the cost of the Threaded Adapters) is the fifth: five CGs & fifty Couplers at $105 total. This leaves a remainder of $95 to be spent on Threaded Adapters. So the order must have been placed for 5 Cable Glands ($5), 50 Couplers($100), and 19 Threaded Adapters($95).

**3.) In a (lock) Box With a Fox**

We installed one of those “wall-mount combination lock boxes” at our community center recently. It holds the key to the storage shed, and allows anyone who knows the code to remove the key from the lock box and open the shed. But it started a water cooler discussion amongst the engineers at the office as we debated the potential number of combinations. At first glance, it seems simple, there are 10 buttons (0-9) and the manufacturer recommends a four digit code (user-selectable), so the number of possibilities would be 10,000, right? Not so fast … in this case, there are two extra rules: Due to the mechanical nature of the lock, you can only use a given number once in your user-selected code AND this is the real kicker: order is unimportant. So code 1234 is the same code as 4321 or 4231.

*So, what is the total number of distinct 4-digit combinations possible for this lock?*

**Answer: In a (lock)Box With a Fox**

Shockingly, there are only 210 combinations when using a 4 digit code.

When choosing the first digit there are 10 choices, then since you can’t reuse that digit, there are only 9 choices for the second digit, and so on. So we start with 10 x 9 x 8 x7 choices, but then we have to remove all the duplicate codes due to “order being irrelevant” so we need to divide that total by 4! (4 Factorial = 4 x 3 x 2 x 1 = 24); the number of different “order combinations” for any given 4 digit number). 5040 / 24 = 210 total possibilities

Another way to determine this number is to use the formula (10!)/((10-r)! * (r!)) where r=4 and the answer also 210. Remember “factorials”?

**4.) Extra Credit **

It turns out that the lockbox will accept codes of any length (although some lengths would seem foolish). *What is the number if you consider all of the other length combinations (i.e. 3-digit, 5-digit, 6 digit, etc.)?*

**Answer: Extra Credit**

Using the same formula above – we modify for the other lengths. For one digit formulas there are (obviously) 10 combinations, for 2 there are 45, for 3 there are 120, for four 210, five digits are the most secure with 252, and 6 give 210, seven 120, eight give 45, and nine give 10. This totals 1022 combinations, and there are technically 2 more: no buttons pressed, and “all ten” buttons pressed, for a grand total of 1024 possible combinations. This number is still a far cry from the 10,000 combinations that some 4-digit locks can provide. It’s probably enough for our community storage shed – but I would think twice about using this lock to secure a key that guards more valuable possessions.

Another (perhaps simpler) way to consider the extra credit solution: each of the 10 digits can either be a part of the combination or not.

So, we could calculate the total as 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 = 2^{10} = 1024… kind of a nice double check of our original math.