I was assigned a simple program to write in C++: Make a program that takes an integer and tells whether each digit is odd or even. So, I started messing around in Perl, rather than doing the assignment (naturally). This is the shortest solution I came up with. Any suggestions for improvement?
(66 chars)
chop($_=<>);s/([13579])/$1: odd\n/g;s/([02468])/$1: even\n/g;print
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: shortest
by Jeff Connelly (Acolyte) on Sep 17, 2000 at 06:36 UTC | |
by kudra (Vicar) on Sep 18, 2000 at 20:08 UTC | |
RE: shortest
by turnstep (Parson) on Sep 17, 2000 at 07:31 UTC | |
RE: shortest
by myocom (Deacon) on Sep 16, 2000 at 08:59 UTC | |
RE: shortest
by indigo (Scribe) on Sep 19, 2000 at 03:28 UTC | |
RE: shortest
by Adam (Vicar) on Sep 16, 2000 at 21:41 UTC | |
by myocom (Deacon) on Sep 17, 2000 at 02:50 UTC | |
by Adam (Vicar) on Sep 18, 2000 at 19:36 UTC |
Back to
Obfuscated Code