aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-11-08 18:39:58 +0000
committerGitHub <noreply@github.com>2020-11-08 18:39:58 +0000
commitca44af2b0fe25a6fbb7915ea8857a678bba80164 (patch)
tree5ec2644e7564e27bd7178256b6408f14add7c137
parentff7475c4559b1087f402725a7c526d3f780e3434 (diff)
parent4a4ca94a61f8d9e8bbadde1406588b795ec0cf75 (diff)
downloadperlweeklychallenge-club-ca44af2b0fe25a6fbb7915ea8857a678bba80164.tar.gz
perlweeklychallenge-club-ca44af2b0fe25a6fbb7915ea8857a678bba80164.tar.bz2
perlweeklychallenge-club-ca44af2b0fe25a6fbb7915ea8857a678bba80164.zip
Merge pull request #2724 from kaicb97/branch-for-challenge-085
solution for week 085 ch-1
-rwxr-xr-xchallenge-085/kai-burgdorf/perl/ch-1.pl39
1 files changed, 39 insertions, 0 deletions
diff --git a/challenge-085/kai-burgdorf/perl/ch-1.pl b/challenge-085/kai-burgdorf/perl/ch-1.pl
new file mode 100755
index 0000000000..f6a1fcf505
--- /dev/null
+++ b/challenge-085/kai-burgdorf/perl/ch-1.pl
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+#Input: @R = (1.2, 0.4, 0.1, 2.5)
+#Output: 1 as 1 < 1.2 + 0.4 + 0.1 < 2
+
+#Input: @R = (0.2, 1.5, 0.9, 1.1)
+#Output: 0
+
+#Input: @R = (0.5, 1.1, 0.3, 0.7)
+#Output: 1 as 1 < 0.5 + 1.1 + 0.3 < 2
+
+#my @R = ( 1.2, 0.4, 0.1, 2.5 );
+#my @R = ( 0.2, 1.5, 0.9, 1.1 );
+my @R = ( 0.5, 1.1, 0.3, 0.7 );
+
+my $output = "0\n";
+
+for ( my $i = 0 ; $i < scalar @R - 2 ; $i++ ) {
+
+ my $a = $R[$i];
+ for ( my $j = 0 ; $j < scalar @R - 1 ; $j++ ) {
+
+ my $b = $R[$j];
+ for ( my $k = 0 ; $k < scalar @R ; $k++ ) {
+
+ my $c = $R[$k];
+ my $sum = $a + $b + $c;
+
+ if ( ( $i != $j && $i != $k && $j != $k ) && ( 1 < $sum && $sum < 2 ) ) {
+ $output = "1 < ($a+$b+$c) < 2\n";
+ }
+ }
+ }
+}
+
+print $output;