aboutsummaryrefslogtreecommitdiff
path: root/challenge-026
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-09-19 11:08:13 +0100
committerGitHub <noreply@github.com>2019-09-19 11:08:13 +0100
commitbd803b1a2481c1246aec72bc209b7f0c681d39b3 (patch)
tree824597959f9e29a7dd3a40a35d7421f6b6e03b97 /challenge-026
parenta99f6f3aabcade0129194f819c6af4831317703a (diff)
parentf6cc983e566f206f59f459f3dc6e241771882f8b (diff)
downloadperlweeklychallenge-club-bd803b1a2481c1246aec72bc209b7f0c681d39b3.tar.gz
perlweeklychallenge-club-bd803b1a2481c1246aec72bc209b7f0c681d39b3.tar.bz2
perlweeklychallenge-club-bd803b1a2481c1246aec72bc209b7f0c681d39b3.zip
Merge pull request #644 from Doomtrain14/master
Added perl6 solutions
Diffstat (limited to 'challenge-026')
-rw-r--r--challenge-026/yet-ebreo/perl5/ch-2.pl2
-rw-r--r--challenge-026/yet-ebreo/perl6/ch-1.p615
-rw-r--r--challenge-026/yet-ebreo/perl6/ch-2.p614
3 files changed, 30 insertions, 1 deletions
diff --git a/challenge-026/yet-ebreo/perl5/ch-2.pl b/challenge-026/yet-ebreo/perl5/ch-2.pl
index 6522d08534..8203324e9f 100644
--- a/challenge-026/yet-ebreo/perl5/ch-2.pl
+++ b/challenge-026/yet-ebreo/perl5/ch-2.pl
@@ -9,7 +9,7 @@ use v5.10;
use Math::Trig;
die "Usage:\n\tch-2.pl <angle1> .. <anglen>\n\n" if !@ARGV;
-die "Only numbers are allowed as input\n" if "@ARGV"=~/[^0-9 ]/;
+die "Only numbers are allowed as input\n" if grep !/^[-+]?\d+$/, @ARGV;
my ($y_comp,$x_comp) = 0;
$y_comp+=sin deg2rad($_),$x_comp+=cos deg2rad($_) for @ARGV;
diff --git a/challenge-026/yet-ebreo/perl6/ch-1.p6 b/challenge-026/yet-ebreo/perl6/ch-1.p6
new file mode 100644
index 0000000000..b88ed72660
--- /dev/null
+++ b/challenge-026/yet-ebreo/perl6/ch-1.p6
@@ -0,0 +1,15 @@
+# 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 (
+ Str $string1, #= String to represent "stones"
+ Str $string2 #= String to represent "jewels"
+){
+ if ($string1~$string2 ~~ /<-[A .. Za .. z]>/) {
+ say "Only A-Z and a-z characters are allowed\n";
+ } else {
+ say ($string2.chars-$string2.trans( $string1 => "").chars);
+ }
+} \ No newline at end of file
diff --git a/challenge-026/yet-ebreo/perl6/ch-2.p6 b/challenge-026/yet-ebreo/perl6/ch-2.p6
new file mode 100644
index 0000000000..d63ede9e6a
--- /dev/null
+++ b/challenge-026/yet-ebreo/perl6/ch-2.p6
@@ -0,0 +1,14 @@
+# Create a script that prints mean angles of the given list of angles in degrees.
+# Please read wiki(https://en.wikipedia.org/wiki/Mean_of_circular_quantities) page
+# that explains the formula in details with an example.
+
+sub MAIN (
+ *@angles #= Angle(s) in degrees
+){
+ my ($x,$y) = (0,0);
+ for @angles -> $r {
+ $y += sin($r*π/180);
+ $x += cos($r*π/180)
+ }
+ say atan2($y,$x)*180/π
+} \ No newline at end of file