aboutsummaryrefslogtreecommitdiff
path: root/challenge-026
diff options
context:
space:
mode:
authorthreadless-screw <threadless-screw@mailbox.org>2019-09-21 16:09:44 +0200
committerthreadless-screw <threadless-screw@mailbox.org>2019-09-21 16:09:44 +0200
commit149b344eb3f530de016ba0b877f903d333608f71 (patch)
treea32d3e7a83d40bc22f4fd4fc30d26c973c5ca827 /challenge-026
parent542cbc759aa3991a370ff843bd1fc90a018a6817 (diff)
downloadperlweeklychallenge-club-149b344eb3f530de016ba0b877f903d333608f71.tar.gz
perlweeklychallenge-club-149b344eb3f530de016ba0b877f903d333608f71.tar.bz2
perlweeklychallenge-club-149b344eb3f530de016ba0b877f903d333608f71.zip
Solutions wk26
Diffstat (limited to 'challenge-026')
-rwxr-xr-xchallenge-026/ozzy/perl6/ch-1.p621
-rwxr-xr-xchallenge-026/ozzy/perl6/ch-2.p615
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-026/ozzy/perl6/ch-1.p6 b/challenge-026/ozzy/perl6/ch-1.p6
new file mode 100755
index 0000000000..1bfeb089f6
--- /dev/null
+++ b/challenge-026/ozzy/perl6/ch-1.p6
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl6
+
+# Create a script that accepts two strings, let us call it, “stones” and “jewels”.
+# It should print the count of “alphabet” from the string “stones” found in the string “jewels”.
+# For example, if your stones is “chancellor” and “jewels” is “chocolate”, then the script
+# should print “8”. To keep it simple, only A-Z,a-z characters are acceptable. Also make the
+# comparison case sensitive.
+
+
+sub MAIN ($string1 where { m/^<[a..z]>+$/ } , $string2 where { m/^<[a..z]>+$/ } ) {
+
+ say my @string1 = $string1.comb;
+ say my @string2 = $string2.comb;
+ my $count = 0;
+
+ for @string1 -> $i {
+ $count++ if @string2.grep: { $_ eq $i };
+ }
+
+ say $count;
+} \ No newline at end of file
diff --git a/challenge-026/ozzy/perl6/ch-2.p6 b/challenge-026/ozzy/perl6/ch-2.p6
new file mode 100755
index 0000000000..a6ec27e6a0
--- /dev/null
+++ b/challenge-026/ozzy/perl6/ch-2.p6
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl6
+
+# Script that prints the mean angle of a given list of
+# angles in degrees.
+
+sub MAIN (*@ang_deg where .elems > 0) {
+
+ my constant \deg2rad = (pi/180);
+ my constant \rad2deg = (180/pi);
+
+ my $y = [+] map { ($_ * deg2rad).sin }, @ang_deg;
+ my $x = [+] map { ($_ * deg2rad).cos }, @ang_deg;
+
+ printf "Mean angle = %.2f degrees\n", (atan2($y,$x) * rad2deg);
+} \ No newline at end of file