in reply to Golf/Perlish solution to this problem?
here is my solution (hopefully i haven't overseen something...):
in: 1 2 3 4 5 6 7 8 9 10 11 12
out: 12 1 2 11 10 3 4 9 8 5 6 7
prints:#!/usr/bin/perl use strict; use warnings; my @in = (1 .. 12); my @out = reverse @in[$#in / 2 + 1 .. $#in]; splice @out, $_ * 2 - (($_ % 2) ? 1 : 2), 0, $_ for (@in[0 .. $#in / 2 +]); print "in: \t@in\n"; print "out: \t@out\n";
in: 1 2 3 4 5 6 7 8 9 10 11 12
out: 12 1 2 11 10 3 4 9 8 5 6 7
bye
update 1: corrected the code and added the output
|
---|
In Section
Seekers of Perl Wisdom