aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-197/james-smith/perl/ch-1.pl17
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-197/james-smith/perl/ch-1.pl b/challenge-197/james-smith/perl/ch-1.pl
new file mode 100644
index 0000000000..84b80e2164
--- /dev/null
+++ b/challenge-197/james-smith/perl/ch-1.pl
@@ -0,0 +1,17 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use feature qw(say);
+use Test::More;
+
+my @TESTS = (
+ [ [1,0,3,0,0,5], '1 3 5 0 0 0' ],
+ [ [1,6,4], '1 6 4' ],
+ [ [0,1,0,2,0], '1 2 0 0 0' ],
+ [ [(0,1) x 100 ], "@{[ (1)x 100, (0)x 100 ]}" ],
+);
+
+is( "@{[ move_zero(@{$_->[0]}) ]}", $_->[1] ) for @TESTS;
+
+sub move_zero{grep({$_}@_),grep{!$_}@_}