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

Golfing dubstep.pl

by perlaintdead (Scribe)
on Sep 02, 2013 at 20:33 UTC ( #1051979=perlmeditation: print w/ replies, xml ) Need Help??

I'm pretty new to golf but this is the best i could do. I would like to see how you would fit this is fewer chars I'm sure theres one way or an other.

use Time::HiRes 'usleep';$|=1;for(;;){$_=(int rand 9)/2;if(/\.5/){prin +t"wub "}else{print"wooo "}usleep 100000}

thanks.

Comment on Golfing dubstep.pl
Download Code
Re: Golfing dubstep.pl
by toolic (Bishop) on Sep 02, 2013 at 21:15 UTC

      after research this has by far the weirdest operator i've seen

      86
      1 2 3 4 5 6 + 7 8 12345678901234567890123456789012345678901234567890123456789012345 +678901234567890123456 perl -e'use Time::HiRes"usleep";$|=1;{print+(int rand 9)%2?"wub ":"woo +o ";usleep 1e5;redo}'
      Update: Or even 69:
      perl -e'$|=1;{print+(int rand 9)%2?"wub ":"wooo ";select$u,$u,$u,.1;re +do}'
      Update: 64, thanks hdb:
      perl -e'$|=1;{print rand(9)%2?"wub ":"wooo ";select$u,$u,$u,.1;redo}' 1 2 3 4 5 6 1234567890123456789012345678901234567890123456789012345678901234
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        int is not needed.



        Doesn't catch the first "w" but here is a slight variation.

        select$u,$u,$u,.1while$|=print rand>5/9?ub:ooo,$".w
Re: Golfing dubstep.pl
by hdb (Prior) on Sep 03, 2013 at 06:36 UTC

    58 (credit to all entries above!). I hope I got the probability correct...

    1 2 3 4 5 6 123456789012345678901234567890123456789012345678901234567890 perl -e'select$u,$u,$u,.1while$|=print+rand>5/9?"wub ":"wooo "'

    Update: If you are happy to accept hyphens rather than blanks, we can save for more characters, see Re: Why is this auto-quoted?

    1 2 3 4 5 6 123456789012345678901234567890123456789012345678901234567890 perl -e'select$u,$u,$u,.1while$|=print+rand>5/9?-wub:-wooo'
      Nice. Shortened to 55:
      1 2 3 4 5 1234567890123456789012345678901234567890123456789012345 perl -e'select$u,$u,$u,.1while$|=print rand>5/9?wub:wooo,$"'
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        Phantastic! I never see all the potential of the special variables. If one is allowed to first print a blank, one can shorten it by another character...



Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2015-05-27 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (521 votes), past polls