aboutsummaryrefslogtreecommitdiff
path: root/challenge-011
diff options
context:
space:
mode:
authorFrancis Whittle <FJ.Whittle@gmail.com>2019-06-06 23:50:09 +1000
committerFrancis Whittle <FJ.Whittle@gmail.com>2019-06-06 23:50:42 +1000
commitb8c0bbf829a93ab70347ec6bafc40ef93594c9f1 (patch)
tree9115190501421185496f7703f715a74640ea3731 /challenge-011
parentd56d883a9784671c88f9353c4cd3a7d287aeabbe (diff)
downloadperlweeklychallenge-club-b8c0bbf829a93ab70347ec6bafc40ef93594c9f1.tar.gz
perlweeklychallenge-club-b8c0bbf829a93ab70347ec6bafc40ef93594c9f1.tar.bz2
perlweeklychallenge-club-b8c0bbf829a93ab70347ec6bafc40ef93594c9f1.zip
fjwhittle challenge 011 solution
Diffstat (limited to 'challenge-011')
-rw-r--r--challenge-011/fjwhittle/perl6/ch-1.p612
-rw-r--r--challenge-011/fjwhittle/perl6/ch-2.p612
2 files changed, 24 insertions, 0 deletions
diff --git a/challenge-011/fjwhittle/perl6/ch-1.p6 b/challenge-011/fjwhittle/perl6/ch-1.p6
new file mode 100644
index 0000000000..e35332670d
--- /dev/null
+++ b/challenge-011/fjwhittle/perl6/ch-1.p6
@@ -0,0 +1,12 @@
+#!/usr/bin/env perl6
+
+my $minf = 32;
+my $maxf = 212;
+my $minc = 0;
+my $maxc = 100;
+
+# Degrees Fahrenheit can be expressed as a function of the form f(x) = ax + C where x
+# is the temperature in degrees Celsius.
+# When f(x) = x, x = C / (1 - a)
+
+say ($minf) / (1 - ($maxf - $minf) / ($maxc - $minc));
diff --git a/challenge-011/fjwhittle/perl6/ch-2.p6 b/challenge-011/fjwhittle/perl6/ch-2.p6
new file mode 100644
index 0000000000..6f99e37fb3
--- /dev/null
+++ b/challenge-011/fjwhittle/perl6/ch-2.p6
@@ -0,0 +1,12 @@
+#!/usr/bin/env perl6
+
+sub identity-matrix (UInt $n) {
+ (^$n).map: -> $i { (^$n).map: -> $j { Int($j == $i) } };
+}
+
+#| Script to create an identity matrix
+unit sub MAIN (
+ UInt $n #= Dimensions of the generated matrix.
+);
+
+.say for identity-matrix $n;