aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalt Mankowski <waltman@pobox.com>2022-01-18 19:38:05 -0500
committerGitHub <noreply@github.com>2022-01-18 19:38:05 -0500
commit149a2195304041449a16e8a683135037138f97cc (patch)
tree7bcfaa3f41d1c37c01cc3798c75f4e1ce7081019
parent9b954d20c837db8b0006f33742464c88167b41c0 (diff)
downloadperlweeklychallenge-club-149a2195304041449a16e8a683135037138f97cc.tar.gz
perlweeklychallenge-club-149a2195304041449a16e8a683135037138f97cc.tar.bz2
perlweeklychallenge-club-149a2195304041449a16e8a683135037138f97cc.zip
Update README.md
Minor tweak to the text.
-rw-r--r--challenge-148/walt-mankowski/README.md2
1 files changed, 1 insertions, 1 deletions
diff --git a/challenge-148/walt-mankowski/README.md b/challenge-148/walt-mankowski/README.md
index e69a7bf44a..0ed2bb3e10 100644
--- a/challenge-148/walt-mankowski/README.md
+++ b/challenge-148/walt-mankowski/README.md
@@ -16,7 +16,7 @@ my @eban = grep { num2en($_) !~ tr/e// } 1..100;
For this task we need to generate the first 5 **Cardano Triplets**. The formula for Cardano Triplets involves square and cube roots. Github's Markdown engine doesn't support inline math, so I'll refer the reader to a [Project Euler](https://projecteuler.net/problem=251) problem involving them.
-There's no obvious method to sort Cardano Triplets, so instead of generating the first 5, I decided to generate all the solutions where a, b, and c are all less than or equal to 100.
+There's no obvious method to sort Cardano Triplets, so instead of generating the first 5, I decided to generate all the solutions where a, b, and c are all less than or equal to 100. I didn't use anything fancy to generate them, just 3 nested `for` loops.
The only real difficulty here is that the second cube root term is often negative. This is the case for the example of (2,1,5) given in the problem description. Like all nonzero real numbers, 2 - sqrt(5) has exactly one real cube root, but since it's negative Perl's `**` operator returns `NaN`. To get around this I take the cube root of the absolute value, then make it negative: