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. Coding Challenge

Coding Challenge

Scheduled Pinned Locked Moved The Lounge
c++architecturehelp
165 Posts 47 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.
  • P PIEBALDconsult

    "Either end" means you can choose which, otherwise he would have said "both ends". (I can't stand the use of "either" in place of "both".)

    P Offline
    P Offline
    Pete OHanlon
    wrote on last edited by
    #4

    Actually, he said earlier in the post "each end", so he is indicating that it is from both sides. What this shows - Chris sucks at coming up with program specifications. :)

    Forgive your enemies - it messes with their heads

    "Mind bleach! Send me mind bleach!" - Nagy Vilmos

    My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

    M 1 Reply Last reply
    0
    • C CPallini

      Hey Chris, may I post my own programming issue labeling it with 'Coding Challenge' or 'Fun For Everyone'? Just Kidding! Sorry for my poor understanding of English, with

      Chris Maunder wrote:

      from either end

      Do you mean the output string should be:

      " monkey dog horse "

      ?

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      C Offline
      C Offline
      Chris Maunder
      wrote on last edited by
      #5

      I've updated the extremely rigourous and well planned specs to change "either" to "each" and to also show the final output string (so yes: " monkey dog horse ")

      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

      1 Reply Last reply
      0
      • P PIEBALDconsult

        "Either end" means you can choose which, otherwise he would have said "both ends". (I can't stand the use of "either" in place of "both".)

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

        PIEBALDconsult wrote:

        (I can't stand the use of "either" in place of "both".)

        Either means both, well, each of two - or it did in its original 'Ye Olde English' version.

        Every man can tell how many goats or sheep he possesses, but not how many friends.

        P 1 Reply Last reply
        0
        • C Chris Maunder

          Back in the Days of Yore we had a couple of small coding challenges such as the Lean and Mean comp. I was thinking that there are a ton of small, well defined problems that can be tackled a zillion ways in a zillion languages and that it would be cool to see what you guys can come up with. I'd like to start the ball rolling with the following simple task: Problem: Given a string of text, trim from each end of the text each all occurrences of a given set of strings Sample input: Input string: "dog cat monkey dog horse dog" Strings that need to be trimmed from each end: { "dog", "cat" } Final output should be: " monkey dog horse" Final output should be " cat monkey dog horse " [Edit: My final sample output was incorrect, so to be fair I'll accept either answer] It's up to you whether you worry about case sensitivity. Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code. For those who feel like jumping on the "No Programming questions" bandwagon, please re-read the lounge guidelines. The point of this is to have fun, not to solve each other's programming issues.

          cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

          N Offline
          N Offline
          Nagy Vilmos
          wrote on last edited by
          #7

          I've got the solution in Brainfuck, but I can't find a compiler to check. #whistles#


          Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

          1 Reply Last reply
          0
          • C Chris Maunder

            Back in the Days of Yore we had a couple of small coding challenges such as the Lean and Mean comp. I was thinking that there are a ton of small, well defined problems that can be tackled a zillion ways in a zillion languages and that it would be cool to see what you guys can come up with. I'd like to start the ball rolling with the following simple task: Problem: Given a string of text, trim from each end of the text each all occurrences of a given set of strings Sample input: Input string: "dog cat monkey dog horse dog" Strings that need to be trimmed from each end: { "dog", "cat" } Final output should be: " monkey dog horse" Final output should be " cat monkey dog horse " [Edit: My final sample output was incorrect, so to be fair I'll accept either answer] It's up to you whether you worry about case sensitivity. Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code. For those who feel like jumping on the "No Programming questions" bandwagon, please re-read the lounge guidelines. The point of this is to have fun, not to solve each other's programming issues.

            cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

            J Offline
            J Offline
            Jason Hooper
            wrote on last edited by
            #8

            We could all just do these: http://projecteuler.net/[^]

            Jason

            1 Reply Last reply
            0
            • L Lost User

              PIEBALDconsult wrote:

              (I can't stand the use of "either" in place of "both".)

              Either means both, well, each of two - or it did in its original 'Ye Olde English' version.

              Every man can tell how many goats or sheep he possesses, but not how many friends.

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #9

              No, it means "one or the other".

              L 1 Reply Last reply
              0
              • C Chris Maunder

                Back in the Days of Yore we had a couple of small coding challenges such as the Lean and Mean comp. I was thinking that there are a ton of small, well defined problems that can be tackled a zillion ways in a zillion languages and that it would be cool to see what you guys can come up with. I'd like to start the ball rolling with the following simple task: Problem: Given a string of text, trim from each end of the text each all occurrences of a given set of strings Sample input: Input string: "dog cat monkey dog horse dog" Strings that need to be trimmed from each end: { "dog", "cat" } Final output should be: " monkey dog horse" Final output should be " cat monkey dog horse " [Edit: My final sample output was incorrect, so to be fair I'll accept either answer] It's up to you whether you worry about case sensitivity. Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code. For those who feel like jumping on the "No Programming questions" bandwagon, please re-read the lounge guidelines. The point of this is to have fun, not to solve each other's programming issues.

                cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #10

                Chris Maunder wrote:

                most unique

                That'll be mine. :-D

                C 1 Reply Last reply
                0
                • C Chris Maunder

                  Back in the Days of Yore we had a couple of small coding challenges such as the Lean and Mean comp. I was thinking that there are a ton of small, well defined problems that can be tackled a zillion ways in a zillion languages and that it would be cool to see what you guys can come up with. I'd like to start the ball rolling with the following simple task: Problem: Given a string of text, trim from each end of the text each all occurrences of a given set of strings Sample input: Input string: "dog cat monkey dog horse dog" Strings that need to be trimmed from each end: { "dog", "cat" } Final output should be: " monkey dog horse" Final output should be " cat monkey dog horse " [Edit: My final sample output was incorrect, so to be fair I'll accept either answer] It's up to you whether you worry about case sensitivity. Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code. For those who feel like jumping on the "No Programming questions" bandwagon, please re-read the lounge guidelines. The point of this is to have fun, not to solve each other's programming issues.

                  cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                  N Offline
                  N Offline
                  NormDroid
                  wrote on last edited by
                  #11

                  Chris Maunder wrote:

                  Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code.

                  Blows dust off assembler manual, I doubt the script kiddies will even know what assembler is.

                  Software Kinetics Wear a hard hat it's under construction
                  Metro RSS

                  1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    Chris Maunder wrote:

                    most unique

                    That'll be mine. :-D

                    C Offline
                    C Offline
                    Chris Maunder
                    wrote on last edited by
                    #12

                    Well...we're waiting :D

                    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      Back in the Days of Yore we had a couple of small coding challenges such as the Lean and Mean comp. I was thinking that there are a ton of small, well defined problems that can be tackled a zillion ways in a zillion languages and that it would be cool to see what you guys can come up with. I'd like to start the ball rolling with the following simple task: Problem: Given a string of text, trim from each end of the text each all occurrences of a given set of strings Sample input: Input string: "dog cat monkey dog horse dog" Strings that need to be trimmed from each end: { "dog", "cat" } Final output should be: " monkey dog horse" Final output should be " cat monkey dog horse " [Edit: My final sample output was incorrect, so to be fair I'll accept either answer] It's up to you whether you worry about case sensitivity. Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code. For those who feel like jumping on the "No Programming questions" bandwagon, please re-read the lounge guidelines. The point of this is to have fun, not to solve each other's programming issues.

                      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                      C Offline
                      C Offline
                      Chris Losinger
                      wrote on last edited by
                      #13

                      can we assume the input string is going to be tokenizable on ' ' ? or, should we expect things like "dogcatcotblahfoodog"

                      image processing toolkits | batch image processing

                      C 1 Reply Last reply
                      0
                      • C Chris Maunder

                        Back in the Days of Yore we had a couple of small coding challenges such as the Lean and Mean comp. I was thinking that there are a ton of small, well defined problems that can be tackled a zillion ways in a zillion languages and that it would be cool to see what you guys can come up with. I'd like to start the ball rolling with the following simple task: Problem: Given a string of text, trim from each end of the text each all occurrences of a given set of strings Sample input: Input string: "dog cat monkey dog horse dog" Strings that need to be trimmed from each end: { "dog", "cat" } Final output should be: " monkey dog horse" Final output should be " cat monkey dog horse " [Edit: My final sample output was incorrect, so to be fair I'll accept either answer] It's up to you whether you worry about case sensitivity. Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code. For those who feel like jumping on the "No Programming questions" bandwagon, please re-read the lounge guidelines. The point of this is to have fun, not to solve each other's programming issues.

                        cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                        D Offline
                        D Offline
                        Dalek Dave
                        wrote on last edited by
                        #14

                        How can anything be described as "Most Unique"? Unique is an absolute, it either is or isn't. Perhaps "Most Elegant" would be a more apposite epithet?

                        ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                        N C 2 Replies Last reply
                        0
                        • C Chris Maunder

                          Back in the Days of Yore we had a couple of small coding challenges such as the Lean and Mean comp. I was thinking that there are a ton of small, well defined problems that can be tackled a zillion ways in a zillion languages and that it would be cool to see what you guys can come up with. I'd like to start the ball rolling with the following simple task: Problem: Given a string of text, trim from each end of the text each all occurrences of a given set of strings Sample input: Input string: "dog cat monkey dog horse dog" Strings that need to be trimmed from each end: { "dog", "cat" } Final output should be: " monkey dog horse" Final output should be " cat monkey dog horse " [Edit: My final sample output was incorrect, so to be fair I'll accept either answer] It's up to you whether you worry about case sensitivity. Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code. For those who feel like jumping on the "No Programming questions" bandwagon, please re-read the lounge guidelines. The point of this is to have fun, not to solve each other's programming issues.

                          cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                          H Offline
                          H Offline
                          hairy_hats
                          wrote on last edited by
                          #15

                          How should whitespace at the ends of the input string be treated - does " cat dog " match or only "cat dog"?

                          D C 2 Replies Last reply
                          0
                          • H hairy_hats

                            How should whitespace at the ends of the input string be treated - does " cat dog " match or only "cat dog"?

                            D Offline
                            D Offline
                            Dalek Dave
                            wrote on last edited by
                            #16

                            I bet he is wishing he never asked the damn question now! :)

                            ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                            N 1 Reply Last reply
                            0
                            • D Dalek Dave

                              How can anything be described as "Most Unique"? Unique is an absolute, it either is or isn't. Perhaps "Most Elegant" would be a more apposite epithet?

                              ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                              N Offline
                              N Offline
                              NormDroid
                              wrote on last edited by
                              #17

                              Cut the small talk and lets see your solution in VBScript (pulls leg) :laugh:

                              Software Kinetics Wear a hard hat it's under construction
                              Metro RSS

                              1 Reply Last reply
                              0
                              • P Pete OHanlon

                                Actually, he said earlier in the post "each end", so he is indicating that it is from both sides. What this shows - Chris sucks at coming up with program specifications. :)

                                Forgive your enemies - it messes with their heads

                                "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                                M Offline
                                M Offline
                                Mike Hankey
                                wrote on last edited by
                                #18

                                I thought it meant that he didn't like dogs or cats but horses and monkey's are OK?

                                Visual Studio Task List on Steriods - VS2010/AVR Studio 5.0 ToDo Manager Extension

                                1 Reply Last reply
                                0
                                • C Chris Maunder

                                  Back in the Days of Yore we had a couple of small coding challenges such as the Lean and Mean comp. I was thinking that there are a ton of small, well defined problems that can be tackled a zillion ways in a zillion languages and that it would be cool to see what you guys can come up with. I'd like to start the ball rolling with the following simple task: Problem: Given a string of text, trim from each end of the text each all occurrences of a given set of strings Sample input: Input string: "dog cat monkey dog horse dog" Strings that need to be trimmed from each end: { "dog", "cat" } Final output should be: " monkey dog horse" Final output should be " cat monkey dog horse " [Edit: My final sample output was incorrect, so to be fair I'll accept either answer] It's up to you whether you worry about case sensitivity. Let's see who can provide the smallest, neatest most elegant, most unique and/or fastest code. For those who feel like jumping on the "No Programming questions" bandwagon, please re-read the lounge guidelines. The point of this is to have fun, not to solve each other's programming issues.

                                  cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                                  A Offline
                                  A Offline
                                  Alberto Bar Noy
                                  wrote on last edited by
                                  #19

                                  Chris barely posted and already there is a design review, rejects from marketing, the devs want to shoot the PM. The PM is whistling nastily (Nagy you dog ... cat... horse... dog) and the mischievous ones reach for the assembler books. What we miss here is QA and we can start a death-march :laugh: EDIT-------------------------- I forgot legal as well. Legal department share its thoughts here with the assistance of the tech writers ;P

                                  Alberto Bar-Noy --------------- “The city’s central computer told you? R2D2, you know better than to trust a strange computer!” (C3PO)

                                  N J B 3 Replies Last reply
                                  0
                                  • D Dalek Dave

                                    I bet he is wishing he never asked the damn question now! :)

                                    ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                                    N Offline
                                    N Offline
                                    NormDroid
                                    wrote on last edited by
                                    #20

                                    Maybe he's stuck and it's a cleverly disguised homework question.

                                    Software Kinetics Wear a hard hat it's under construction
                                    Metro RSS

                                    D 1 Reply Last reply
                                    0
                                    • P PIEBALDconsult

                                      No, it means "one or the other".

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

                                      You can think it means whatever you want, but in correct English usage either can mean both 'one of two' or 'each of two.

                                      Every man can tell how many goats or sheep he possesses, but not how many friends.

                                      H P 2 Replies Last reply
                                      0
                                      • N NormDroid

                                        Maybe he's stuck and it's a cleverly disguised homework question.

                                        Software Kinetics Wear a hard hat it's under construction
                                        Metro RSS

                                        D Offline
                                        D Offline
                                        Dalek Dave
                                        wrote on last edited by
                                        #22

                                        :thumbsup: :laugh:

                                        ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                                        1 Reply Last reply
                                        0
                                        • C CPallini

                                          Hey Chris, may I post my own programming issue labeling it with 'Coding Challenge' or 'Fun For Everyone'? Just Kidding! Sorry for my poor understanding of English, with

                                          Chris Maunder wrote:

                                          from either end

                                          Do you mean the output string should be:

                                          " monkey dog horse "

                                          ?

                                          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                                          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                                          [My articles]

                                          D Offline
                                          D Offline
                                          Dalek Dave
                                          wrote on last edited by
                                          #23

                                          I am just glad he wants a Monkey Dog Horse and not one of these[^].

                                          ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                                          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