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. Logic problem

Logic problem

Scheduled Pinned Locked Moved The Lounge
helpquestion
20 Posts 17 Posters 1 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.
  • C Chris Maunder

    You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

    T Offline
    T Offline
    Tim Smith
    wrote on last edited by
    #2

    Flip both - 4 minutes have expired. Flip 4 minutes HG and wait for 7 minutes to finish - 7 minutes have expired. Flip 7 minutes HG and wait for 4 minutes to finish - 8 minutes Flip 7 minutes HG again and wait for it to finish - 9 minutes Tim Smith I'm going to patent thought. I have yet to see any prior art.

    1 Reply Last reply
    0
    • C Chris Maunder

      You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

      L Offline
      L Offline
      Larry Antram
      wrote on last edited by
      #3

      Get a new hourglass.

      1 Reply Last reply
      0
      • C Chris Maunder

        You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

        S Offline
        S Offline
        Steven Hicks n 1
        wrote on last edited by
        #4

        Wait for the 7 minute one to become completed and then turn over the 4 minute one and wait till its half way finished. -Steven "the yellow dart" Hicks

        CPA

        CodeProjectAddict

        Actual Linux Penguins were harmed in the creation of this message.

        More tutorials: Ltpb.8m.com: Tutorials |404Browser.com (Download Link)

        1 Reply Last reply
        0
        • C Chris Maunder

          You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

          S Offline
          S Offline
          Sean Cundiff
          wrote on last edited by
          #5

          Let H7 == 7 minute hourglass, H4 == 4 minute hourglass. Let H7(x) and H4(y) represent the number of minutes (x,y) left on each hourglass. [edit] Let Flip be a prefix operator on Hz(x). (0 <= x <= z; x,z are ints) Define: Flip(Hz(x)) == Hz(z-x) ;P [/edit] Start H7 and H4 at the same time. When H4(0) then H7(3) -- 4 minutes have elapsed. Flip H4 over. When H7(0) then H4(1) -- 3 additional minutes have elapsed. Flip H7 over. When H4(0) then H7(6) -- 1 additional minute has elapsed. Flip H7 over. H7(6) transforms to H7(1). When H7(0) -- 1 additional minute has elapsed. 4 + 3 + 1 + 1 == 9 Q.E.D (Proof by example). -Sean ---- Shag a Lizard

          1 Reply Last reply
          0
          • C Chris Maunder

            You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

            M Offline
            M Offline
            Michael A Barnhart
            wrote on last edited by
            #6

            Well getting to 10 minutes is easier. OK :-O

            1 Reply Last reply
            0
            • C Chris Maunder

              You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

              C Offline
              C Offline
              Christopher Duncan
              wrote on last edited by
              #7

              Frankly, I'd take both back to the merchant for replacement. Neither 7 minutes nor 4 minutes are anywhere near an hour. You were robbed. And while you're there getting the 60 minutes worth of sand per glass that you originally paid for, I'd spend a couple of extra bucks and get some minuteglasses while you're at it. In fact, you might even be able to get him to throw one in for free, for your trouble... Chistopher Duncan Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)

              1 Reply Last reply
              0
              • C Chris Maunder

                You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

                J Offline
                J Offline
                Jon Newman
                wrote on last edited by
                #8

                Chris Maunder wrote: you want to measure 9 minutes, how do you do it? A watch...or that little clock in the bottom right of your screen. [edit]Now, can you stick your tongue out and touch your forhead?[/edit]


                "If you just say porn then you get all manner of chaff and low grade stuff."
                - Paul Watson, Lounge 25 Mar 03
                "If a man is standing in the middle of the forest speaking and there is no woman around to hear him, is he still wrong?"
                - Anon


                Jonathan 'nonny' Newman Homepage [www.nonny.com] [^]

                S P 2 Replies Last reply
                0
                • C Chris Maunder

                  You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #9

                  I don't do your homework problems! :-D Marc Help! I'm an AI running around in someone's f*cked up universe simulator.
                  Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus
                  Every line of code is a liability - Taka Muraoka
                  Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"

                  1 Reply Last reply
                  0
                  • C Chris Maunder

                    You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

                    D Offline
                    D Offline
                    Daniel Turini
                    wrote on last edited by
                    #10

                    Hehehe... Lots of free time and hourglass rolling on your screen... My latest article: GBVB - Converting VB.NET code to C#

                    J 1 Reply Last reply
                    0
                    • C Chris Maunder

                      You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

                      J Offline
                      J Offline
                      jhaga
                      wrote on last edited by
                      #11

                      HG 7 you let go to end and turn it around. HG 4 turn at 4 min and at 8 min At 8 min you turn HG 7 again and let it run out = 9 min !! jhaga

                      1 Reply Last reply
                      0
                      • C Chris Maunder

                        You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

                        J Offline
                        J Offline
                        JoeSox
                        wrote on last edited by
                        #12

                        go buy a 9 minute hourglass. :-D :jig::jig::jig: <that's logical.> Later,
                        JoeSox
                        www.humanaiproject.org "This life is more than just a read thru"[lyrics^] Can't Stop - Red Hot Chili Peppers

                        1 Reply Last reply
                        0
                        • J Jon Newman

                          Chris Maunder wrote: you want to measure 9 minutes, how do you do it? A watch...or that little clock in the bottom right of your screen. [edit]Now, can you stick your tongue out and touch your forhead?[/edit]


                          "If you just say porn then you get all manner of chaff and low grade stuff."
                          - Paul Watson, Lounge 25 Mar 03
                          "If a man is standing in the middle of the forest speaking and there is no woman around to hear him, is he still wrong?"
                          - Anon


                          Jonathan 'nonny' Newman Homepage [www.nonny.com] [^]

                          S Offline
                          S Offline
                          Steve Mayfield
                          wrote on last edited by
                          #13

                          Now, can you stick your tongue out and touch your forhead?

                          I can't - but Heidi Hamilton can - "a beautiful, blonde bomb shell with an 8-inch tongue". She is a Los Angeles radio "on air personality". Recently had a tongue-off with Kiss's Gene Simmons and won...here is the competition[^] Steve

                          J 1 Reply Last reply
                          0
                          • C Chris Maunder

                            You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

                            N Offline
                            N Offline
                            Nick Parker
                            wrote on last edited by
                            #14

                            Chris Maunder wrote: You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it? Flip the 4 minute hourglass. When the 4 minute hourglass is halfway down, flip the 7 minute hourglass. Did I miss a better solution? -Nick Parker

                            J 1 Reply Last reply
                            0
                            • N Nick Parker

                              Chris Maunder wrote: You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it? Flip the 4 minute hourglass. When the 4 minute hourglass is halfway down, flip the 7 minute hourglass. Did I miss a better solution? -Nick Parker

                              J Offline
                              J Offline
                              jhaga
                              wrote on last edited by
                              #15

                              Measuring a 4 minute hourglass halfway down will give you an accuracy of +-10 sek. If you let it run to the end, it gives an accuracy of +-5 sek. (hourglass standardisation rfc-474) jhaga

                              1 Reply Last reply
                              0
                              • S Steve Mayfield

                                Now, can you stick your tongue out and touch your forhead?

                                I can't - but Heidi Hamilton can - "a beautiful, blonde bomb shell with an 8-inch tongue". She is a Los Angeles radio "on air personality". Recently had a tongue-off with Kiss's Gene Simmons and won...here is the competition[^] Steve

                                J Offline
                                J Offline
                                Jon Newman
                                wrote on last edited by
                                #16

                                :omg::wtf::omg: I'll have to think twice before making that joke again


                                "If you just say porn then you get all manner of chaff and low grade stuff."
                                - Paul Watson, Lounge 25 Mar 03
                                "If a man is standing in the middle of the forest speaking and there is no woman around to hear him, is he still wrong?"
                                - Anon


                                Jonathan 'nonny' Newman Homepage [www.nonny.com] [^]

                                1 Reply Last reply
                                0
                                • D Daniel Turini

                                  Hehehe... Lots of free time and hourglass rolling on your screen... My latest article: GBVB - Converting VB.NET code to C#

                                  J Offline
                                  J Offline
                                  John Honan
                                  wrote on last edited by
                                  #17

                                  Nice article Daniel, although your link didn't work, I found it here: http://www.codeproject.com/csharp/GBVB.asp[^] I'm a VB.NET programmer, what I'd really like to see is a conversion / comparison chart of VB.NET versus C# I often find nice examples of things I need to do, but the code is in C#, and I have difficulty converting it to VB.NET! Things like, where to put the 'inherits' keyword, how to declare constructors, how 'namespace' is used in VB.NET, the structure of classes in VB.NET versus C#, how to declare functions/subs and parameters/return values in C# versus VB.NET I always get caught out by the 'reverse' way of declaring types in VB versus C++, e.g. in VB.NET you can say Dim myStr as String, in C# it's something like String myStr; (the other way around!) Okay, that's enough... I don't want to start a programming thread in the Lounge!... :-O John. www.silveronion.com[^]

                                  J 1 Reply Last reply
                                  0
                                  • J John Honan

                                    Nice article Daniel, although your link didn't work, I found it here: http://www.codeproject.com/csharp/GBVB.asp[^] I'm a VB.NET programmer, what I'd really like to see is a conversion / comparison chart of VB.NET versus C# I often find nice examples of things I need to do, but the code is in C#, and I have difficulty converting it to VB.NET! Things like, where to put the 'inherits' keyword, how to declare constructors, how 'namespace' is used in VB.NET, the structure of classes in VB.NET versus C#, how to declare functions/subs and parameters/return values in C# versus VB.NET I always get caught out by the 'reverse' way of declaring types in VB versus C++, e.g. in VB.NET you can say Dim myStr as String, in C# it's something like String myStr; (the other way around!) Okay, that's enough... I don't want to start a programming thread in the Lounge!... :-O John. www.silveronion.com[^]

                                    J Offline
                                    J Offline
                                    Jon Newman
                                    wrote on last edited by
                                    #18

                                    John Honan wrote: in VB.NET you can say Dim myStr as String, in C# it's something like String myStr; Thats C++ based languages for you.* No silly keywords found here. *No lets not get into a discussion about what C++ is based on


                                    "If you just say porn then you get all manner of chaff and low grade stuff."
                                    - Paul Watson, Lounge 25 Mar 03
                                    "If a man is standing in the middle of the forest speaking and there is no woman around to hear him, is he still wrong?"
                                    - Anon


                                    Jonathan 'nonny' Newman Homepage [www.nonny.com] [^]

                                    1 Reply Last reply
                                    0
                                    • C Chris Maunder

                                      You have two hourglasses, one measures 7 minutes and the other measures 4 minutes, now you want to measure 9 minutes, how do you do it?

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

                                      Get 7 min and 4 min hourglass going. When the 4 min hourglass has ran out flip it over (we marked 4 min). When the 7 min hourglass has ran out flip over the 7 min hourglass (we no have a 7 min mark). Bear in mind that the 4 min hourglass will still run for another 1 min. When the 4 min hour glass has finnally run out flip 7 min hour glass at this instant (we marked 8 min). At this point the 7 min hourglass has only run for 1 min and by flipping it over again we will have it run out in exactly 1 min. Hence, the 8 + 1 = 9 min. Problem solved. Happy Coding :) Marat Kagetsya dogd' nashinaetsya :)

                                      1 Reply Last reply
                                      0
                                      • J Jon Newman

                                        Chris Maunder wrote: you want to measure 9 minutes, how do you do it? A watch...or that little clock in the bottom right of your screen. [edit]Now, can you stick your tongue out and touch your forhead?[/edit]


                                        "If you just say porn then you get all manner of chaff and low grade stuff."
                                        - Paul Watson, Lounge 25 Mar 03
                                        "If a man is standing in the middle of the forest speaking and there is no woman around to hear him, is he still wrong?"
                                        - Anon


                                        Jonathan 'nonny' Newman Homepage [www.nonny.com] [^]

                                        P Offline
                                        P Offline
                                        Peter Hancock
                                        wrote on last edited by
                                        #20

                                        Sure.... what do you want me to touch my forehead with? My left hand, or my right hand?:-D And they still ran faster and faster and faster, till they all just melted away, and there was nothing left but a great big pool of melted butter "I ask candidates to create an object model of a chicken." -Bruce Eckel

                                        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