aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-11-04 20:16:10 +0000
committerGitHub <noreply@github.com>2021-11-04 20:16:10 +0000
commit98d18b65e7f2316fd31f6ff99e29c87df2934c29 (patch)
treed1b53aa63913591e3a7cb5342260f84c983759c9
parentc3752c1301a2a913c92c5c85b21686d204102bd6 (diff)
parentbf5538ad1f5731602298463bb9c819339f94736b (diff)
downloadperlweeklychallenge-club-98d18b65e7f2316fd31f6ff99e29c87df2934c29.tar.gz
perlweeklychallenge-club-98d18b65e7f2316fd31f6ff99e29c87df2934c29.tar.bz2
perlweeklychallenge-club-98d18b65e7f2316fd31f6ff99e29c87df2934c29.zip
Merge pull request #5159 from drbaggy/master
Added some timings for Lychrel < 3e7
-rw-r--r--challenge-137/james-smith/README.md9
1 files changed, 8 insertions, 1 deletions
diff --git a/challenge-137/james-smith/README.md b/challenge-137/james-smith/README.md
index b32381ed19..9bdd58ce27 100644
--- a/challenge-137/james-smith/README.md
+++ b/challenge-137/james-smith/README.md
@@ -164,8 +164,15 @@ say $_ foreach sort { $a <=> $b } keys %lychrel;
Using this script to generate all candidate Lychrel numbers up to 1 million took approximately `12` seconds. To use the `lychrel_large` routine took approximately 2180 seconds (36 minutes 20 seconds), a speed gain of approximately `180x`.
-To 10 million the time taken was approximately 6 minutes.
+To 10 million the time taken was approximately 1 min 40s; 20 million ~ 3 min 50s; 30 million ~ 31 min 40s {I think the time for this got large as the machine was starting to hit SWAP storage}. The code fails shortly after this as memory and swap was exhausted ~ 12GB.
+| N | Lychrel < N | Time taken |
+| ---------: | ----------: | ---------: |
+| 10,000,000 | 2,010,871 | 1 min 40s |
+| 20,000,000 | 4,521,930 | 3 min 50s |
+| 30,000,000 | 7,177,742 | 31 min 40s |
+
+The last of these is still quicker than getting Lychrel numbers up to 1,000,000 using the "large" method.
### Explanation
For every sequence generated above - all the numbers are either not Lychral numbers or candidate Lychral numbers. Once we either get to a palindrome OR reach the "end of the sequence" we can tag every number as either a candidate Lychral number or not. This reduces the number of calculations.