aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLapVeesh <rabbiveesh@gmail.com>2019-04-21 10:53:17 +0300
committerLapVeesh <rabbiveesh@gmail.com>2019-04-21 10:53:17 +0300
commit2fe3ee92c9aeabfe53a38f6a7e7b97151e7f4e24 (patch)
tree10606aaa77369b41bf3ebc5d520cb6ed7b62f65f
parentdfbc57749888066b163267bda3801bd66ca5b1de (diff)
downloadperlweeklychallenge-club-2fe3ee92c9aeabfe53a38f6a7e7b97151e7f4e24.tar.gz
perlweeklychallenge-club-2fe3ee92c9aeabfe53a38f6a7e7b97151e7f4e24.tar.bz2
perlweeklychallenge-club-2fe3ee92c9aeabfe53a38f6a7e7b97151e7f4e24.zip
Added answer to easy challenge for week 4
-rw-r--r--challenge-001/veesh-goldman/perl5/ch-1.pl7
-rw-r--r--challenge-002/veesh-goldman/perl5/ch-2.pl4
-rwxr-xr-xchallenge-004/veesh-goldman/perl5/ch-01.pl18
3 files changed, 23 insertions, 6 deletions
diff --git a/challenge-001/veesh-goldman/perl5/ch-1.pl b/challenge-001/veesh-goldman/perl5/ch-1.pl
index b0355e5715..aba2042d0a 100644
--- a/challenge-001/veesh-goldman/perl5/ch-1.pl
+++ b/challenge-001/veesh-goldman/perl5/ch-1.pl
@@ -3,10 +3,9 @@ my $count;
$count++ while $string =~ s/e/E/;
print "$count -- $string\n\n";
-# throws error: Substitution replacement not terminated
-#$_ = 'Perl Weekly Challenge';
-#$%++ while s/e/E;
-#print "$% -- $_\n\n";
+$_ = 'Perl Weekly Challenge';
+$%++ while s/e/E/;
+print "$% -- $_\n\n";
$_ = 'Perl Weekly Challenge';
print y/e/E/," -- $_\n\n";
diff --git a/challenge-002/veesh-goldman/perl5/ch-2.pl b/challenge-002/veesh-goldman/perl5/ch-2.pl
index 59fb74872a..1d67909982 100644
--- a/challenge-002/veesh-goldman/perl5/ch-2.pl
+++ b/challenge-002/veesh-goldman/perl5/ch-2.pl
@@ -8,12 +8,12 @@ while (my ($index, $element) = each @to_table) {
sub convert_to {
my $x = shift; my $pow = 1; my @ret;
- while ($x > 0) {
+ do {
my $digit = $x % 35;
unshift @ret, $to_table[$digit];
$x -= $digit;
$x /= 35;
- }
+ } while $x > 0;
return join '', @ret
}
diff --git a/challenge-004/veesh-goldman/perl5/ch-01.pl b/challenge-004/veesh-goldman/perl5/ch-01.pl
new file mode 100755
index 0000000000..38cac1586e
--- /dev/null
+++ b/challenge-004/veesh-goldman/perl5/ch-01.pl
@@ -0,0 +1,18 @@
+#! /usr/bin/perl
+
+
+#Here's a little hacky way of doing this: I'm encoding the digits
+#of pi in unicode characters, and then turning them back into
+#digits. I get between 4 and 5 digits per chinese character (or
+#math symbol). It's a bit golfy, b/c I'm assuming whitespace
+#counts towards the 'length' of the script. I'm counting 'length'
+#by characters, not by bytes.
+use utf8;print for'3.',map ord,split//,'㝏枧⌓纀閷┞⊉◴Ⓑ銆:'
+
+#this is just so I can put both in the same script
+;
+#I assume that printing via die counts too, because print makes
+#this too long.
+#Arctan of 1 is actually defined as pi/4, and I get 15 digits
+#precision on my box (64 bit Ubuntu Xenial)
+die 4*atan2 1,1