• subscribe
January 25, 2008 12:00 AM

The Logical Puzzle

SQL Server Pro
InstantDoc ID #97759

Solution to January’s Puzzle: Counting Triangles Can you figure out how many triangles Figure A contains? Can you think of a methodical approach or formula to calculate this number?

To follow the explanation of this puzzle’s solution, examine Figure B, in which the points in the diagram are marked with letters. To find a methodical approach for solving the puzzle, you must identify a repeating pattern in the diagram. Note that the diagram contains a repeating pattern of floors or levels. Each floor except the top one consists of two lines crossing each other, as well as a ceiling.

To create a formula for counting the triangles, you must determine the effect of adding each floor. You can start by drawing only the outermost triangle (ABC). So far, your count is 1. Add the ceiling of the first floor (DE), and the triangle ADE adds 1 to the count. Next, add the lines crossing each other within the first floor (DC, BE). The new triangles formed as a result of adding these two lines include 4 one-celled triangles (DBF, FBC, EFC, DFE), 4 two-celled triangles (DBC, BCE, CED, EDB) and 2 three-celled triangles (ABE, ADC), thus adding 10 new triangles to the count. So adding the first floor (including the ceiling and the two lines crossing each other) adds 11 to the original count of 1.

Add another floor by marking the lines GH, DH, and GE. This adds 11 new triangles (as the first floor also added), plus 2 new four-celled triangles (GBE, HDC). In other words, the first floor adds 11 to the count, and every additional floor beyond the first adds 13 to the count.

Although the top floor doesn’t have a ceiling (no line exists between points J and K), you can imagine the floor as if there were a ceiling (namely, add 13 to the count), then subtract the triangles that are eliminated by removing the floor. Four triangles are eliminated (AJK, JLK, JGK, JHK). So the total number of triangles you get is 1 + 11 + 13 + 13 - 4 = 34.

The general formula for n floors when the top floor has no ceiling is: 1 + 11 + [(n - 1) × 13] - 4. If you simplify the formula by expanding the parentheses (i.e., 1 + 11 + (n × 13) - 13 - 4), you get (n × 13) - 5. So for 3 floors you get (3 × 13) - 5 = 34. Now you can easily calculate the number of triangles for any given number of floors.

February’s Puzzle: Counterfeit Coins
This puzzle is from Clifford Jensen. Suppose you have 10 stacks of coins, with 10 coins in each stack. One stack consists of 10 counterfeit coins and the other 9 stacks each consist of 10 legitimate coins. Each legitimate coin weighs exactly 1 gram. Each counterfeit coin weighs exactly 0.9 grams. You have a digital scale that’s graduated in tenths of grams. Using the scale to take only one reading, determine which stack has the 10 counterfeit coins. You can weigh any number of coins from any number of stacks, but must you weigh them all together (i.e., you can take only one reading from the scale).



ARTICLE TOOLS

Comments
  • Carla
    4 years ago
    Mar 27, 2008

    In my previous comment, replace subtract from 10 by subtract from 1 and use total weight mod 1 not mod 10.

  • Carla
    4 years ago
    Mar 27, 2008

    Number the stacks from 1 to 10. Place coins from each stack on the scale equal to the number of the stack (1 from stack 1, 2 from stack 2, etc.). Subtract from 10 the weight mod 10 to get the stack that has the counterfeit coins. (Assuming the bad coins are in stack 3, the total weight is 547, and the stack can be found by the following calculation: 10 - (547%10) = 3.

  • Thomas
    4 years ago
    Feb 13, 2008

    Place 1 coin from stack 1, 2 coins from stack 2,..., 9 coins from stack 9, and 10 coins from stack 10 on the scale and weigh.
    CASE weight
    WHEN 54.9 THEN Stack 1 is counterfeit
    WHEN 54.8 THEN Stack 2 is counterfeit
    WHEN 54.7 THEN Stack 3 is counterfeit
    WHEN 54.6 THEN Stack 4 is counterfeit
    WHEN 54.5 THEN Stack 5 is counterfeit
    WHEN 54.4 THEN Stack 6 is counterfeit
    WHEN 54.3 THEN Stack 7 is counterfeit
    WHEN 54.2 THEN Stack 8 is counterfeit
    WHEN 54.1 THEN Stack 9 is counterfeit
    WHEN 54.0 THEN Stack 10 is counterfeit

  • LAVON
    4 years ago
    Feb 11, 2008

    Just wanted to note that the figures are now correct as posted. Sorry for the confusion! --Lavon Peters, Senior Editor

  • Anne
    4 years ago
    Feb 08, 2008

    Readers, thanks for pointing out the error in the puzzle. Itzik's answer of 34 triangles is correct, but the figures we posted are not. The Figures A and B that you refer to have a line (JK in Figure B) that was not in the figures Itzik originally provided to us. I apologize for the incorrect additional line, which was accidentally introduced when the article was edited. We'll post the correct figures as soon as possible. Thanks for reading!
    Anne Grubb, Web site strategic editor, SQL Server Magazine

You must log on before posting a comment.

Are you a new visitor? Register Here