Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Code Golf: Four is magic

by thundergnat (Deacon)
on Jul 15, 2010 at 13:56 UTC ( #849776=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @p=(Thir,Four,Fif,Six,Seven,Eigh,Nine);@n=("\x8",One,Two,Three,Four,Fi
    +ve,@p[3..6],Ten,Eleven,Twelve,map$_.teen,@p);s/u//for@m=map$_.ty,Twen
    +,@p;$n[8].=t;sub n{$n=shift;$n?$n<20?$n[$n]:"$m[$n/10-2]-$n[$n%10]":Z
    +ero}$p+=<>;warn$m=n($p)," is ",$_=$p-4?n$p=()=$m=~/\w/g:magic,".\n"un
    +til/c/
    
  2. or download this
    @p=(Thir,Four,Fif,Six,Seven,Eigh,Nine);@n=("",One,Two,Three,Four,Five,
    +@p[3..6],Ten,Eleven,Twelve,map($_.teen,@p),map$_.ty,Twen,@p);$n[22]=~
    +s/u//;$n[8].=t;$_+=<>;print$z=$_?$_<20?$n[$_]:$n[$_/10+18].$n[$_%10]:
    +Zero," is ",$_=$_-4?length$z:magic,".\n"until/a/
    
  3. or download this
    perl -E'@p=(Thir,Four,Fif,Six,Seven,Eigh,Nine);@n=("",One,Two,Three,Fo
    +ur,Five,@p[3..6],Ten,Eleven,Twelve,map($_.teen,@p),map$_.ty,Twen,@p);
    +$n[22]=~s/u//;$n[8].=t;$_+=<>;say$z=$_?$_<20?$n[$_]:$n[$_/10+18].$n[$
    +_%10]:Zero," is ",$_=$_-4?length$z:magic,"."until/a/'
    
  4. or download this
    @u="0335443554366887798866555766"=~/./g;sub n{@p=(Thir,Four,Fif,Six,Se
    +ven,Eigh,Nine);@n=("",One,Two,Three,Four,Five,@p[3..6],Ten,Eleven,Twe
    +lve,map($_.teen,@p),map$_.ty,Twen,@p);$n[22]=~s/u//;$n[8].=t;shift()?
    +$_<20?$n[$_]:$n[$_/10+18].$n[$_%10]:Zero}$_=pop;print$z=n($_)," is ",
    +$_=$_-4?length$z:magic,".\n"while/\d/
    
  5. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{@p=(thir,four,fif,six,se
    +ven,eigh,nine);@n=('',one,two,three,four,five,@p[3..6],ten,eleven,twe
    +lve,map($_.teen,@p),twenty,map$_.ty,@p);$n[22]=~s/u//;$n[8].=t;shift(
    +)?$_<20?$n[$_]:$n[$_/10+18].$n[$_%10]:zero}$_=pop;print$z=n($_)," is 
    +",$_=$_-4?length$z:magic,".\n"while/\d/
    
  6. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{@p=(qw/thir four fif six
    + seven eigh nine/);@n=('',qw/one two three four five/,@p[3..6],qw/ten
    + eleven twelve/,map($_.'teen',@p),'twenty',map$_.'ty',@p);$n[22]=~s/u
    +//;$n[8].='t';shift()?$_<20?$n[$_]:$n[$_/10+18].$n[$_%10]:'zero'}$_=<
    +>;print$z=n($_)," is ",$_=$_-4?length$z:magic,".\n"while/\d/
    
    
  7. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{shift;@p=(qw/thir four f
    +if six seven eigh nine/);@n=('',qw/one two three four five/,@p[3..6],
    +qw/ten eleven twelve/,map($_.'teen',@p),'twenty',map$_.'ty',@p);$n[22
    +]=~s/u//;$n[8].='t';$t=$_?$_<20?$n[$_]:$n[$_/10+18].$n[$_%10]:'zero'}
    +$_=<>;print$z=n($_)," is ",$_=$_-4?length$z:magic,".\n"while/\d/
    
  8. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{shift;@p=(qw/thir four f
    +if six seven eigh nine/);@n=('',qw/one two three four five/,@p[3..6],
    +qw/ten eleven twelve/,map($_.'teen',@p),'twenty',map$_.'ty',@p);$n[22
    +]=~s/u//;$n[8].='t';$t=$_?$_<20?$n[$_]:$n[$_/10+18].$n[$_%10]:'zero'}
    +$_=<>;print n($_)," is ",$_=$_-4?length n($_):magic,".\n"while/\d/
    
  9. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{shift;@p=(qw/thir four f
    +if six seven eigh nine/);@n=('',qw/one two three four five/,@p[3..6],
    +qw/ten eleven twelve/,map($_.'teen',@p),'twenty',map$_.'ty',@p);$n[22
    +]=~s/u//;$n[8].='t';$t=$_?$_<20?$n[$_]:$n[$_/10+18].$n[$_%10]:'zero'}
    +$_=pop;print n($_)," is ",$_=$_-4?length n($_):magic,".\n"while/\d/
    
  10. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{shift;@p=(qw/thir four f
    +if six seven eigh nine/);@n=('',qw/one two three four five/,@p[3..6],
    +qw/ten eleven twelve/,map($_.'teen',@p),'twenty',map($_.'ty',@p);$n[2
    +2]=~s/u//;$n[8].='t';$t=$_?$_<20?$n[$_]:$n[$_/10+18].$n[$_%10]:'zero'
    +}$_=pop;print n($_)," is ",$_=$_-4?length n($_):magic,".\n"while/\d/
    
  11. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{shift;@p=(qw/thir four f
    +if six seven eigh nine/);@n=('',qw/one two three four five/,@p[3..6],
    +qw/ten eleven twelve/);push@n,$_.'teen'for@p;$p[1]=~s/u//;push@n,'twe
    +nty',;push@n,$_.'ty'for@p;$n[8].='t';$t=$_?$_<20?$n[$_]:$n[$_/10+18].
    +$n[$_%10]:'zero'}$_=pop;print n($_)," is ",$_=$_-4?length n($_):magic
    +,".\n"while/\d/
    
  12. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{shift;@p=(qw/thir four f
    +if six seven eigh nine/);@n=('',qw/one two three four five/,@p[3..6],
    +qw/ten eleven twelve/);push@n,$_.'teen'for@p;$p[1]=~s/u//;push@n,'twe
    +nty',;push@n,$_.'ty'for@p;$n[8].='t';$t=$_?$_<20?$n[$_]:$n[$_/10+18].
    +$n[$_%10]:'zero'}$_=pop;print n($_)," is ",$_=$_-4?$_<20?$u[$_]||4:$u
    +[chop]+$u[18+$_]:magic,".\n"while/\d/
    
  13. or download this
    @u='0335443554366887798866555766'=~/./g;sub n{shift;@p=(qw/thir four f
    +if six seven eigh nine/);@n=('',qw/one two three four five/,@p[3..6],
    +qw/ten eleven twelve/);push@n,$_.'teen'for@p;push@n,'twenty',;push@n,
    +$_.'ty'for@p;$n[8].='t';$n[22]=~s/u//;$t=$_?$_<20?$n[$_]:$n[$_/10+18]
    +.$n[$_%10]:'zero'}$_=pop;print n($_)," is ",$_=$_-4?$_<20?$u[$_]||4:$
    +u[chop]+$u[18+$_]:magic,".\n"while/\d/ 
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-04 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls