Another round of TIMTOWTDI/golf :)
Printing 1..10 was simple, but counting backwards from 10 to 1 is a bit harder, because the .. list operator can't do that. It's even harder when you can't use reverse *evil grin*
(And an extra bonus if you're able to do it without \w characters ;))
My try:
perl -le'$b=ord "\cJ"; $a++ == ord "\cJ" && die, print $b-- while 1'
perl -le'$b=ord "\cJ"; $a++ == ord "\cJ" && die, print $b-- while "foo"'
Update - chipmunk correctly pointed out that I didn't follow my own rules... Oops! :)
Printing 1..10 was simple, but counting backwards from 10 to 1 is a bit harder, because the .. list operator can't do that. It's even harder when you can't use reverse *evil grin*
-
The rules:
- No \w characters
-
The rules:
- No numbers (no \d characters)
- No use of reverse
- No modules
- Pure Perl
(And an extra bonus if you're able to do it without \w characters ;))
My try:
perl -le'$b=ord "\cJ"; $a++ == ord "\cJ" && die, print $b-- while "foo"'
Update - chipmunk correctly pointed out that I didn't follow my own rules... Oops! :)
Back to
Meditations