aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-08-28 17:22:08 +0100
committerGitHub <noreply@github.com>2020-08-28 17:22:08 +0100
commit7819fc1da60ba6ad50d161a489bf7510e8f3feb7 (patch)
tree1a51ce262d171e9e0a54951b19e06aa5838d1cc9
parent8c21cbde5ace7619765ac6e7240cfd6edfc0ae48 (diff)
parent042a69bc0aabb2d569a4ac40590d721c5bd43da6 (diff)
downloadperlweeklychallenge-club-7819fc1da60ba6ad50d161a489bf7510e8f3feb7.tar.gz
perlweeklychallenge-club-7819fc1da60ba6ad50d161a489bf7510e8f3feb7.tar.bz2
perlweeklychallenge-club-7819fc1da60ba6ad50d161a489bf7510e8f3feb7.zip
Merge pull request #2163 from Doomtrain14/master
Solution for ch#74
-rw-r--r--challenge-074/yet-ebreo/perl/ch-1.pl12
-rw-r--r--challenge-074/yet-ebreo/perl/ch-2.pl13
2 files changed, 25 insertions, 0 deletions
diff --git a/challenge-074/yet-ebreo/perl/ch-1.pl b/challenge-074/yet-ebreo/perl/ch-1.pl
new file mode 100644
index 0000000000..7e2dc4c342
--- /dev/null
+++ b/challenge-074/yet-ebreo/perl/ch-1.pl
@@ -0,0 +1,12 @@
+#! /usr/bin/perl
+use strict;
+use feature 'say';
+
+my @list = (1, 3, 1, 2, 4, 5);
+my %h;
+
+$h{$_}++ for @list;
+
+my $r = (sort { $h{$b}-$h{$a} } keys %h)[0];
+
+print ( ($h{$r}> @list/2) ? $r : -1 ) \ No newline at end of file
diff --git a/challenge-074/yet-ebreo/perl/ch-2.pl b/challenge-074/yet-ebreo/perl/ch-2.pl
new file mode 100644
index 0000000000..01b4ad6b01
--- /dev/null
+++ b/challenge-074/yet-ebreo/perl/ch-2.pl
@@ -0,0 +1,13 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use feature 'say';
+
+
+my $p;
+for my $c (($ARGV[0] || "ababc") =~ /./g) {
+ $p .= $c;
+ 1 while $p=~s/(.)(.*)\1/$2/;
+ print ((substr $p,-1) || "#");
+
+} \ No newline at end of file