Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Friday Golf: All 2-digit combinations (wrong!)

by BrowserUk (Pope)
on Sep 26, 2003 at 13:04 UTC ( #294399=note: print w/ replies, xml ) Need Help??


in reply to Friday Golf: All 2-digit combinations

Update: Both attempts in this node are bogus!!

46?

$n='00';$s!~/$n/and$s.=$n while$n++<99;print$s
123456789 123456789 123456789 123456789 123456789

45

$n='00';$s!~$n and$s.=$n while$n++<99;print$s
123456789 123456789 123456789 123456789 123456789


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.


Comment on Re: Friday Golf: All 2-digit combinations (wrong!)
Re: Re: Friday Golf: All 2-digit combinations
by PodMaster (Abbot) on Sep 26, 2003 at 13:20 UTC
    44 if you die ;) why won't you die??? lol

    I do realize that the line number may not be wanted, but I just couldn't resist ;D

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Re: Friday Golf: All 2-digit combinations
by Chady (Priest) on Sep 26, 2003 at 13:21 UTC
    40.
    $n='00';/$n/ or$_.=$n while$n++<99;print
    123456789 123456789 123456789 123456789

    Update: your code still displays some bad entries. see below

    010203040506070809111213141516171819222324252627282933343536...etc.
    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
Re: Re: Friday Golf: (I think I got it *this* time)
by BrowserUk (Pope) on Sep 26, 2003 at 13:59 UTC

    62? (Does anyone have a neat one liner for verifying this? trying to check the results is doing my eyes in:)

    $_=$n='00';/$n/ or$_.=$n and s/(.)\1\1/$1$1/while$n++<99;print
    123456789 123456789 123456789 123456789 123456789 123456789 123

    58!
    $_=$n='00';/$n/ or$_.=$n,s/(.)(?=\1\1)//while$n++<99;print
    123456789 123456789 123456789 123456789 123456789 123456789 123


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

      I believe that is the first correct solution! Congratulations, let the ++'s flow!

      See my original post for the checker.

      Congratz! Though, I think your algorithm works only because of a peculiarity in 00..99. If you extend it to 000..999, your algorithm doesn't scale, while mine does. :-)

      ------
      We are the carpenters and bricklayers of the Information Age.

      The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://294399]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-08-21 18:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (141 votes), past polls