### 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??

```@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/
```
```@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/
```
```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/'
```
```@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/
```
```@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/
```
```@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/

```
```@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/
```
```@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/
```
```@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/
```
```@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/
```
```@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/
```
```@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/
```
```@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/
```

Create A New User
Node Status?
node history
Node Type: note [id://849776]
help
Chatterbox?
and !@monks...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-05-27 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
World peace can best be achieved by:

Results (194 votes). Check out past polls.

Notices?