diff options
| author | Ysmael Ebreo <Ysmael.Ebreo@latticesemi.com> | 2020-08-29 00:11:30 +0800 |
|---|---|---|
| committer | Ysmael Ebreo <Ysmael.Ebreo@latticesemi.com> | 2020-08-29 00:11:30 +0800 |
| commit | 042a69bc0aabb2d569a4ac40590d721c5bd43da6 (patch) | |
| tree | 6ce0ac48d80ce95aaaaa0f715350e46548c76321 /challenge-074 | |
| parent | 4e01dc493388e093a1b638b3001eb17fa86a16e0 (diff) | |
| download | perlweeklychallenge-club-042a69bc0aabb2d569a4ac40590d721c5bd43da6.tar.gz perlweeklychallenge-club-042a69bc0aabb2d569a4ac40590d721c5bd43da6.tar.bz2 perlweeklychallenge-club-042a69bc0aabb2d569a4ac40590d721c5bd43da6.zip | |
Solution for ch#74
Diffstat (limited to 'challenge-074')
| -rw-r--r-- | challenge-074/yet-ebreo/perl/ch-1.pl | 12 | ||||
| -rw-r--r-- | challenge-074/yet-ebreo/perl/ch-2.pl | 13 |
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 |
