Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. IQ / Programming Quiz (Cannon-Ball Stacks)

IQ / Programming Quiz (Cannon-Ball Stacks)

Scheduled Pinned Locked Moved The Lounge
helpcomquestionlearning
85 Posts 19 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T tolw

    To tell you the truth I had to Google 'tetrahedral' to begin with ( my knowledge of English is limited I'm afraid :) ), which led me to: here[^] and later (through the See Also section) to here[^] Things were kind of obvious from there :) Thank you wikipedia :)

    A Offline
    A Offline
    AspDotNetDev
    wrote on last edited by
    #25

    Points awarded for sharing your research techniques, for pointing me to this GIF, and for figuring out a solution so fast without even knowing what a "tetrahedral" is. :)

    Thou mewling ill-breeding pignut!

    1 Reply Last reply
    0
    • A AspDotNetDev

      Background

      I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

      Cannon-Ball Stacks

      A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

      [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

      If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

      AspDotNetDev's Extra Rules

      Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

      Thou mewling ill-breeding pignut!

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #26

      Pascal's Triangle[^] Also see: Pascal's Pyramid[^]

      IronScheme
      ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))

      A 1 Reply Last reply
      0
      • M Mark_Wallace

        I'm going out in a bit to get some dolly mixture, and some jelly babies to build the pyramids. I'll nip up and give your OP a five, because it's really inspired me to be productive, today.

        I wanna be a eunuchs developer! Pass me a bread knife!

        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #27

        Points awarded for awarding me points (always a winning proposition). :rolleyes:

        Thou mewling ill-breeding pignut!

        1 Reply Last reply
        0
        • L leppie

          Pascal's Triangle[^] Also see: Pascal's Pyramid[^]

          IronScheme
          ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #28

          How does that relate to the cannon-ball problem? :confused:

          Thou mewling ill-breeding pignut!

          L 1 Reply Last reply
          0
          • A AspDotNetDev

            How does that relate to the cannon-ball problem? :confused:

            Thou mewling ill-breeding pignut!

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #29

            AspDotNetDev wrote:

            How does that relate to the cannon-ball problem?

            Exercise for the reader ;p (Can you not see the symmetry?)

            IronScheme
            ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))

            A 1 Reply Last reply
            0
            • A AspDotNetDev

              Background

              I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

              Cannon-Ball Stacks

              A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

              [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

              If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

              AspDotNetDev's Extra Rules

              Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

              Thou mewling ill-breeding pignut!

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #30

              The way I see it, each stack must have a number of cannonballs from the set {1, 4, 10, 20, 35...} Now we are looking for a minimum A and B, both out of this set, so that the sum of both is also in the set. From your example we know it works for two stacks of 10 cannonballs, so the sum cannot be greater than 20. Therefore A and B must both be in {1, 4, 10} Now you can simply try all combinations:

              A | B | Sum | Sum <= 20 | Sum in set

              1 | 1 | 2 | Y | N
              1 | 4 | 5 | Y | N
              1 |10 | 11 | Y | N
              4 | 1 | 5 | Y | N
              4 | 4 | 8 | Y | N
              4 |10 | 14 | Y | N
              10| 1 | 11 | Y | N
              10| 4 | 14 | Y | N
              10|10 | 20 | Y | Y

              So here we have it. Your example with two stacks of 10 cannonballs already is the minimum. Edit: Added pre tags to make the table readable

              I'm invincible, I can't be vinced

              A 1 Reply Last reply
              0
              • A AspDotNetDev

                Background

                I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                Cannon-Ball Stacks

                A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                AspDotNetDev's Extra Rules

                Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                Thou mewling ill-breeding pignut!

                B Offline
                B Offline
                BillWoodruff
                wrote on last edited by
                #31

                Hi AspDotNetDev, In this comment to your good self(ves?)[^], I think you raised an issue appropriate for "Site Suggs and Buggs:" and I have expressed my views there:[^]. And, to this starving worm on a wilted cabbage leaf, the issue raised by that post is an even more compelling puzzle than the stacking of cannon-balls, although I am not denigrating the value of considering the stacking of cannon balls ! best, Bill

                "Science is facts; just as houses are made of stones: so, is science made of facts. But, a pile of stones is not a house, and a collection of facts is not, necessarily, science." Henri Poincare

                1 Reply Last reply
                0
                • L Lost User

                  The way I see it, each stack must have a number of cannonballs from the set {1, 4, 10, 20, 35...} Now we are looking for a minimum A and B, both out of this set, so that the sum of both is also in the set. From your example we know it works for two stacks of 10 cannonballs, so the sum cannot be greater than 20. Therefore A and B must both be in {1, 4, 10} Now you can simply try all combinations:

                  A | B | Sum | Sum <= 20 | Sum in set

                  1 | 1 | 2 | Y | N
                  1 | 4 | 5 | Y | N
                  1 |10 | 11 | Y | N
                  4 | 1 | 5 | Y | N
                  4 | 4 | 8 | Y | N
                  4 |10 | 14 | Y | N
                  10| 1 | 11 | Y | N
                  10| 4 | 14 | Y | N
                  10|10 | 20 | Y | Y

                  So here we have it. Your example with two stacks of 10 cannonballs already is the minimum. Edit: Added pre tags to make the table readable

                  I'm invincible, I can't be vinced

                  A Offline
                  A Offline
                  AspDotNetDev
                  wrote on last edited by
                  #32

                  Nope, there was a stipulation that A and B are different. Otherwise, you are one the right track.

                  Thou mewling ill-breeding pignut!

                  1 Reply Last reply
                  0
                  • L leppie

                    AspDotNetDev wrote:

                    How does that relate to the cannon-ball problem?

                    Exercise for the reader ;p (Can you not see the symmetry?)

                    IronScheme
                    ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))

                    A Offline
                    A Offline
                    AspDotNetDev
                    wrote on last edited by
                    #33

                    leppie wrote:

                    Can you not see the symmetry?

                    They both involve triangles. Other than that, nope.

                    Thou mewling ill-breeding pignut!

                    1 Reply Last reply
                    0
                    • A AspDotNetDev

                      You keep deleting your messages before I can reply to them, so here is what I was going to say in response to one of them... :)


                      There is no pyramid composed of exactly 91 balls. It goes 84, then 120. You are on the right track though. Let me phrase it another way. There are 3 pyramids: A, B, and C. A is the smallest, B is larger, and C is the largest. The number of balls in C is equal to the sum of the balls in A and B. A does not equal B. This is the question: Find the smallest possible value of C.

                      Thou mewling ill-breeding pignut!

                      T Offline
                      T Offline
                      Thor Sigurdsson
                      wrote on last edited by
                      #34

                      A=20, B=54, C=55 or B=54, A=20, C=55 used two recurisve functions and iteration (lazy mans search).

                      I=I.am()?Code(I):0/0;

                      A 1 Reply Last reply
                      0
                      • A AspDotNetDev

                        Background

                        I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                        Cannon-Ball Stacks

                        A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                        [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                        If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                        AspDotNetDev's Extra Rules

                        Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                        Thou mewling ill-breeding pignut!

                        Y Offline
                        Y Offline
                        YvesDaoust
                        wrote on last edited by
                        #35
                        1. looked up the tetrahedral numbers in Wikipedia and found this list: 1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969... (10 seconds of work) 2) opened an Excel sheet and created the table of sums 2 5 11 21 36 57... 5 8 14 24 39 60... 11 14 20 30 45 66... 21 24 30 40 55 76... 36 39 45 55 70 91... ... (just needed to recall the appropriate syntax to form the cell expression; 1 minute of work) 3) sorted all sums in increasing order 2, 5, 5, 8, 11, 11, 14, 14, 20, 21, 21, 24, 24, 30, 30, 36, 36, 39, 39, 40, 45, 45, 55, 55, 57, 57, 60, 60, 66, 66, 70, 76, 76, 85, 85, 88, 88, 91, 91, ... (moved to Word to flatten the table structure; 1 minute of work) 4) spotted by eye in the list the first tetrahedral number larger than 20: 680, the sum of 120 and 560. (Lucky the Wikipedia list was long enough :)) (2 extra minutes) 5) explained the answer in CodeProject (half an hour)
                        A 1 Reply Last reply
                        0
                        • A AspDotNetDev

                          Background

                          I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                          Cannon-Ball Stacks

                          A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                          [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                          If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                          AspDotNetDev's Extra Rules

                          Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                          Thou mewling ill-breeding pignut!

                          J Offline
                          J Offline
                          jsc42
                          wrote on last edited by
                          #36

                          I did this using an old technique: pencil and paper. It is more complicated to explain than it was to do. Basically, I wrote 3 columns of numbers: Col 1: 1, 2, 3, 4, etc [represents the no of levels in the pyramid) Col 2: 1, (corresponding no in col 1 + prev number in col 2), ... [represents the no of new balls in the new level of the pyramid] Col 3: 1, (corresponding no in col 2 + prev number in col 3), ... [represents the total no of balls in the pyramid] and then looked for a number in col 2 that was the same as a number in col 3 which is a pyramid's worth of balls that is also a level's worth of balls [Actually, I didn't bother with col 1 - I could work that one out without writing it down, but it is easier to explain with it there] My solution is ... The first one found was 120, so the solution is 120 + 560 (no in col 3 before the 120 in col 2) = 680 (no in col 3 next to 120 in col 2). (select the text in the gap above, e.g. by dragging the mouse, to read it) Of course, this discounts the possibility that a pyramid might split across multiple levels in a combined pyramid. Just in case I had made a simple arithmetic error, I checked in MS-Excel: Cell A1 = 1, B1 = 1, C1 = 1 Cell A2 = =A1+1, B2 = =A2+B1, C2 = =B2+C1 Cells A3 through C17 = Copy and paste A2 through C2 [I've had to edit this entry twice - suffering from lysdexia (!) today].

                          A 2 Replies Last reply
                          0
                          • A AspDotNetDev

                            Background

                            I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                            Cannon-Ball Stacks

                            A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                            [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                            If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                            AspDotNetDev's Extra Rules

                            Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                            Thou mewling ill-breeding pignut!

                            Y Offline
                            Y Offline
                            yiangos
                            wrote on last edited by
                            #37

                            Well, using a bit of python:

                            def pyr(l):
                            if l==0:
                            return 0
                            elif l==1:
                            return 1
                            else:
                            return pyr(l-1)+l*(l+1)/2

                            #then we brute-force
                            a=[pyr(i) for i in range(100)][1:]
                            b=[(i,j,k) for i in a
                            for j in a
                            for k in a
                            if (i!=j and i+j==k)]
                            if len(b)>0:
                            print b[0]

                            Running the above yields the result as

                            (120, 560, 680)

                            as others have already pointed out... (Edit: changed the type from general to Answer)

                            Φευ! Εδόμεθα υπό ρηννοσχήμων λύκων! (Alas! We're devoured by lamb-guised wolves!)

                            1 Reply Last reply
                            0
                            • A AspDotNetDev

                              Background

                              I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                              Cannon-Ball Stacks

                              A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                              [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                              If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                              AspDotNetDev's Extra Rules

                              Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                              Thou mewling ill-breeding pignut!

                              Y Offline
                              Y Offline
                              YvesDaoust
                              wrote on last edited by
                              #38

                              A Python script can do. Grow a list of tetrahedral numers; for every new number, try and find a number in the list such that when subtracted from the new number, it gives another number in the list. (This way you make sure that for every new number the two terms of the decomposition are already in the list.)

                              # Start with an empty list
                              List= {}
                              n= 1

                              while n > 0:
                              # Try the next tetrahedral number
                              r= n * (n + 1) * (n + 2) / 6

                              # Try every number in the list
                              for p in List:
                                  # Lookup the difference between the new number and the current one
                                  q= r - p
                                  if p != q and q in List:
                                      print p, '+', q, '=', r
                              
                                      # Flag as found
                                      n= -1
                                      break
                              
                              # Not found, extend the list
                              List\[r\]= None
                              n+= 1
                              

                              For efficiency of the search, the list is implemented as a dictionnary. Yields:

                              560 + 120 = 680

                              1 Reply Last reply
                              0
                              • A AspDotNetDev

                                Background

                                I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                                Cannon-Ball Stacks

                                A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                                [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                                If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                                AspDotNetDev's Extra Rules

                                Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                                Thou mewling ill-breeding pignut!

                                E Offline
                                E Offline
                                el_vez
                                wrote on last edited by
                                #39

                                Haskell answer:

                                layers = scanl1 (+) [1..]
                                sizes = scanl1 (+) layers
                                combinedSizes = [(s1, s2, s1 + s2) | s1 <- sizes, s2 <- takeWhile (< s1) sizes]
                                newPyramids = filter combinesToPyramid combinedSizes
                                where combinesToPyramid (s1, s2, sum) = sum `elem` (takeWhile (sum >=) sizes)

                                answer = head newPyramids

                                -------- SPOILER ------------ this gives the answer as "(560, 120, 680)", (if you load it up in GHCI and type "answer"). If you want the n first solutions, just type "take n newPyramids":

                                take 3 newPyramids
                                [(560,120,680),(27720,1540,29260),(29260,4960,34220)]

                                A 1 Reply Last reply
                                0
                                • A AspDotNetDev

                                  Background

                                  I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                                  Cannon-Ball Stacks

                                  A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                                  [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                                  If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                                  AspDotNetDev's Extra Rules

                                  Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                                  Thou mewling ill-breeding pignut!

                                  Y Offline
                                  Y Offline
                                  YvesDaoust
                                  wrote on last edited by
                                  #40

                                  Brute force:

                                  def T(n):
                                  return n * (n + 1) * (n + 2) / 6

                                  r= 1
                                  while True:
                                  q= 1
                                  while q < r:
                                  p= 1
                                  while T(p) + T(q) < T(r):
                                  p+= 1
                                  if T(p) + T(q) == T(r):
                                  print T(p), '+', T(q), '=', T(r)
                                  q+= 1
                                  r+= 1

                                  Yields:

                                  10 + 10 = 20
                                  560 + 120 = 680
                                  120 + 560 = 680
                                  27720 + 1540 = 29260
                                  1540 + 27720 = 29260
                                  29260 + 4960 = 34220
                                  4960 + 29260 = 34220
                                  59640 + 10660 = 70300
                                  10660 + 59640 = 70300
                                  182104 + 39711 = 221815
                                  39711 + 182104 = 221815
                                  ...

                                  1 Reply Last reply
                                  0
                                  • A AspDotNetDev

                                    Background

                                    I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                                    Cannon-Ball Stacks

                                    A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                                    [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                                    If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                                    AspDotNetDev's Extra Rules

                                    Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                                    Thou mewling ill-breeding pignut!

                                    Y Offline
                                    Y Offline
                                    YvesDaoust
                                    wrote on last edited by
                                    #41

                                    Even bruter force:

                                    def T(n):
                                    return n * (n + 1) * (n + 2) / 6

                                    for r in range (1, 1000):
                                    for q in range(1, r):
                                    for p in range(1, q):
                                    if T(p) + T(q) == T(r):
                                    print T(p), '+', T(q), '=', T(r)

                                    Yields:

                                    120 + 560 = 680
                                    1540 + 27720 = 29260
                                    4960 + 29260 = 34220
                                    10660 + 59640 = 70300
                                    39711 + 182104 = 221815
                                    102340 + 125580 = 227920
                                    7140 + 280840 = 287980
                                    19600 + 447580 = 467180
                                    ...

                                    A 1 Reply Last reply
                                    0
                                    • M Mark_Wallace

                                      AspDotNetDev wrote:

                                      what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid?

                                      A couple of points: - You can't make a tetrahedron with 10 cannon balls; you need 11. - You'd have to define "large".

                                      I wanna be a eunuchs developer! Pass me a bread knife!

                                      P Offline
                                      P Offline
                                      PhilLenoir
                                      wrote on last edited by
                                      #42

                                      Sorry, 6 on the bottom, 3 next then 1 = total 10 for a 3x3x3 pyramid!

                                      Life is like a s**t sandwich; the more bread you have, the less s**t you eat.

                                      1 Reply Last reply
                                      0
                                      • T Thor Sigurdsson

                                        A=20, B=54, C=55 or B=54, A=20, C=55 used two recurisve functions and iteration (lazy mans search).

                                        I=I.am()?Code(I):0/0;

                                        A Offline
                                        A Offline
                                        AspDotNetDev
                                        wrote on last edited by
                                        #43

                                        Nope, 20 + 54 is not 55.

                                        Thou mewling ill-breeding pignut!

                                        T 1 Reply Last reply
                                        0
                                        • A AspDotNetDev

                                          Background

                                          I'm reading "The Mammoth Book of IQ Puzzles". It contains, as you may have guessed, a bunch of IQ puzzles. I just solved one of them and thought I'd write the problem down here so you would all have a chance to solve it too. It is called "Cannon-Ball Stacks". In finding the answer, reference materials, books, calculators, and computers are allowed. Since computers are allowed, programs can be created to get the solution.

                                          Cannon-Ball Stacks

                                          A park ranger has stacked cannon-balls in two tetrahedral pyramids for display at Gettysburg. He later decides to combine the cannon-balls in both of the pyramids in order to create one large pyramid. The smallest number of cannon-balls he can have if the two pyramids are the same size is twenty (assuming he uses every cannon-ball in both pyramids).

                                          [10 cannon-ball pyramid] + [10 cannon-ball pyramid] = [20 cannon-ball pyramid]

                                          If the two smaller pyramids are different sizes, however, what would be the minimum number of cannon-balls he could use to make one large tetrahedral pyramid? Difficulty: 4 out of 5.

                                          AspDotNetDev's Extra Rules

                                          Explain how you arrived at the solution. If you create a program to help you solve the problem, paste that in your message. I will reply to this message with the answer in a hidden <span> tag. Don't cheat by looking first though! I will post tomorrow how I arrived at my solution (which may be incorrect, as the book doesn't list what the correct answer is). Points will be awarded for: elegance, quickness, humor, and correcting others (in no particular order). Good luck!

                                          Thou mewling ill-breeding pignut!

                                          P Offline
                                          P Offline
                                          PhilLenoir
                                          wrote on last edited by
                                          #44

                                          Maybe not the most elegant solution but might possibly be the fastest way to come up with the answer!: 1 Using Excel I created 3 columns: column 1 being a linear sequence (1,2,3 ....100); column 2 representing each layer (B1=1,B2=A1+A2); the third representing the pyramid (C1=1,C2=B1+B2) 2 I pasted these into an Access table 3 I cross joined the table to itself and added the two columns 3 4 I inner joined the query to the table on sum = column 3 Answer 120 (8 layers) + 560 (14 layers) = 680 (15 layers)

                                          Life is like a s**t sandwich; the more bread you have, the less s**t you eat.

                                          A 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups