aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--challenge-001/paulo-custodio/go.pl20
-rw-r--r--challenge-001/paulo-custodio/untabify.pl1
-rw-r--r--challenge-029/paulo-custodio/Makefile2
-rw-r--r--challenge-029/paulo-custodio/README1
-rw-r--r--challenge-029/paulo-custodio/perl/ch-1.pl30
-rw-r--r--challenge-029/paulo-custodio/perl/ch-2.pl16
-rw-r--r--challenge-029/paulo-custodio/t/test-1.yaml22
-rw-r--r--challenge-029/paulo-custodio/t/test-2.yaml5
-rw-r--r--challenge-142/paulo-custodio/perl/ch-1.pl2
-rw-r--r--challenge-142/paulo-custodio/perl/ch-2.pl2
-rw-r--r--challenge-142/paulo-custodio/python/ch-1.py2
-rw-r--r--challenge-142/paulo-custodio/python/ch-2.py2
-rw-r--r--challenge-143/paulo-custodio/perl/ch-1.pl2
-rw-r--r--challenge-143/paulo-custodio/perl/ch-2.pl2
-rw-r--r--challenge-143/paulo-custodio/python/ch-1.py2
-rw-r--r--challenge-143/paulo-custodio/python/ch-2.py2
17 files changed, 99 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index ba8194b15c..040286b6c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,5 +19,8 @@ go.mod
go.sum
tags
+# Perl Inline module
+_Inline
+
# Rust languageoutput directory
target/
diff --git a/challenge-001/paulo-custodio/go.pl b/challenge-001/paulo-custodio/go.pl
index 5278fa551b..3904778b45 100644
--- a/challenge-001/paulo-custodio/go.pl
+++ b/challenge-001/paulo-custodio/go.pl
@@ -7,25 +7,11 @@ use Path::Tiny;
or die "Usage: ",path($0)->basename," nr\n";
my $nr = sprintf("%03d", $ARGV[0]);
-#for my $dir (qw(
-# ada
-# awk
-# basic
-# bc
-# brainfuck
-# c
-# cpp
-# d
-# forth
-# fortran
-# lua
-# pascal
-# perl
-# python
-# t
-# )) {
+path("challenge-$nr/paulo-custodio")->mkpath;
+#for my $dir (qw(ada awk basic bc brainfuck c cpp d forth fortran lua pascal perl python t)) {
# path("challenge-$nr/paulo-custodio/$dir")->mkpath;
#}
+
path("challenge-$nr/paulo-custodio/README")->spew("Solution by Paulo Custodio\n");
if (! -f "challenge-$nr/paulo-custodio/Makefile") {
path("challenge-$nr/paulo-custodio/Makefile")->spew(
diff --git a/challenge-001/paulo-custodio/untabify.pl b/challenge-001/paulo-custodio/untabify.pl
index 9f3c5657d4..dfdd1f1143 100644
--- a/challenge-001/paulo-custodio/untabify.pl
+++ b/challenge-001/paulo-custodio/untabify.pl
@@ -10,6 +10,7 @@ for my $dir (<challenge-*/paulo-custodio>) {
my $iter = path($dir)->iterator({recurse=>1});
while (defined(my $path = $iter->())) {
next unless $path->is_file;
+ next unless -T $path;
next if $path =~ /~$/; # temp files
my $ext = ""; $path->basename =~ /(\.\w+)$/ and $ext = $1;
next if $ext eq "" || $ext =~ /\.(exe|o|obj|ali|ads)$/; # binaries
diff --git a/challenge-029/paulo-custodio/Makefile b/challenge-029/paulo-custodio/Makefile
new file mode 100644
index 0000000000..c3c762d746
--- /dev/null
+++ b/challenge-029/paulo-custodio/Makefile
@@ -0,0 +1,2 @@
+all:
+ perl ../../challenge-001/paulo-custodio/test.pl
diff --git a/challenge-029/paulo-custodio/README b/challenge-029/paulo-custodio/README
new file mode 100644
index 0000000000..87dc0b2fbd
--- /dev/null
+++ b/challenge-029/paulo-custodio/README
@@ -0,0 +1 @@
+Solution by Paulo Custodio
diff --git a/challenge-029/paulo-custodio/perl/ch-1.pl b/challenge-029/paulo-custodio/perl/ch-1.pl
new file mode 100644
index 0000000000..606ec245cf
--- /dev/null
+++ b/challenge-029/paulo-custodio/perl/ch-1.pl
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+# Challenge 029
+
+# Task #1
+# Write a script to demonstrate brace expansion. For example, script would take
+# command line argument Perl {Daily,Weekly,Monthly,Yearly} Challenge and should
+# expand it and print like below:
+#
+# Perl Daily Challenge
+# Perl Weekly Challenge
+# Perl Monthly Challenge
+# Perl Yearly Challenge
+
+use Modern::Perl;
+
+sub print_expanded {
+ my($text) = @_;
+ if ($text =~ /[{]([^{}]*?)[}]/) {
+ my($before, $expand, $after) = ($`, $1, $');
+ for my $arg (split(/,/, $expand)) {
+ print_expanded($before.$arg.$after);
+ }
+ }
+ else {
+ say $text;
+ }
+}
+
+print_expanded("@ARGV");
diff --git a/challenge-029/paulo-custodio/perl/ch-2.pl b/challenge-029/paulo-custodio/perl/ch-2.pl
new file mode 100644
index 0000000000..c33fa95943
--- /dev/null
+++ b/challenge-029/paulo-custodio/perl/ch-2.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+# Challenge 029
+
+# Task #2
+# Write a script to demonstrate calling a C function. It could be any user
+# defined or standard C function.
+
+use Modern::Perl;
+use Inline C => <<'END';
+ int sum(int a, int b) {
+ return a+b;
+ }
+END
+
+say sum(@ARGV);
diff --git a/challenge-029/paulo-custodio/t/test-1.yaml b/challenge-029/paulo-custodio/t/test-1.yaml
new file mode 100644
index 0000000000..9caa126714
--- /dev/null
+++ b/challenge-029/paulo-custodio/t/test-1.yaml
@@ -0,0 +1,22 @@
+- setup:
+ cleanup:
+ args: "'Perl {Daily,Weekly,Monthly,Yearly} Challenge'"
+ input:
+ output: |
+ Perl Daily Challenge
+ Perl Weekly Challenge
+ Perl Monthly Challenge
+ Perl Yearly Challenge
+- setup:
+ cleanup:
+ args: "'a{b{1,2},c{3,4}}d'"
+ input:
+ output: |
+ ab1d
+ ac3d
+ ab1d
+ ac4d
+ ab2d
+ ac3d
+ ab2d
+ ac4d
diff --git a/challenge-029/paulo-custodio/t/test-2.yaml b/challenge-029/paulo-custodio/t/test-2.yaml
new file mode 100644
index 0000000000..45d285dccc
--- /dev/null
+++ b/challenge-029/paulo-custodio/t/test-2.yaml
@@ -0,0 +1,5 @@
+- setup:
+ cleanup:
+ args: 2 3
+ input:
+ output: 5
diff --git a/challenge-142/paulo-custodio/perl/ch-1.pl b/challenge-142/paulo-custodio/perl/ch-1.pl
index 76a8e19638..c29b6a64d8 100644
--- a/challenge-142/paulo-custodio/perl/ch-1.pl
+++ b/challenge-142/paulo-custodio/perl/ch-1.pl
@@ -1,5 +1,7 @@
#!/usr/bin/perl
+# Challenge 142
+#
# TASK #1 > Divisor Last Digit
# Submitted by: Mohammad S Anwar
# You are given positive integers, $m and $n.
diff --git a/challenge-142/paulo-custodio/perl/ch-2.pl b/challenge-142/paulo-custodio/perl/ch-2.pl
index 83160b0a28..a1da4960ff 100644
--- a/challenge-142/paulo-custodio/perl/ch-2.pl
+++ b/challenge-142/paulo-custodio/perl/ch-2.pl
@@ -1,5 +1,7 @@
#!/usr/bin/perl
+# Challenge 142
+#
# TASK #2 > Sleep Sort
# Submitted by: Adam Russell
# Another joke sort similar to JortSort suggested by champion Adam Russell.
diff --git a/challenge-142/paulo-custodio/python/ch-1.py b/challenge-142/paulo-custodio/python/ch-1.py
index d142b7d24f..99880d719a 100644
--- a/challenge-142/paulo-custodio/python/ch-1.py
+++ b/challenge-142/paulo-custodio/python/ch-1.py
@@ -1,5 +1,7 @@
#!/usr/bin/python3
+# Challenge 142
+#
# TASK #1 > Divisor Last Digit
# Submitted by: Mohammad S Anwar
# You are given positive integers, $m and $n.
diff --git a/challenge-142/paulo-custodio/python/ch-2.py b/challenge-142/paulo-custodio/python/ch-2.py
index 31f6f67abe..cd84d4b50d 100644
--- a/challenge-142/paulo-custodio/python/ch-2.py
+++ b/challenge-142/paulo-custodio/python/ch-2.py
@@ -1,5 +1,7 @@
#!/usr/bin/python3
+# Challenge 142
+#
# TASK #2 > Sleep Sort
# Submitted by: Adam Russell
# Another joke sort similar to JortSort suggested by champion Adam Russell.
diff --git a/challenge-143/paulo-custodio/perl/ch-1.pl b/challenge-143/paulo-custodio/perl/ch-1.pl
index 73a806191b..cd583324dc 100644
--- a/challenge-143/paulo-custodio/perl/ch-1.pl
+++ b/challenge-143/paulo-custodio/perl/ch-1.pl
@@ -1,5 +1,7 @@
#!/usr/bin/perl
+# Challenge 143
+#
# TASK #1 > Calculator
# Submitted by: Mohammad S Anwar
# You are given a string, $s, containing mathematical expression.
diff --git a/challenge-143/paulo-custodio/perl/ch-2.pl b/challenge-143/paulo-custodio/perl/ch-2.pl
index 9433cd520d..81a2ddc25f 100644
--- a/challenge-143/paulo-custodio/perl/ch-2.pl
+++ b/challenge-143/paulo-custodio/perl/ch-2.pl
@@ -1,5 +1,7 @@
#!/usr/bin/perl
+# Challenge 143
+#
# TASK #2 > Stealthy Number
# Submitted by: Mohammad S Anwar
# You are given a positive number, $n.
diff --git a/challenge-143/paulo-custodio/python/ch-1.py b/challenge-143/paulo-custodio/python/ch-1.py
index 7705a4eafe..1eafbbb75e 100644
--- a/challenge-143/paulo-custodio/python/ch-1.py
+++ b/challenge-143/paulo-custodio/python/ch-1.py
@@ -1,5 +1,7 @@
#!/usr/bin/python3
+# Challenge 143
+#
# TASK #1 > Calculator
# Submitted by: Mohammad S Anwar
# You are given a string, $s, containing mathematical expression.
diff --git a/challenge-143/paulo-custodio/python/ch-2.py b/challenge-143/paulo-custodio/python/ch-2.py
index 850ebfac33..6196e941a5 100644
--- a/challenge-143/paulo-custodio/python/ch-2.py
+++ b/challenge-143/paulo-custodio/python/ch-2.py
@@ -1,5 +1,7 @@
#!/usr/bin/python3
+# Challenge 143
+#
# TASK #2 > Stealthy Number
# Submitted by: Mohammad S Anwar
# You are given a positive number, $n.