Talk:Self numbers: Difference between revisions

From Rosetta Code
Content added Content deleted
 
(Speedup for Go, link to tio.run)
Line 9: Line 9:
Now counting all selfnumbers 0..9999 than copy 10000- (max digitcount)*9 to Position 0..- (max digitcount)*9 and clear the rest to the upper limit.
Now counting all selfnumbers 0..9999 than copy 10000- (max digitcount)*9 to Position 0..- (max digitcount)*9 and clear the rest to the upper limit.
This can all be done lightning fast in Level I cache. [[user Horst.h|Horst.h]] 18:20, 7 October 2020 (UTC)
This can all be done lightning fast in Level I cache. [[user Horst.h|Horst.h]] 18:20, 7 October 2020 (UTC)

== Go, tweaked ==
Rearranged some of the nested additions, seems to go around 25% faster, or so. (Original was taking over 12 seconds on tio.run) [https://tio.run/##bZLdjpswEIXveYpTpEqwWCtYqVKzjl@hqtTe7eaCHxucgFmBk16s8uzpeEJXrlouOPKcz/YMnH6@3d7q9lT3GlNtXZLY6W1ePLLUTD6VqbeTTvMkMWfXYrX6orMcL4dmnke8J8B6EXB4VrT7pLO7IfD0UOldsXvYFVUuUBJn5gW1qMeAlqIqJWrsgSfJVVUXFUlR8ZmBbUTDbHAlGmJZqaoaYpuYbUXLbHAlWmJZqapaYtuY7UTHbHAlOmJZqao6YruY1UIzG1wJTSwrVZUmVsesEYbZ4EoYYlmpqgyxJmZ70TMbXImeWFaqqp7YPmYHMTAbXImBWFaqqoHYIWatsMwGV8ISy0pVZYm1MXsMoJWke1iijkWBd5AZfunLsXAHKPjlrCUcWdePh5BF@/PiiEuuWzBCdCgXHAgvOBTtfHY@XBIS9Pht/pVRErYAbZGY/OP3xTo/uiz9OWgYu6weX0qsejRw56nRy4p60c@UwG1Ezs99uFG7bL3ktAi9c@vW4BO1bw/bGvc2ikIG697SXoUr/vhRGyZLP3dIBWy@mddNP/YqhUp//d/mMMOre3VhjqosMdlxtLPzQzwM7BofDzSLrk9/XRbe138@zjyfaCN/yR/WtTpbfZ4n19vtNw linky]

Just saw Horst's idea, haven't incorporated it yet.--[[User:Enter your username|Enter your username]] ([[User talk:Enter your username|talk]]) 19:47, 7 October 2020 (UTC)

Revision as of 19:48, 7 October 2020

Improvement to the clever sieving of purefox

It takes a lot of space for sieving all.
Thinking of a highest number to test has 12 digits then max digitcount is 12. One can use small blocks of 10,000 (or 100,000 ( 4..5 digits )) + an extension of (max digitcount)*9
So the upper limit is 10,000 +(max digitcount)*9 -1 here 10,107
For example:
After marking the first 10000 (n = 0--9999) not selfnumbers the last marked is 9999+4*9 = 100035 Now counting all selfnumbers 0..9999 than copy 10000- (max digitcount)*9 to Position 0..- (max digitcount)*9 and clear the rest to the upper limit. This can all be done lightning fast in Level I cache. Horst.h 18:20, 7 October 2020 (UTC)

Go, tweaked

Rearranged some of the nested additions, seems to go around 25% faster, or so. (Original was taking over 12 seconds on tio.run) linky

Just saw Horst's idea, haven't incorporated it yet.--Enter your username (talk) 19:47, 7 October 2020 (UTC)