CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #6
    Join Date
    Nov 2002
    Location
    Sofia, Bulgaria
    Posts
    661

    Re: Coder speed challenge

    Quote Originally Posted by PeejAvery
    1234567 has a lot more prime numbers than you have for it. It should have...

    1 3 5 7 23 67 4567

    I guess that I am by your problem. What do you mean by split every way possible? The following finds all prime numbers possible by combinations (not rearranging the characters) of the string.
    ...
    Take another look at the problem and at the sample i/o By 'split' I meant a pure geometrical split. Inserting spaces in the appropriate places if you like

    1234567 can only be split in two ways
    1 2 3 4567
    and
    1 23 4567

    Any other way would either be not composed entirely of prime numbers or won't give the input number if you remove the spaces. Look at how 34 gives no output. It's because 34 is not prime and "3, 4" are not two prime numbers.

    <edit> and what TheCPUWizard said in his reply </edit>
    Last edited by SeventhStar; April 10th, 2007 at 01:50 PM.
    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured