aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalt Mankowski <waltman@pobox.com>2022-01-17 20:56:16 -0500
committerWalt Mankowski <waltman@pobox.com>2022-01-17 20:56:16 -0500
commit0dc95b11651662ac21f1a2ed6aae227e3a281905 (patch)
tree376cef84dfc68ea194288e2f3b174e3bdec270bc
parentd12d825c64ff59dee6e963896b6b2aafb45d7fca (diff)
downloadperlweeklychallenge-club-0dc95b11651662ac21f1a2ed6aae227e3a281905.tar.gz
perlweeklychallenge-club-0dc95b11651662ac21f1a2ed6aae227e3a281905.tar.bz2
perlweeklychallenge-club-0dc95b11651662ac21f1a2ed6aae227e3a281905.zip
Perl code to solve challenge 148 task 2
-rw-r--r--challenge-148/walt-mankowski/perl/ch-2.pl21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-148/walt-mankowski/perl/ch-2.pl b/challenge-148/walt-mankowski/perl/ch-2.pl
new file mode 100644
index 0000000000..7769483138
--- /dev/null
+++ b/challenge-148/walt-mankowski/perl/ch-2.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use feature qw(:5.34);
+use experimental qw(signatures);
+
+my $EPS = 1e-6;
+my $THIRD = 1 / 3;
+
+for my $a (1..100) {
+ for my $b (1..100) {
+ for my $c (1..100) {
+ my $t1 = ($a + $b * sqrt($c)) ** $THIRD;
+ my $tmp = $a - $b * sqrt($c);
+ my $t2 = ($tmp >= 0) ? $tmp ** $THIRD : -abs($tmp) ** $THIRD;
+ if (abs($t1 + $t2 - 1) < $EPS) {
+ say "($a, $b, $c) ", $a + $b + $c ;
+ }
+ }
+ }
+}