Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

TMTOWTDI the new year!

by giulienk (Curate)
on Dec 23, 2001 at 08:34 UTC ( [id://134018]=perlmeditation: print w/replies, xml ) Need Help??

I was at the club tonight when i saw a manifest for a new year party. So the quest materialized in my mind: printing "2002" without using numbers. Everything else is allowed. A special premium goes to the one who Golf it. Special mention to the most OBFU one. Here two samples (it's 4:29 in the morning, so i don't have anything better):
print $^F.$|.$[.$^F; #the simpler way #a more mathematical approach print $^F**(++$_.$_)-$=+$^F**$^F**$^F-$^F;
Happy new year ;)

gkinueliileunikg

Replies are listed 'Best First'.
Re: TMTOWTDI the new year!
by wog (Curate) on Dec 23, 2001 at 09:03 UTC

    Golf:

    # ASCII specific print"SQQS"^"aaaa" #23456789012345678 # 1

    update: If we don't care about strict we can do:

    print+SQQS^aaaa #23456789012345 # 1

    Not golfing:

    use LWP::Simple; print get("http://perlmonks.org/?node=TMTOWTDI+the+new+year!") =~ /printing "(\d+)"/; # or print y/a// for qw(aa bb bb aa); # or

    update: Oops. I didn't type kill in here orginally:

    print kill($$-$$,@$_) for [$$,$$], [], [], [$$,$$]; # or use Fcntl qw(:seek); print SEEK_END, SEEK_SET, SEEK_SET, SEEK_END; # or $_ = "weirdness"; print y ueuu, y fuff, y sfss, y esee;
Re: TMTOWTDI the new year!
by japh (Friar) on Dec 23, 2001 at 15:14 UTC
    my first publicly-posted perl obfuscation.
    #!/usr/bin/perl -l print bulldozer_(" _ _ | two _ __ ___ _ __| |_ __ ___ ___ _ __ | | _____ | | '_ \ / _ \ '__| | '_ ` _ \ / _ \| '_ \| |/ / __| | thousand | |_) | __/ | | | | | | | | (_) | | | | <\__ \ | | .__/ \___|_| |_|_| |_| |_|\___/|_| |_|_|\_\___/ | two |_| ") ;sub#marine) bulldozer_{ #"=. $_ = length shift; $_ --+$_ --+$_ --+$_ --+$_ --+$_ --+$_ }#_bulldozer
    Update: spoiler

    A string (the 2002 banner) constructed with figlet and vi is passed to a function named bulldozer_, which takes the length of it and repeatedly adds that number to itself while decrementing it by 1 each time. The result of this construct is passed back to the original print statement.

Re (tilly) 1: TMTOWTDI the new year!
by tilly (Archbishop) on Dec 23, 2001 at 12:27 UTC
    Use the CPAN. Acme::Smirch is your friend.
    $==$';$;||$.|$|;$_='*$(^@(%_+&);@-);~~,.*+,./|);;;~~@-;#~~;#@-;#@-;#~~ +@-__&$#%^';$__='`'&'&';$___="````"|"$[`$["|'`%",';$~=("$___$__-$[``$_ +_"|"$___"|("$___$__-$[.%")).("'`"|"'$["|"'#").'/.*?&([^&]*)&.*/$'.++$ +=.("/``"|"/$[`"|"/#'").(";`/[\\`\\`$__]//`;"|";$[/[\\$[\\`$__]//`;"|" +;#/[\\\$\\.$__]//'").'@:=("@-","/.","~~",";#",";;",";.",",.",");","() +","*+","__","-(","/@",".%","/|",";_");@:{@:}=$%..$#:;'.('`'|"$["|'#') +."/(..)(..)/".("```"|"``$["|'#("').'(($:{$'.$=.'}<<'.(++$=+$=).')|($: +{$'.$=.'}))/'.("```;"|"``$[;"|"%'#;").("````'$__"|"%$[``"|"%&!,").${$ +[};`$~$__>&$=`;
    UPDATE
    I should puncuate this with the somewhat symmetrical:
    print --$|+$|.$?.$?,$?.$?.$|+$|--
      Did someone say symmetrical?
      print !$!+!$!.$$*-$-.-$-*$$.!$!+!$!
      andy.
Re: TMTOWTDI the new year!
by Albannach (Monsignor) on Dec 23, 2001 at 10:14 UTC
    Golf:
    # 1 2 #2345678901234567890 print"$^F$[$[$^F"
    Of course die would be cheaper but I'll assume we ONLY want "2002" ;-)
    Geesh, how unoriginal! I should really read the entire root node before posting the first thing that comes to mind!

    Silly, and for a limited time only:

    @foo = split' ',scalar localtime; $bar = pop @foo; print ++$bar;

    --
    I'd like to be able to assign to an luser

Re: TMTOWTDI the new year!
by giulienk (Curate) on Dec 23, 2001 at 20:19 UTC
    With a fresh mind (and some luck) I got this new cool one:$;+=ord for(split'','MerryXMAS&&HappyNEWYEAR!');print$;


    Update: the following looks betterprint eval join'+',map{ord}split'','MerryXMAS&&HappyNEWYEAR!'

    gkinueliileunikg

      Very nice! Maybe put the greeting first?:
      $_= "MerryXMAS&&HappyNEWYEAR!"; s/./"+".ord$&/ge; print eval,$/


        p
Re: TMTOWTDI the new year!
by gmax (Abbot) on Dec 31, 2001 at 18:48 UTC
    I hope it isn't too late for my contribution.
    Nothing special. Just to wish you all a pleasant new year.
    perl -e '$_=sprintf("%d",pack "H*",b).unpack "H*",b;m/\d$/;$b=$&;m/^\d +/;print "$b$&$&$b$/"' perl -e '$a=unpack("H*",d)-unpack "H*",b;$b=sprintf"%d",pack"H*",b;pri +nt "$a$b$b$a$/"' perl -e '$b=$a=ord(b)-ord(a);print++$a,--$b,$b,$a,$/' perl -e '$a=@{[a,b]};$b=@{[]}; print "$a$b$b$a$/"' perl -e '($a=$%)++;print ++$a,$%,$%,$a,$/'
    Cheers
    _ _ _ _ (_|| | |(_|>< _|
Re: TMTOWTDI the new year!
by Juerd (Abbot) on Dec 23, 2001 at 18:21 UTC
    "Happy new year" in many languages :)
    Note: This is a double obfuscation, as eval() doesn't get any number too (hint: s/eval/print/...
    This script needs support for named characters in Perl.
    #!/usr/bin/perl -l eval join "", map { chomp && chr length } <DATA>
Re: TMTOWTDI the new year!
by mrbbking (Hermit) on Dec 23, 2001 at 21:23 UTC
    Leaving golf and obfuscation to those more suited to the task, I'll go for simplicity...
    print length(' '),length(''); print length(''),length(' ');
Re: TMTOWTDI the new year!
by andye (Curate) on Dec 23, 2001 at 22:18 UTC
    Just being silly now...
    print tr/w//<<!$, for qw(two thousand and two)
    andy.
Re: TMTOWTDI the new year!
by japh (Friar) on Dec 31, 2001 at 13:36 UTC
    I bred these critters (composed of 4 flavors of gene) overnight using a modified version of gumpu's code at Genetic Programming or breeding Perls. They're 24 genes long because I was going to obfuscate a map of them in a string the same length as "Just Another Perl Hacker" but the new year is almost upon us :)
    perl -le '$_+=$_++;$_+=--$_;$_+=$_--;$_+=++$_;$_+=$_++;$_+=$_--;$_+=$_ +--;$_+=--$_;$_+=$_--;$_+=$_++;$_+=++$_;$_+=++$_;$_+=--$_;$_+=$_--;$_+ +=--$_;$_+=$_++;$_+=$_--;$_+=--$_;$_+=$_--;$_+=$_--;$_+=$_++;$_+=--$_; +$_+=++$_;$_+=--$_;print' perl -le '$_+=$_--;$_+=$_++;$_+=++$_;$_+=$_++;$_+=$_--;$_+=--$_;$_+=$_ +--;$_+=$_++;$_+=$_++;$_+=++$_;$_+=$_++;$_+=--$_;$_+=++$_;$_+=--$_;$_+ +=$_--;$_+=++$_;$_+=$_--;$_+=$_++;$_+=$_--;$_+=++$_;$_+=++$_;$_+=++$_; +$_+=--$_;$_+=--$_;print' perl -le '$_+=$_--;$_+=++$_;$_+=$_--;$_+=$_++;$_+=++$_;$_+=$_++;$_+=-- +$_;$_+=$_--;$_+=++$_;$_+=$_--;$_+=++$_;$_+=$_++;$_+=$_--;$_+=$_++;$_+ +=$_--;$_+=--$_;$_+=$_--;$_+=$_++;$_+=$_++;$_+=$_++;$_+=--$_;$_+=--$_; +$_+=--$_;$_+=--$_;print' perl -le '$_+=$_--;$_+=++$_;$_+=$_--;$_+=++$_;$_+=$_++;$_+=--$_;$_+=$_ +++;$_+=$_--;$_+=--$_;$_+=$_--;$_+=++$_;$_+=++$_;$_+=--$_;$_+=$_--;$_+ +=$_--;$_+=$_--;$_+=$_--;$_+=--$_;$_+=$_--;$_+=--$_;$_+=++$_;$_+=$_--; +$_+=++$_;$_+=++$_;print'
    The four arbitrary gene types allow for 2002-printing critters of length ten:
    perl -le '$_+=++$_;$_+=++$_;$_+=++$_;$_+=++$_;$_+=$_++;$_+=++$_;$_+=++ +$_;$_+=++$_;$_+=--$_;$_+=--$_;print'
Re: TMTOWTDI the new year!
by toma (Vicar) on Dec 24, 2001 at 12:30 UTC
    Not golf or obfu, but 2002 is an interesting number!
    perl -e '$_++;print "$_$_"*ord("\a")*ord("\r")<<$_'

    It should work perfectly the first time! - toma

Re: TMTOWTDI the new year!
by petral (Curate) on Dec 24, 2001 at 23:22 UTC
Re: TMTOWTDI the new year!
by crazyinsomniac (Prior) on Dec 31, 2001 at 14:46 UTC
      Your submission is interesting but don't follow the rules given in the root node: no numbers. Anyway happy new year to crazyinsomniac too :)

      gkinueliileunikg

Re: TMTOWTDI the new year!
by Juerd (Abbot) on Mar 06, 2002 at 11:51 UTC
    Yeah, I know it's a bit late for a 2002-TIMTOWTDI, but I re-read this thread and i sort of got inspired by the critter-like code ($_+=$_-- etc), and created this late entry:

    $|++;$_="+++++[>++++++++++>++<<-]>.- -..++.>.";tr/-+,.[]<>//cd;for$a(qw%]} [while($p[$p]){ -$p[$p]-- +$p[$p]++ ,$p[$p]=ord(getc) .print(chr($p[$p])) <$p-- >$p++%){s/\Q${\ substr$a,"foo", $|}/${\substr$a,$|};/g}eval


    {grin}

    brainf*ck++

    ++ vs lbh qrpbqrq guvf hfvat n ge va Crey :)
    Nabgure bar vs lbh qvq fb jvgubhg ernqvat n znahny svefg.
    -- vs lbh hfrq OFQ pnrfne ;)
        - Whreq
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://134018]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (9)
As of 2024-04-23 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found