From f70444df60782c54955c25d7b462b002a16fa498 Mon Sep 17 00:00:00 2001 From: Adam Russell Date: Sun, 9 Jun 2019 00:19:26 -0400 Subject: solution for challenge 011 --- challenge-011/adam-russell/blog.txt | 1 + challenge-011/adam-russell/perl5/ch-1.pl | 14 ++++++++++++++ challenge-011/adam-russell/perl5/ch-2.pl | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 challenge-011/adam-russell/blog.txt create mode 100644 challenge-011/adam-russell/perl5/ch-1.pl create mode 100644 challenge-011/adam-russell/perl5/ch-2.pl diff --git a/challenge-011/adam-russell/blog.txt b/challenge-011/adam-russell/blog.txt new file mode 100644 index 0000000000..1b39aba56b --- /dev/null +++ b/challenge-011/adam-russell/blog.txt @@ -0,0 +1 @@ +https://adamcrussell.livejournal.com/3900.html diff --git a/challenge-011/adam-russell/perl5/ch-1.pl b/challenge-011/adam-russell/perl5/ch-1.pl new file mode 100644 index 0000000000..a723c744a4 --- /dev/null +++ b/challenge-011/adam-russell/perl5/ch-1.pl @@ -0,0 +1,14 @@ +use strict; +use warnings; +## +# Write a script that computes the equal point in the Fahrenheit and Celsius +# scales, knowing that the freezing point of water is 32 °F and 0 °C, and +# that the boiling point of water is 212 °F and 100 °C. +# °F = (°C * 9/5) + 32 +## +for my $c (-100 .. 100){ + my $f = ($c * (9/5)) + 32; + if($f == $c){ + print "°F = °C at $f\n"; + } +} diff --git a/challenge-011/adam-russell/perl5/ch-2.pl b/challenge-011/adam-russell/perl5/ch-2.pl new file mode 100644 index 0000000000..d29c2bf377 --- /dev/null +++ b/challenge-011/adam-russell/perl5/ch-2.pl @@ -0,0 +1,18 @@ +use strict; +use warnings; +## +# Write a script to create an Identity Matrix for the given size. +# For example, if the size is 4, then create Identity Matrix 4x4. +## +use constant SIZE => 10; + +my @a; +for my $i (0 .. SIZE - 1){ + my @b = (0) x SIZE; + $b[$i] = 1; + push @a, \@b; +} +print SIZE . " x " . SIZE . " identity matrix:\n"; +for my $i (0 .. SIZE - 1){ + print "\t" . join(" ", @{$a[$i]}) . "\n"; +} -- cgit