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. I give up

I give up

Scheduled Pinned Locked Moved The Lounge
helpsalesquestion
36 Posts 23 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.
  • G generic_user_id

    I'll let the solution speak for itself: (Using Haskell set logic) solution :: [(Int, Int)] solution = [ (apples, oranges) | apples <- [0..100], oranges <- [0..100], apples * 29 + oranges * 39 == 1999 ] Result:

    [(38,23)]

    Hence, the answer must be 38 apples. Haskell really shines sometimes. I don't think solutions really get more elegant than this. :-D

    J Offline
    J Offline
    Jorgen Sigvardsson
    wrote on last edited by
    #23

    That's cheating. ;) -- Schni Schna Schnappi! Schnappi Schnappi Schnapp!

    1 Reply Last reply
    0
    • B Bassam Abdul Baki

      29a + 39o = 1999 29a ≤ 1999 ⇒ 0 ≤ a ≤ 68 39o ≤ 1999 ⇒ 0 ≤ o ≤ 51 29a + 39o ≡ 9a + 9o = 9(a + o) ≡ 9 (mod 10) ∴ a + o ≡ 1 (mod 10) Since 29 and 39 do not divide 1999, 29(a + o) < 29a + 39o < 39(a + 0) ⇒ 51 < a + o < 68. ∴ a + o = 61. a + o = 61 and 29a + 39o = 1999 ⇒ a = 38 and o = 23. "For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog

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

      This is exactly the method I used to solve the problem. (congruency and equivalence relations). Ahh, the good old days of discrete mathematics! -Sean ---- Shag a Lizard

      B 1 Reply Last reply
      0
      • S Sean Cundiff

        This is exactly the method I used to solve the problem. (congruency and equivalence relations). Ahh, the good old days of discrete mathematics! -Sean ---- Shag a Lizard

        B Offline
        B Offline
        Bassam Abdul Baki
        wrote on last edited by
        #25

        Gotta love Mathematics. Nothing you can't prove or counter-prove with it. :-D "For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog

        A 1 Reply Last reply
        0
        • B Bassam Abdul Baki

          Gotta love Mathematics. Nothing you can't prove or counter-prove with it. :-D "For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog

          A Offline
          A Offline
          Andy Brummer
          wrote on last edited by
          #26

          Especially Goedel's theorem.;P


          I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

          B V 2 Replies Last reply
          0
          • A Andy Brummer

            Especially Goedel's theorem.;P


            I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

            B Offline
            B Offline
            Bassam Abdul Baki
            wrote on last edited by
            #27

            Reminds me of a cousin of mine who used to say, if God is all-powerful, why can't he create a rock that is so big, that even he can't lift it, and if he can't lift it, how is he so powerful? I think that Goedel's theorem would fall under the prove that we can't prove it, in which case we have a proof (of sorts). :) And yes, you're a smart-ass. :-D "For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog

            A 1 Reply Last reply
            0
            • B Bassam Abdul Baki

              Reminds me of a cousin of mine who used to say, if God is all-powerful, why can't he create a rock that is so big, that even he can't lift it, and if he can't lift it, how is he so powerful? I think that Goedel's theorem would fall under the prove that we can't prove it, in which case we have a proof (of sorts). :) And yes, you're a smart-ass. :-D "For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog

              A Offline
              A Offline
              Andy Brummer
              wrote on last edited by
              #28

              Bassam Abdul-Baki wrote: And yes, you're a smart-ass. Sorry, I just couldn't resist.:-D


              I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

              1 Reply Last reply
              0
              • S Srikanth Remani

                a for apple, o for orange 29a + 39o = 1999 29(a + o) + 10o = 1999 lets call a + o = t (total) 29t + 10o = 1999 we know o is a whole number, o = (1999 - 29t)/10, for this to be a whole number 29t would be ***9 (has 9 in units place) so t would be *1 (has 1 in units place) so our probable answer set (for total fruits) are 1, 11, 21, 31, 41, 51, 61, 71 ... for lower limit a=0, so t = o (all fruits are oranges, since oranges are costlier) 39t = 1999, t = 1999/39 = 51.256 (just more than 51) for upper limit o = 0, so t =a (all fruits are apples, since apples are cheaper) 29t = 1999, t = 1999/29 = 68.931 (just less than 70). the only number that ends with *1 in this range is 61, so t = 61. so, 29*61 + 10o = 1999, 10o = 1999 - 1769, o = 230/10 = 23. a = 61- 23 = 38.

                V Offline
                V Offline
                Vikram A Punathambekar
                wrote on last edited by
                #29

                Amazing! :omg: What's even more amazing is that your very first post has garnered 11 5 votes and still counting. :cool: Vikram.


                http://www.geocities.com/vpunathambekar "It's like hitting water with your fist. There's all sorts of motion and noise at impact, and no impression left whatsoever shortly thereafter." — gantww.

                T 1 Reply Last reply
                0
                • A Andy Brummer

                  Especially Goedel's theorem.;P


                  I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

                  V Offline
                  V Offline
                  Vikram A Punathambekar
                  wrote on last edited by
                  #30

                  You beat me to it. :-D Vikram.


                  http://www.geocities.com/vpunathambekar "It's like hitting water with your fist. There's all sorts of motion and noise at impact, and no impression left whatsoever shortly thereafter." — gantww.

                  1 Reply Last reply
                  0
                  • S Srikanth Remani

                    a for apple, o for orange 29a + 39o = 1999 29(a + o) + 10o = 1999 lets call a + o = t (total) 29t + 10o = 1999 we know o is a whole number, o = (1999 - 29t)/10, for this to be a whole number 29t would be ***9 (has 9 in units place) so t would be *1 (has 1 in units place) so our probable answer set (for total fruits) are 1, 11, 21, 31, 41, 51, 61, 71 ... for lower limit a=0, so t = o (all fruits are oranges, since oranges are costlier) 39t = 1999, t = 1999/39 = 51.256 (just more than 51) for upper limit o = 0, so t =a (all fruits are apples, since apples are cheaper) 29t = 1999, t = 1999/29 = 68.931 (just less than 70). the only number that ends with *1 in this range is 61, so t = 61. so, 29*61 + 10o = 1999, 10o = 1999 - 1769, o = 230/10 = 23. a = 61- 23 = 38.

                    Y Offline
                    Y Offline
                    Yulianto
                    wrote on last edited by
                    #31

                    Wow for the solution and the number of 5 vote. :)


                    Work hard, Work effectively.

                    1 Reply Last reply
                    0
                    • B Bassam Abdul Baki

                      29a + 39o = 1999 29a ≤ 1999 ⇒ 0 ≤ a ≤ 68 39o ≤ 1999 ⇒ 0 ≤ o ≤ 51 29a + 39o ≡ 9a + 9o = 9(a + o) ≡ 9 (mod 10) ∴ a + o ≡ 1 (mod 10) Since 29 and 39 do not divide 1999, 29(a + o) < 29a + 39o < 39(a + 0) ⇒ 51 < a + o < 68. ∴ a + o = 61. a + o = 61 and 29a + 39o = 1999 ⇒ a = 38 and o = 23. "For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog

                      S Offline
                      S Offline
                      Srikanth Remani
                      wrote on last edited by
                      #32

                      The solution is quite elegant. seems to me that I should go back and refine my discrete mathematics and modern algebra. Blood, Sweat and Code

                      B 1 Reply Last reply
                      0
                      • M Matias Szulman

                        Today I realised that math is definitively not for me. For fun I was trying to solve some puzzles, and I've been stuck with this one for about an hour. I know some of you really get it, so could I ask for some help? Thanks! A fruitstand in my neighborhood sells apples for 29 cents apiece, and oranges for 39 cents apiece. One day I went there and filled a basket with a mixture of apples and oranges. When I paid for them I handed the clerk a $20 bill, and she handed me back my change ... one penny. How many apples did I buy? (Assume there was no sales tax charged.) Matias

                        C Offline
                        C Offline
                        Chester Ragel
                        wrote on last edited by
                        #33

                        In .net and C#.... int apple,orange = 0; //surely apple wont be more than 69 for(apple=0;apple<69;apple++) { long temp1,temp2 = 0; temp1 = Math.DivRem((1999-39*apple),29,out temp2); if(temp2 == 0) { orange = (int)temp1; break; } } //Get the ornage and apple here! :-D

                        1 Reply Last reply
                        0
                        • V Vikram A Punathambekar

                          Amazing! :omg: What's even more amazing is that your very first post has garnered 11 5 votes and still counting. :cool: Vikram.


                          http://www.geocities.com/vpunathambekar "It's like hitting water with your fist. There's all sorts of motion and noise at impact, and no impression left whatsoever shortly thereafter." — gantww.

                          T Offline
                          T Offline
                          ThatsAlok
                          wrote on last edited by
                          #34

                          Vikram A Punathambekar wrote: garnered 11 5 votes 18th is mine! ;P

                          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                          cheers, Alok Gupta

                          1 Reply Last reply
                          0
                          • S Srikanth Remani

                            The solution is quite elegant. seems to me that I should go back and refine my discrete mathematics and modern algebra. Blood, Sweat and Code

                            B Offline
                            B Offline
                            Bassam Abdul Baki
                            wrote on last edited by
                            #35

                            Yours was the equivalent of mine, just a bit more wordy. Don't get many mathematical problems on CP, so I quickly jumped into the solution. Little did I know that I was 3 hours late in supplying the first correct one. :( Whch is why I only got 3 votes. :-D "For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog

                            1 Reply Last reply
                            0
                            • M Michael Dunn

                              Let a = number of apples bought, and o = number of oranges bought. Then you have: 29_a_ + 39_o_ = 1999 You can't solve this equation in isolation, because to solve for 2 unknowns you need 2 equations. You have the restriction that both a and o must be integers, but I can't think of an equation for that in the 30 seconds I've been considering this problem ;) --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

                              X Offline
                              X Offline
                              Xiangyang Liu
                              wrote on last edited by
                              #36

                              Michael Dunn wrote: 29a + 39o = 1999 This is a perfect problem to be solved by computers, like the following: #include <stdio.h> void main() {   for(int a=0;a<100;a++)     for(int o=0;o<100;o++)       if(29*a+39*o==1999) printf("Solution: a=%d, o=%d\n",a, o); } :-D[

                              My articles and software tools

                              ](http://mysite.verizon.net/XiangYangL/index.htm)

                              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