aboutsummaryrefslogtreecommitdiff
path: root/challenge-059/mohammad-anwar/perl/ch-1a.pl
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-059/mohammad-anwar/perl/ch-1a.pl')
-rw-r--r--challenge-059/mohammad-anwar/perl/ch-1a.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-059/mohammad-anwar/perl/ch-1a.pl b/challenge-059/mohammad-anwar/perl/ch-1a.pl
new file mode 100644
index 0000000000..7be98d1233
--- /dev/null
+++ b/challenge-059/mohammad-anwar/perl/ch-1a.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+
+use Test::More;
+use Test::Deep;
+
+is_deeply( split_list([ 1, 4, 3, 2, 5, 2 ], 3), [ 1, 2, 2, 4, 3, 5 ]);
+
+done_testing;
+
+sub split_list {
+ my ($L, $K) = @_;
+
+ my $before = [];
+ my $after = [];
+ foreach my $i (@$L) {
+ if ($i < $K) {
+ push @$before, $i;
+ }
+ else {
+ push @$after, $i;
+ }
+ }
+
+ return [ @$before, @$after ];
+}