aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-10-16 17:32:41 +0100
committerGitHub <noreply@github.com>2022-10-16 17:32:41 +0100
commitcd25b24cf1849302c0349b4e5940abea99dd2c63 (patch)
tree60ed7dd16ccc14f902cd1b69c1d0ed9c49a45f15
parent8060a1bc4006c34884bd75cf7d35c0f6d631304d (diff)
parentf296a22e81b1ac8b8426d4271d61fe2ee5b4c02d (diff)
downloadperlweeklychallenge-club-cd25b24cf1849302c0349b4e5940abea99dd2c63.tar.gz
perlweeklychallenge-club-cd25b24cf1849302c0349b4e5940abea99dd2c63.tar.bz2
perlweeklychallenge-club-cd25b24cf1849302c0349b4e5940abea99dd2c63.zip
Merge pull request #6915 from adamcrussell/challenge-186
initial commit
-rw-r--r--challenge-186/adam-russell/blog.txt1
-rw-r--r--challenge-186/adam-russell/blog1.txt1
-rw-r--r--challenge-186/adam-russell/perl/ch-1.pl15
-rw-r--r--challenge-186/adam-russell/perl/ch-2.pl38
-rw-r--r--challenge-186/adam-russell/prolog/ch-1.p3
5 files changed, 58 insertions, 0 deletions
diff --git a/challenge-186/adam-russell/blog.txt b/challenge-186/adam-russell/blog.txt
new file mode 100644
index 0000000000..770a721c1b
--- /dev/null
+++ b/challenge-186/adam-russell/blog.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/perl/2022/10/16 \ No newline at end of file
diff --git a/challenge-186/adam-russell/blog1.txt b/challenge-186/adam-russell/blog1.txt
new file mode 100644
index 0000000000..6893e8e5cd
--- /dev/null
+++ b/challenge-186/adam-russell/blog1.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/prolog/2022/10/16 \ No newline at end of file
diff --git a/challenge-186/adam-russell/perl/ch-1.pl b/challenge-186/adam-russell/perl/ch-1.pl
new file mode 100644
index 0000000000..5564c6cf31
--- /dev/null
+++ b/challenge-186/adam-russell/perl/ch-1.pl
@@ -0,0 +1,15 @@
+use v5.36;
+use strict;
+use warnings;
+##
+# You are given two lists of the same size.
+# Create a subroutine sub zip() that merges the two lists.
+##
+sub zip($a, $b){
+ return map { $a->[$_], $b->[$_] } 0 .. @$a - 1;
+}
+
+MAIN:{
+ print join(", ", zip([qw/1 2 3/], [qw/a b c/])) . "\n";
+ print join(", ", zip([qw/a b c/], [qw/1 2 3/])) . "\n";
+} \ No newline at end of file
diff --git a/challenge-186/adam-russell/perl/ch-2.pl b/challenge-186/adam-russell/perl/ch-2.pl
new file mode 100644
index 0000000000..e3b75a756a
--- /dev/null
+++ b/challenge-186/adam-russell/perl/ch-2.pl
@@ -0,0 +1,38 @@
+use utf8;
+use v5.36;
+use strict;
+use warnings;
+##
+# You are given a string with possible unicode characters. Create a subroutine
+# sub makeover($str) that replace the unicode characters with their ascii equivalent.
+# For this task, let us assume the string only contains letters.
+##
+use Imager;
+use File::Temp q/tempfile/;
+use Image::OCR::Tesseract q/get_ocr/;
+
+use constant TEXT_SIZE => 30;
+use constant FONT => q#/usr/pkg/share/fonts/X11/TTF/Symbola.ttf#;
+
+sub makeover($s){
+ my $image = Imager->new(xsize => 100, ysize => 100);
+ my $temp = File::Temp->new(SUFFIX => q/.tiff/);
+ my $font = Imager::Font->new(file => FONT) or die "Cannot load " . FONT . " ", Imager->errstr;
+ $font->align(string => $s,
+ size => TEXT_SIZE,
+ color => q/white/,
+ x => $image->getwidth/2,
+ y => $image->getheight/2,
+ halign => q/center/,
+ valign => q/center/,
+ image => $image
+ );
+ $image->write(file => $temp) or die "Cannot save $temp", $image->errstr;
+ my $text = get_ocr($temp);
+ return $text;
+}
+
+
+MAIN:{
+ say makeover(q/ Ã Ê Í Ò Ù /);
+} \ No newline at end of file
diff --git a/challenge-186/adam-russell/prolog/ch-1.p b/challenge-186/adam-russell/prolog/ch-1.p
new file mode 100644
index 0000000000..28429c87a3
--- /dev/null
+++ b/challenge-186/adam-russell/prolog/ch-1.p
@@ -0,0 +1,3 @@
+zip([], [], []).
+zip([Ha|Ta], [Hb|Tb], [Ha, Hb|Tc]):-
+ zip(Ta, Tb, Tc). \ No newline at end of file