From ef4abf511640753973a09531e3d6e4324d1b0d77 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 26 Dec 2022 14:34:43 +0000 Subject: Create ch-1.pl --- challenge-197/james-smith/perl/ch-1.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 challenge-197/james-smith/perl/ch-1.pl 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{!$_}@_} -- cgit