aboutsummaryrefslogtreecommitdiff
path: root/challenge-011
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2019-06-09 05:39:51 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2019-06-09 05:39:51 +0100
commit8cdc531858dfa1b8f3c6c90a1d3058a92bfd8f78 (patch)
tree9138ffeeca4a75aeaf6a99db6d70e6e59609187d /challenge-011
parentd4b277b14cf4fa525814ff76e0665f2151022fe0 (diff)
downloadperlweeklychallenge-club-8cdc531858dfa1b8f3c6c90a1d3058a92bfd8f78.tar.gz
perlweeklychallenge-club-8cdc531858dfa1b8f3c6c90a1d3058a92bfd8f78.tar.bz2
perlweeklychallenge-club-8cdc531858dfa1b8f3c6c90a1d3058a92bfd8f78.zip
- Added solutions by Jo Christian Oterhals.
Diffstat (limited to 'challenge-011')
-rw-r--r--challenge-011/jo-christian-oterhals/perl6/ch-1.p628
-rw-r--r--challenge-011/jo-christian-oterhals/perl6/ch-1.sh1
-rw-r--r--challenge-011/jo-christian-oterhals/perl6/ch-1a.p63
-rw-r--r--challenge-011/jo-christian-oterhals/perl6/ch-2.p65
4 files changed, 22 insertions, 15 deletions
diff --git a/challenge-011/jo-christian-oterhals/perl6/ch-1.p6 b/challenge-011/jo-christian-oterhals/perl6/ch-1.p6
index 54955d03c7..aa12ae87ce 100644
--- a/challenge-011/jo-christian-oterhals/perl6/ch-1.p6
+++ b/challenge-011/jo-christian-oterhals/perl6/ch-1.p6
@@ -1,21 +1,21 @@
#!/usr/bin/env perl6
-multi MAIN( #= Compares the C. scale to any scale you dream up
- Real $f, #= freezing point in custom scale
- Real $b #= boiling point in custom scale
+multi MAIN( #= Compares the Celcius scale to whatever scale you dream up
+ Real $f, #= freezing point in this scale
+ Real $b #= boiling point in this scale
) {
- say "There is no equal point for this scale." and exit if $b - $f == 100;
- my $equal-point = $f / (1 - (($b - $f) / 100));
- say "The calculated equal point is only theoretical as it is below absolute zero." if $equal-point < -273.15;
- say "Equal point: $equal-point";
+ say "There is no equal point for this scale." and exit if $b - $f == 100;
+ my $equal-point = $f / (1 - (($b - $f) / 100));
+ say "The calculated equal point is only theoretical as it is below absolute zero." if $equal-point < -273.15;
+ say "Equal point: $equal-point";
}
-multi MAIN( #= Compares the C. scale to a named temperature scale
- Str $scale where { $_ ~~ m:i/^(fahrenheit|kelvin|rankin)$/ } #= Name of scale (Fahrenheit, Kelvin or Rankin)
+multi MAIN( #= Compares the Celcius scale to a given temperature scale
+ Str $scale where { $_ ~~ m:i/^(fahrenheit|kelvin|rankin)$/ } #= Name of scale (Fahrenheit, Kelvin or Rankin)
) {
- given $scale.fc {
- when "fahrenheit" { MAIN( 32 , 212 ); }
- when "kelvin" { MAIN(273.15, 373.15); }
- when "rankin" { MAIN(491.67, 671.67); }
- }
+ given $scale.fc {
+ when "fahrenheit" { MAIN( 32 , 212 ); }
+ when "kelvin" { MAIN(273.15, 373.15); }
+ when "rankin" { MAIN(491.67, 671.67); }
+ }
}
diff --git a/challenge-011/jo-christian-oterhals/perl6/ch-1.sh b/challenge-011/jo-christian-oterhals/perl6/ch-1.sh
deleted file mode 100644
index 46451905ba..0000000000
--- a/challenge-011/jo-christian-oterhals/perl6/ch-1.sh
+++ /dev/null
@@ -1 +0,0 @@
-perl6 -e 'sub MAIN($a, $b) { say "Equal point: " ~ ( $b - $a == 100 ?? "None" !! $a / (1 - (($b - $a) / 100))) }' 32 212
diff --git a/challenge-011/jo-christian-oterhals/perl6/ch-1a.p6 b/challenge-011/jo-christian-oterhals/perl6/ch-1a.p6
new file mode 100644
index 0000000000..bff294d1a6
--- /dev/null
+++ b/challenge-011/jo-christian-oterhals/perl6/ch-1a.p6
@@ -0,0 +1,3 @@
+#!/usr/bin/env perl6
+
+-> $a, $b { say "Equal point: " ~ ( $b - $a == 100 ?? "None" !! $a / (1 - (($b - $a) / 100))) }(32,212)
diff --git a/challenge-011/jo-christian-oterhals/perl6/ch-2.p6 b/challenge-011/jo-christian-oterhals/perl6/ch-2.p6
new file mode 100644
index 0000000000..db71e84635
--- /dev/null
+++ b/challenge-011/jo-christian-oterhals/perl6/ch-2.p6
@@ -0,0 +1,5 @@
+#!/usr/bin/env perl6
+
+my &idm = -> $size { gather for ^$size -> $y { take map { Int($_ == $y) }, ^$size } };
+.join(' ').say for idm(4); # 4... 2... 16... or whatever...
+