In light of the events last week, and to try to help bring life at the Monestary back to normal, here's a rather simple golf challenge:

Golf a sub that prints the following to STDOUT:

* * * * * *===============
 * * * * *                
* * * * * *===============
 * * * * *                
* * * * * *===============
 * * * * * 
* * * * * *===============

==========================

==========================

==========================
(That's 26x13 characters wide if you don't want to spend the time counting; and no, there's not 50 stars on this, but the idea is there :-) )Update No, this is not meant to be a political statement/prediction, or anything else along that nature; I just couldn't easily work in 50 stars into the ASCII art without distorting the image).

As a sort of added challenge, try to derive a unique approach, such as avoiding the use of the 'x' operator or the map function.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: (Golf) Patriotic Golf
by quent (Beadle) on Sep 18, 2001 at 01:31 UTC

    Well, I got one down to 66:

    $x=' *'x5;print$_%2?$_<1?$x:'':$_<1?"*$x".'='x15:'='x26,$/for-6..6 #23456789_123456789_123456789_123456789_123456789_123456789_123456

    But then I noticed suaveant's reworking of dragonchild's can be shaved to 65:

    print+(@s=('*'," *"x5,"="x15,$/)," *"x5,$/)x3,@s,($/,'='x26,$/)x3 #23456789_123456789_123456789_123456789_123456789_123456789_12345

    sigh

      ++ for simply bothering to figure out the mess of trinaries! :)

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

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Re: (Golf) Patriotic Golf
by chipmunk (Parson) on Sep 17, 2001 at 23:51 UTC
    use LWP::Simple;print+(get"http://perlmonks.org/?node=112874")=~/(\*.*?)</s 75 characters. Hehe!
      Ha, you better hope no one actually creates a node named 112874, like someone did with 847 (opposed to node_id=847)... Anyway, I chopped three chars off it like this.
      use LWP::Simple;print+(get"http://3467251276/?node=112874")=~/(\*.*?)< +/s

      -Blake

        If LWP::Simple is installed, GET should be too, so I make it in 51 chars. Oh, and I print to STDERR instead.
        die+(`GET "3467251276/?node=112874"`)=~/(\*.*?)</s

        _____________________________________________________
        Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
        s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

      Since it's frontpaged now, I can get that one down to 63. (The extra space is needed because somebody said "*BSD")
      use LWP::Simple;print+(get"http://perlmonks.org")=~/(\* .*?)</s
      update: it got knocked off the front page, so this won't work any more :-(

      -- MrNobo1024

      s]]HrLfbfe|EbBibmv]e|s}w}ciZx^RYhL}e^print

Re: (Golf) Patriotic Golf
by SparkeyG (Curate) on Sep 17, 2001 at 23:19 UTC
    @s=("\n","* "x6,"="x13,"\n"," *"x5)x3;@t=("\n","="x26,"\n")x3;print "@ +s@t";
    76 Characters.
    --SparkeyG
    (My first golf)

    Update: You're right it doesn't. Didn't notice that. Looks like the rest of you are taking what I made and running w/ it. *shrug*

      oooh, with some mods to yours...
      sub f{print(($/,"* "x5,'*',"="x15,$/," *"x5)x3,($/,"="x26,$/)x3)} 123456789_123456789_123456789_123456789_123456789_12345678
      58!

      and it prints the same as the example

                      - Ant
                      - Some of my best work - Fish Dinner

        Actually, it doesn't.
        @s=('*'," *"x5,"="x15,$/);print((@s," *"x5,$/)x3,@s,($/,'='x26,$/)x3)
        and that's a nice round 69! :)

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

        Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      I count you at 73 (congratz!), but I also don't think it gives what Masem asked for. Using your idea, I got me down to 87 chars:
      @s=('*',' *'x5,'='x15,"\n");@t=(' *'x5,"\n",@s)x3;@u=("\n",'='x26,"\n" +)x3;print@s,@t,@u

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

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      I think your code produces a picture that's a little bit different from the original question.

      Here's one at 83:

      @s=("*"," *"x5,"="x15,"\n");@p=((@s," *"x5,"\n")x3,@s,("\n",'='x26,"\n +")x3);print@p

      Looks like the rest of you are taking what I made and running w/ it.

      I think this would exemplify the core philosophy of the Free Software movement. i.e. Take a good idea and refine it.

Re: (Golf) Patriotic Golf
by suaveant (Parson) on Sep 17, 2001 at 22:32 UTC
    Here is my sad attempt, but it will get the ball rolling...
    sub f{push@f,(($_%2?'=':' ')x26,"\n")for(1..13);for$i(0..6){$f[$i*27+$ +_]=(($_+$i+1)%2?'*':' ')for(0..10)}print@f} 123456789_123456789_123456789_123456789_123456789_123456789_1234 +56789_123456789_123456789_123456789_123456
    106... ewww, but the first posted... hack away at it :)

    Update! Not to be outdone!

    sub f{@f=(('=')x26,$/,($")x26,$/)x6;for$i(0..7){$f[$i*27+$_]=(($_+$i+1 +)%2?'*':$")for(0..10)}print@f} 123456789_123456789_123456789_123456789_123456789_123456789_1234 +56789_123456789_123456789_123
    94!

    Update293... took out an accidental space

                    - Ant
                    - Some of my best work - Fish Dinner

Re: (Golf) Patriotic Golf
by dragonchild (Archbishop) on Sep 17, 2001 at 22:43 UTC
    Brute force is always a good place to start ... *winces at the horrible not-pun*
    $f='* 'x5;$e='='x15;$g='='x11;$h="$f*$e\n";$i=" $f\n$h";$c="$h$i$i$i\n +";$_=$c."$e$g\n\n"x3;print
    96 characters ... haven't looked at suaveant's try closely to see if there's a marriage yet...

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

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Re: (Golf) Patriotic Golf
by dga (Hermit) on Sep 17, 2001 at 23:11 UTC

    127 but uses no x or map

    $l="* * * * * *===============\n";$e=$b=$s=$l;$s=~y/*= / */;$b=~y/ */ +==/;$e=~y/*=/ /;$m=$l.$s;$f=$e.$b;print "$m$m$m$l$f$f$f";
Re: (Golf) Patriotic Golf
by patgas (Friar) on Sep 18, 2001 at 01:15 UTC

    Well, I was in the running there for a little while, but it looks like the really elegant solutions are coming out now, and I got left in the dust... But I worked on this all afternoon, so I'll contribute it anyway.

    I have it at 78 characters.

    sub f{ for((5)x3,0){print'*',' *'x5,'='x15,"\n ",'* 'x$_,"\n"}print+('='x26," +$/$/")x3 }

    Update: For those curious, here's another angle I was working on, at 81 characters:

    sub f { for(1..7){($d=$d?'':'='x15)&&print'*';print' *'x5,"$d\n"}print+($/.('= +'x26).$/)x3 }

    "We're experiencing some Godzilla-related turbulence..."

Re: (Golf) Patriotic Golf
by MrNobo1024 (Hermit) on Sep 18, 2001 at 05:26 UTC
    Here's one that's 66 characters:
    print+(' *'x5,'* 'x5 .'*'.'='x15,'='x26 .($,=$/))[101013222=~/./g]
    update: Got it down to 63:
    print+($_=' *'x5,"*$_".'='x15,($,=$/).'='x26)[1010101222=~/./g]

    -- MrNobo1024

    s]]HrLfbfe|EbBibmv]e|s}w}ciZx^RYhL}e^print

Re: (Golf) Patriotic Golf
by George_Sherston (Vicar) on Sep 18, 2001 at 02:50 UTC
    Without x or map I can only do 174. Perhaps this isn't even a golf, laid out thus:
    %h=( 0=>' *', 5=>' ', 20=>"\n", 21=>'* ', 26=>'*', 27=>'=', 42=>"\n", 43=>'=', 69=>"\n" ); sub f{$n=$h{$_}?$_:$n;print$h{$n}} f for 21..42; for(0..2){f for 0..42} for(0..2){f for 42..69}


    George Sherston
Re: (Golf) Patriotic Golf
by premchai21 (Curate) on Sep 18, 2001 at 05:35 UTC
    Not golf, but another approach. *n?x-dependent.
    bash-2.03$ perl 2>&1 use Filter::exec 'sh', '-c', 'cat >&2';* * * * * *=============== * * * * * * * * * * *=============== * * * * * * * * * * *=============== * * * * * * * * * * *=============== ========================== ========================== ==========================
Re: (Golf) Patriotic Golf
by demerphq (Chancellor) on Sep 24, 2001 at 01:18 UTC
    At 146 chars its not even in the running I know. But I thought I'd post it anyway.
    $_=unpack"B*",q;_⪐U*_⪐U';;%0=qw;001 JH 0000 AJA 0001 P +H 01 JA 1 PP;;$"="|";@0=keys%0;chop;s&\G(@0)&$0{$1}&ge;y;JAPH0; *=\n;d;prin +t
    :-)

    Yves
    --
    You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

      You guys are insane! I couldn't even come close to getting this node anywhere near 60 characters, but in the light of things mine is 101, for the 101st Airborne! HOAH!
      (who-a)adj. slang used by soldiers primarily airborne/rangers refering to anything and everything except no
      $p='#'x23;$b='#'x35;$s="* * * * * * $p\n";$f="* * * * * \n"; print"$s $f$s $f$s $f$s\n$b\n\n$b\n\n$b";

      softworkz