aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2023-04-19 10:32:04 +0100
committerPaulo Custodio <pauloscustodio@gmail.com>2023-04-19 10:32:04 +0100
commitf398fa99476c315f32fe774c4db7ec654b3d2db3 (patch)
tree59a77837017e27298066b4b4694d123d425e2108
parentbdfe0db0a9735b73e7e99ff50188290e08e1fab3 (diff)
downloadperlweeklychallenge-club-f398fa99476c315f32fe774c4db7ec654b3d2db3.tar.gz
perlweeklychallenge-club-f398fa99476c315f32fe774c4db7ec654b3d2db3.tar.bz2
perlweeklychallenge-club-f398fa99476c315f32fe774c4db7ec654b3d2db3.zip
Add Perl solution
-rw-r--r--challenge-213/paulo-custodio/Makefile2
-rw-r--r--challenge-213/paulo-custodio/perl/ch-1.pl32
-rw-r--r--challenge-213/paulo-custodio/t/test-1.yaml15
3 files changed, 49 insertions, 0 deletions
diff --git a/challenge-213/paulo-custodio/Makefile b/challenge-213/paulo-custodio/Makefile
new file mode 100644
index 0000000000..c3c762d746
--- /dev/null
+++ b/challenge-213/paulo-custodio/Makefile
@@ -0,0 +1,2 @@
+all:
+ perl ../../challenge-001/paulo-custodio/test.pl
diff --git a/challenge-213/paulo-custodio/perl/ch-1.pl b/challenge-213/paulo-custodio/perl/ch-1.pl
new file mode 100644
index 0000000000..ee4c2c7460
--- /dev/null
+++ b/challenge-213/paulo-custodio/perl/ch-1.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+# Challenge 213
+#
+# Task 1: Fun Sort
+# Submitted by: Mohammad S Anwar
+#
+# You are given a list of positive integers.
+#
+# Write a script to sort the all even integers first then all odds in
+# ascending order.
+# Example 1
+#
+# Input: @list = (1,2,3,4,5,6)
+# Output: (2,4,6,1,3,5)
+#
+# Example 2
+#
+# Input: @list = (1,2)
+# Output: (2,1)
+#
+# Example 3
+#
+# Input: @list = (1)
+# Output: (1)
+
+use Modern::Perl;
+
+my @even = sort {$a<=>$b} grep {$_%2==0} @ARGV;
+my @odd = sort {$a<=>$b} grep {$_%2!=0} @ARGV;
+my @result = (@even, @odd);
+say "@result";
diff --git a/challenge-213/paulo-custodio/t/test-1.yaml b/challenge-213/paulo-custodio/t/test-1.yaml
new file mode 100644
index 0000000000..11e5dad12e
--- /dev/null
+++ b/challenge-213/paulo-custodio/t/test-1.yaml
@@ -0,0 +1,15 @@
+- setup:
+ cleanup:
+ args: 1 2 3 4 5 6
+ input:
+ output: 2 4 6 1 3 5
+- setup:
+ cleanup:
+ args: 1 2
+ input:
+ output: 2 1
+- setup:
+ cleanup:
+ args: 1
+ input:
+ output: 1