aboutsummaryrefslogtreecommitdiff
path: root/challenge-004
diff options
context:
space:
mode:
authorsergiotarxz <sergio.iglesias7890@gmail.com>2019-04-19 14:24:43 +0200
committersergiotarxz <sergio.iglesias7890@gmail.com>2019-04-19 14:24:43 +0200
commit735c6bb2ec38bfd0356c8f6d80a0ac5b3b533329 (patch)
tree3457c99c4596b35022d55881db043a2f3725874f /challenge-004
parent41a47bcbdec92efa3ba07168a95948058b98e424 (diff)
downloadperlweeklychallenge-club-735c6bb2ec38bfd0356c8f6d80a0ac5b3b533329.tar.gz
perlweeklychallenge-club-735c6bb2ec38bfd0356c8f6d80a0ac5b3b533329.tar.bz2
perlweeklychallenge-club-735c6bb2ec38bfd0356c8f6d80a0ac5b3b533329.zip
Solutions
Diffstat (limited to 'challenge-004')
-rw-r--r--challenge-004/sergiotarxz/perl5/ch-1.pl4
-rw-r--r--challenge-004/sergiotarxz/perl5/ch-2.pl30
2 files changed, 34 insertions, 0 deletions
diff --git a/challenge-004/sergiotarxz/perl5/ch-1.pl b/challenge-004/sergiotarxz/perl5/ch-1.pl
new file mode 100644
index 0000000000..e719612c7d
--- /dev/null
+++ b/challenge-004/sergiotarxz/perl5/ch-1.pl
@@ -0,0 +1,4 @@
+use Math::BigFloat;
+open$fh,'<',$0;
+$b+=scalar(split//,$_)while (<$fh>);
+print Math::BigFloat->bpi($b)."\n";
diff --git a/challenge-004/sergiotarxz/perl5/ch-2.pl b/challenge-004/sergiotarxz/perl5/ch-2.pl
new file mode 100644
index 0000000000..a168902ae6
--- /dev/null
+++ b/challenge-004/sergiotarxz/perl5/ch-2.pl
@@ -0,0 +1,30 @@
+use strict;
+use feature qw(say);
+my @letters = split//,$ARGV[0] or die "No letters";
+my $file = $ARGV[1] || '/usr/share/dict/words';
+-f $file or die "The dictionary does not exists";
+open my $fh, '<', $file;
+my @a = <$fh>;
+for (@a) {
+ s/\/.*//;
+ s/\n//;
+ my @b = split //,$_;
+ my $itsok = 1;
+ my @copy = @letters;
+ for (@b) {
+ my $exists = 0;
+ for (my $i=0;$i<@copy;$i++) {
+ if ($copy[$i] =~ /$_/i) {
+ $exists=1;
+ splice @copy, $i, 1;
+ $i--;
+ last;
+ }
+ }
+ unless ($exists) {
+ $itsok = 0;
+ last;
+ }
+ }
+ $itsok and say $_;
+}