in reply to Golf/Perlish solution to this problem?
If you are golfing then
if it the divisible by 4 constraint wasn't present then a little more care is required@n = map { $n + 1 - $_, $_ } 1 .. $n / 2;
use integer; @n = map { $n + 1 - $_, $_ } 1 .. $n / 2; push @n, $n / 2 + 1 if $n % 2;
Update: As kindly pointed out by fellow monks I misread the specs. For the sake of completeness I give a correct (I hope) solution in the same vein as the previous offerings.
Unfortunately it's not as golfy but it is still cryptic looking;-)@n = map { $n + 2 - 2 * $_, 2 * $_ - 1, 2 * $_, $n + 1 - 2 * $_ } 1 .. + $n / 4;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Golf/Perlish solution to this problem?
by ikegami (Patriarch) on Jan 31, 2008 at 02:51 UTC | |
by hipowls (Curate) on Jan 31, 2008 at 03:10 UTC | |
Re^2: Golf/Perlish solution to this problem?
by GrandFather (Saint) on Jan 31, 2008 at 02:59 UTC | |
by tye (Sage) on Jan 31, 2008 at 06:40 UTC |
In Section
Seekers of Perl Wisdom