Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

RAM wasn't built in a day.


devel / comp.lang.c / Re: Losing my mind: results change with/without printf() statements

SubjectAuthor
* Losing my mind: results change with/without printf() statementsDFS
+* Re: Losing my mind: results change with/without printf() statementsDavid Brown
|`* Re: Losing my mind: results change with/without printf() statementsDFS
| +* Re: Losing my mind: results change with/without printf() statementsBart
| |`* Re: Losing my mind: results change with/without printf() statementsDFS
| | +* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| | |`* Re: Losing my mind: results change with/without printf() statementsDFS
| | | +- Re: Losing my mind: results change with/without printf() statementsDavid Brown
| | | `* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| | |  `* Re: Losing my mind: results change with/without printf() statementsMichael S
| | |   `* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| | |    `* Re: Losing my mind: results change with/without printf() statementsMichael S
| | |     `* Re: Losing my mind: results change with/without printf() statementsMichael S
| | |      `* Re: Losing my mind: results change with/without printf() statementsBart
| | |       `* Re: Losing my mind: results change with/without printf() statementsMichael S
| | |        `* Re: Losing my mind: results change with/without printf() statementsBart
| | |         `* Re: Losing my mind: results change with/without printf() statementsMichael S
| | |          `- Re: Losing my mind: results change with/without printf() statementsMichael S
| | +* Re: Losing my mind: results change with/without printf() statementsMichael S
| | |`* Re: Losing my mind: results change with/without printf() statementsBart
| | | `- Re: Losing my mind: results change with/without printf() statementsMichael S
| | `* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| |  +- Re: Losing my mind: results change with/without printf() statementsDFS
| |  +- Re: Losing my mind: results change with/without printf() statementsBart
| |  `* Re: Losing my mind: results change with/without printf() statementsKaz Kylheku
| |   `* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| |    `* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| |     `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |      `* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| |       `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |        `* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| |         `* Re: Losing my mind: results change with/without printf() statementsKent Dickey
| |          `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |           `* Re: Losing my mind: results change with/without printf() statementsKent Dickey
| |            `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |             +- Re: Losing my mind: results change with/without printf() statementsDFS
| |             `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |              `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |               +* Re: Losing my mind: results change with/without printf() statementsKent Dickey
| |               |`* Re: Losing my mind: results change with/without printf() statementsMichael S
| |               | `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |               |  `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |               |   `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |               |    +* Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| |               |    |`* Re: Losing my mind: results change with/without printf() statementsMichael S
| |               |    | `- Re: Losing my mind: results change with/without printf() statementsBen Bacarisse
| |               |    `- Re: Losing my mind: results change with/without printf() statementsMichael S
| |               +* Re: Losing my mind: results change with/without printf() statementsDFS
| |               |`- Re: Losing my mind: results change with/without printf() statementsMichael S
| |               `* Re: Losing my mind: results change with/without printf() statementsMike Terry
| |                `* Re: Losing my mind: results change with/without printf() statementsMichael S
| |                 `* Re: Losing my mind: results change with/without printf() statementsMike Terry
| |                  +- Re: Losing my mind: results change with/without printf() statementsMike Terry
| |                  `- Re: Losing my mind: results change with/without printf() statementsMike Terry
| +* Re: Losing my mind: results change with/without printf() statementsDavid Brown
| |`* Re: Losing my mind: results change with/without printf() statementsDFS
| | `* Re: Losing my mind: results change with/without printf() statementsBart
| |  `- Re: Losing my mind: results change with/without printf() statementsDFS
| `- Re: Losing my mind: results change with/without printf() statementsluser droog
+* Re: Losing my mind: results change with/without printf() statementsBarry Schwarz
|`* Re: Losing my mind: results change with/without printf() statementsDFS
| +- Re: Losing my mind: results change with/without printf() statementsBarry Schwarz
| `- Re: Losing my mind: results change with/without printf() statementsDavid Brown
`- Re: Losing my mind: results change with/without printf() statementsRosario19

Pages:123
Re: Losing my mind: results change with/without printf() statements

<sbne5k$6f6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17185&group=comp.lang.c#17185

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
Date: Fri, 2 Jul 2021 17:16:43 +0100
Organization: A noiseless patient Spider
Lines: 86
Message-ID: <sbne5k$6f6$1@dont-email.me>
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <sbjvd3$bgu$1@dont-email.me>
<0DGDI.11997$NP.2951@fx42.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 2 Jul 2021 16:16:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="43845afab179f91ac4dad940c011128c";
logging-data="6630"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+e96u2t7CZ/Qcm2Oq3ujj2CaAHMbINMx4="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:SwxGTp5scoVmZW6kKzwQ1hvjZ0k=
In-Reply-To: <0DGDI.11997$NP.2951@fx42.iad>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210702-0, 02/07/2021), Outbound message
 by: Bart - Fri, 2 Jul 2021 16:16 UTC

On 02/07/2021 16:52, DFS wrote:
> On 7/1/2021 4:46 AM, David Brown wrote:
>> On 30/06/2021 19:58, DFS wrote:
>
>
>
>> At the very least, paste your code into <https://godbolt.org> and use
>> "gcc -O2 -Wall -Wextra" there.
>
>
> Incredible site - thanks for the link.
>
>
> -Wall -Wextra is pretty strict.  It even warned of unused 'argc' from
> main().
>
>
>
>> There are many things that can affect performance, and Python can be
>> surprisingly efficient at times.  It's fun to try this kind of thing and
>> see how you can improve the speeds.  (You could try pypy, for example.)
>
> I saw Bart tried pypy and got good results.  I tried pypy3 on the below
> and got a 13.8x speed increase over python for F(10^6) and F(10^7).
>
>
>
>>> ================================================================
>>> import sys
>>> start = int(sys.argv[1])
>>> end   = int(sys.argv[2])
>>> div,ocn = 0,0
>>> for i in range(start,end+1):
>>>      istr = str(i)
>>>      ilen = len(istr)
>>>      for j in range(0,ilen):
>>>          for k in range(j+1,ilen+1):
>>>              if int(istr[j:k]) % ilen == 0:
>>>                  div+=1
>>>      if div == 1: ocn+=1
>>>      div = 0
>>> print("\n%d one-child numbers from %d to %d" % (ocn,start,end))
>>> ================================================================
>>>
>>
>

I created my own script version, which got ported to C (see my recent
post), but I also converted it to this Python:

----------------------------------
def onechild(n):
s=str(n)
slen=len(s)

count = (n%slen)==0

for w in range(slen-1):
for i in range(slen-w):
m=int(s[i:i+w+1])
if (m%slen)==0:
count+=1
if count>1: return 0

if count==1: return 1
return 0

n=10_000_000
count=0

for i in range(1,n):
count+=onechild(i)

print("F(",n,") =",count)

----------------------------------

This took the same time as gcc-O3, 9.4 seconds, using PyPy (89 seconds
with CPython).

(Annoyingly, my script interpreter, which is not JITed, took 37 seconds.
But PyPy /does/ love loops with long iterations; it's its thing.

I like interesting new benchmarks, but with ones like this with just one
obvious bottleneck, it's hard to beat tracing JITs when implementing
dynamic bytecode.)

Re: Losing my mind: results change with/without printf() statements

<245d9902-b854-44d9-9a8e-f4fa2d2fd044n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17186&group=comp.lang.c#17186

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:48c4:: with SMTP id v4mr590351qvx.30.1625243159253;
Fri, 02 Jul 2021 09:25:59 -0700 (PDT)
X-Received: by 2002:ae9:e911:: with SMTP id x17mr566186qkf.371.1625243159117;
Fri, 02 Jul 2021 09:25:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 2 Jul 2021 09:25:58 -0700 (PDT)
In-Reply-To: <bf39ecc9-f6c8-499a-8fed-c17d725b10fbn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.182.191; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.182.191
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87im1vj6q3.fsf@bsb.me.uk> <O%aDI.906$tE4.1@fx29.iad>
<8735syjrwf.fsf@bsb.me.uk> <54aa8ed0-7069-44c8-a582-d05aa8541ac8n@googlegroups.com>
<87fswwhlu4.fsf@bsb.me.uk> <bf39ecc9-f6c8-499a-8fed-c17d725b10fbn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <245d9902-b854-44d9-9a8e-f4fa2d2fd044n@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 02 Jul 2021 16:25:59 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Fri, 2 Jul 2021 16:25 UTC

On Friday, July 2, 2021 at 5:49:01 PM UTC+3, Michael S wrote:
> On Friday, July 2, 2021 at 4:44:33 PM UTC+3, Ben Bacarisse wrote:
> > Michael S <already...@yahoo.com> writes:
> >
> > > On Thursday, July 1, 2021 at 12:38:21 PM UTC+3, Ben Bacarisse wrote:
> > >> DFS <nos...@dfs.com> writes:
> > >>
> > >> > On 6/30/2021 7:03 PM, Ben Bacarisse wrote:
> > >> >> DFS <nos...@dfs.com> writes:
> > >> >>
> > >> >>> On 6/30/2021 2:44 PM, Bart wrote:
> > >> >> <cut>
> > >> >>>> But I suspect that in all cases, what is dominant is the conversion
> > >> >>>> from int to text, from text back to int, and applying the mod
> > >> >>>> operator. All things that happen outside of the code generated from
> > >> >>>> your source.
> > >> >>>
> > >> >>> I don't understand 'happen outside'.
> > >> >> I think he means that your calls to atoi are doing most of the work, so
> > >> >> you can't get much more speed from tinkering with the code you actually
> > >> >> wrote.
> > >> >> That's not quite right in that you can get a good speed-up by not
> > >> >> generating all those sub-strings. You already have the full number in
> > >> >> 's' so you can get sub-string numbers by doing this:
> > >> >> char save = s[j+k];
> > >> >> s[j+k] = 0;
> > >> >> ssnbr = atoi(s+j);
> > >> >> s[j+k] = save;
> > >> >
> > >> > Geez, that block means less code overall, and the prog runs
> > >> > significantly faster. Where do you mad geniuses come from?
> > >> Actually there is no genius involved (IMO). It's mostly the result of
> > >> having written and (possibly more importantly) read code for more than
> > >> 40 years. You pick up stuff along the way.
> > >> >> Having said that, Bart's point still holds. This can be seen as a
> > >> >> purely arithmetical problem. There is no need for strings conversions
> > >> >> (and hence atoi) at all. Whether that would make the code faster is not
> > >> >> obvious, but I suspect it might. I've not have time to try it.
> > >> >
> > >> > Careful of gotchas. These are all the substrings of 104, including
> > >> > the leading-zero dropped '04':
> > >> Whether that's a gotcha or not depends on how you tackle the problem.
> > >>
> > >> I've written an arithmetic version (i.e. no strings) and it is
> > >> significantly faster again.
> > >
> > > Does it include replacement of division by reciprocal multiplication?
> > No, it's a plain integer / and % version. Have you got one that does
> > something clever with the divisions?
> >
> > --
> > Ben.
> No, I didn't.
> Have more interesting things to do.
> Besides, brute force is so obvious dead end...

Just to prove to myself that brute force is dead end
Here is rather clever brute force.
It does 1e9 in 26 sec on my aging home PC (i5-3450).

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>

static bool isOneChild(const uint8_t *digits, int nDigits, const uint8_t *remTab)
{ int nChilds = 0;
for (int beg = 0; beg < nDigits; ++beg) {
unsigned r = 0;
for (int end = beg; end < nDigits; ++end) {
r = remTab[r*10+digits[end]];
if (r == 0) {
++nChilds;
}
}
if (nChilds > 1)
return false;
}
return nChilds == 1;
}

static unsigned long long countOneChildsInRange(uint64_t first, uint64_t last, int nDigits, bool print)
{ // initialize look-up table
uint8_t remTab[200];
for (int i = 0; i < nDigits*10; ++i)
remTab[i] = i % nDigits;

// initialize array of digits
uint8_t digits[20];
uint64_t x = first;
for (int i = 0; i < nDigits; ++i) {
digits[nDigits-1-i] = x % 10;
x /= 10;
}

unsigned long long cnt = 0;
for (x = first; x <= last; ++x) {
if (isOneChild(digits, nDigits, remTab)) {
++cnt;
if (print)
printf("%llu\n", (unsigned long long)x);
}
uint8_t lsDig = digits[nDigits-1] + 1;
digits[nDigits-1] = lsDig;
if (lsDig == 10) {
digits[nDigits-1] = 0;
for (int i = nDigits-2; i >= 0; --i) {
uint8_t d = digits[i] + 1;
if (d == 10) {
digits[i] = 0;
} else {
digits[i] = d;
break;
}
}
lsDig = 0;
}
}
return cnt;
}

int count_digits(unsigned long long x)
{ int c = 0;
while (x) {
++c;
x /= 10;
}
return c;
}

unsigned long long ndig_max(int nDigits)
{ unsigned long long x = 1;
for (int i = 0; i < nDigits; ++i)
x *= 10;
return x - 1;
}

int main(int argz, char** argv)
{ if (argz < 3) {
fprintf(stderr, "Consult DFS!\n");
return 1;
}

char* endp;
unsigned long long first = strtoull(argv[1], &endp, 0);
if (endp == argv[1]) {
fprintf(stderr, "%s is not a number.\n", argv[1]);
return 1;
}

unsigned long long last = strtoull(argv[2], &endp, 0);
if (endp == argv[2]) {
fprintf(stderr, "%s is not a number.\n", argv[2]);
return 1;
}

bool print = false;
if (argz > 3 && argv[3][0]=='p')
print = true;

unsigned long long cnt = 0;
while (first <= last) {
int nDigits = count_digits(first);
unsigned long long rangeLast = ndig_max(nDigits);
if (rangeLast > last)
rangeLast = last;
cnt += countOneChildsInRange(first, rangeLast, nDigits, print);
first = rangeLast + 1;
}
printf("Found %llu one-childs\n", cnt);

return 0;
}

Re: Losing my mind: results change with/without printf() statements

<a0IDI.10228$SA.9490@fx39.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17187&group=comp.lang.c#17187

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx39.iad.POSTED!not-for-mail
Subject: Re: Losing my mind: results change with/without printf() statements
Newsgroups: comp.lang.c
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <sbjvd3$bgu$1@dont-email.me>
<0DGDI.11997$NP.2951@fx42.iad> <sbne5k$6f6$1@dont-email.me>
From: nos...@dfs.com (DFS)
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
MIME-Version: 1.0
In-Reply-To: <sbne5k$6f6$1@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 61
Message-ID: <a0IDI.10228$SA.9490@fx39.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Fri, 02 Jul 2021 17:27:34 UTC
Organization: blocknews - www.blocknews.net
Date: Fri, 2 Jul 2021 13:27:33 -0400
X-Received-Bytes: 2517
 by: DFS - Fri, 2 Jul 2021 17:27 UTC

On 7/2/2021 12:16 PM, Bart wrote:

> I created my own script version, which got ported to C (see my recent
> post), but I also converted it to this Python:
>
> ----------------------------------
> def onechild(n):
>     s=str(n)
>     slen=len(s)
>
>     count = (n%slen)==0
>
>     for w in range(slen-1):
>         for i in range(slen-w):
>             m=int(s[i:i+w+1])
>             if (m%slen)==0:
>                 count+=1
>                 if count>1: return 0
>
>     if count==1: return 1
>     return 0
>
> n=10_000_000
> count=0
>
> for i in range(1,n):
>     count+=onechild(i)
>
> print("F(",n,") =",count)
>
> ----------------------------------
>
> This took the same time as gcc-O3, 9.4 seconds, using PyPy (89 seconds
> with CPython).

F(10^7) 7.2s here, with pypy3.
F(10^8) 86.2S

(old system i5-750@2.67GHz)

> (Annoyingly, my script interpreter, which is not JITed, took 37 seconds.
> But PyPy /does/ love loops with long iterations; it's its thing.
>
> I like interesting new benchmarks, but with ones like this with just one
> obvious bottleneck, it's hard to beat tracing JITs when implementing
> dynamic bytecode.)

The pypy people have done a remarkable job in speeding up python code.

The pypy interpreter itself looks to have been written in python
https://downloads.python.org/pypy/pypy3.7-v7.3.5-src.tar.bz2

https://www.pypy.org/people.html

Re: Losing my mind: results change with/without printf() statements

<sbnima$7p0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17188&group=comp.lang.c#17188

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
Date: Fri, 2 Jul 2021 18:33:53 +0100
Organization: A noiseless patient Spider
Lines: 148
Message-ID: <sbnima$7p0$1@dont-email.me>
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87im1vj6q3.fsf@bsb.me.uk>
<O%aDI.906$tE4.1@fx29.iad> <8735syjrwf.fsf@bsb.me.uk>
<54aa8ed0-7069-44c8-a582-d05aa8541ac8n@googlegroups.com>
<87fswwhlu4.fsf@bsb.me.uk>
<bf39ecc9-f6c8-499a-8fed-c17d725b10fbn@googlegroups.com>
<245d9902-b854-44d9-9a8e-f4fa2d2fd044n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 2 Jul 2021 17:34:02 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="43845afab179f91ac4dad940c011128c";
logging-data="7968"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ubb4o1OX6r0o2VsAS4LFMRjHnG5yp/eY="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:AjqL/PpkiiWp6Ib4qOyXaCBmfp0=
In-Reply-To: <245d9902-b854-44d9-9a8e-f4fa2d2fd044n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210702-0, 02/07/2021), Outbound message
 by: Bart - Fri, 2 Jul 2021 17:33 UTC

On 02/07/2021 17:25, Michael S wrote:
> On Friday, July 2, 2021 at 5:49:01 PM UTC+3, Michael S wrote:
>> On Friday, July 2, 2021 at 4:44:33 PM UTC+3, Ben Bacarisse wrote:

>>>> Does it include replacement of division by reciprocal multiplication?
>>> No, it's a plain integer / and % version. Have you got one that does
>>> something clever with the divisions?
>>>
>>> --
>>> Ben.
>> No, I didn't.
>> Have more interesting things to do.
>> Besides, brute force is so obvious dead end...
>
>
> Just to prove to myself that brute force is dead end
> Here is rather clever brute force.
> It does 1e9 in 26 sec on my aging home PC (i5-3450).
>
> #include <stdint.h>
> #include <stdbool.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> static bool isOneChild(const uint8_t *digits, int nDigits, const uint8_t *remTab)
> {
> int nChilds = 0;
> for (int beg = 0; beg < nDigits; ++beg) {
> unsigned r = 0;
> for (int end = beg; end < nDigits; ++end) {
> r = remTab[r*10+digits[end]];
> if (r == 0) {
> ++nChilds;
> }
> }
> if (nChilds > 1)
> return false;
> }
> return nChilds == 1;
> }
>
> static unsigned long long countOneChildsInRange(uint64_t first, uint64_t last, int nDigits, bool print)
> {
> // initialize look-up table
> uint8_t remTab[200];
> for (int i = 0; i < nDigits*10; ++i)
> remTab[i] = i % nDigits;
>
> // initialize array of digits
> uint8_t digits[20];
> uint64_t x = first;
> for (int i = 0; i < nDigits; ++i) {
> digits[nDigits-1-i] = x % 10;
> x /= 10;
> }
>
> unsigned long long cnt = 0;
> for (x = first; x <= last; ++x) {
> if (isOneChild(digits, nDigits, remTab)) {
> ++cnt;
> if (print)
> printf("%llu\n", (unsigned long long)x);
> }
> uint8_t lsDig = digits[nDigits-1] + 1;
> digits[nDigits-1] = lsDig;
> if (lsDig == 10) {
> digits[nDigits-1] = 0;
> for (int i = nDigits-2; i >= 0; --i) {
> uint8_t d = digits[i] + 1;
> if (d == 10) {
> digits[i] = 0;
> } else {
> digits[i] = d;
> break;
> }
> }
> lsDig = 0;
> }
> }
> return cnt;
> }
>
> int count_digits(unsigned long long x)
> {
> int c = 0;
> while (x) {
> ++c;
> x /= 10;
> }
> return c;
> }
>
> unsigned long long ndig_max(int nDigits)
> {
> unsigned long long x = 1;
> for (int i = 0; i < nDigits; ++i)
> x *= 10;
> return x - 1;
> }
>
> int main(int argz, char** argv)
> {
> if (argz < 3) {
> fprintf(stderr, "Consult DFS!\n");
> return 1;
> }
>
> char* endp;
> unsigned long long first = strtoull(argv[1], &endp, 0);
> if (endp == argv[1]) {
> fprintf(stderr, "%s is not a number.\n", argv[1]);
> return 1;
> }
>
> unsigned long long last = strtoull(argv[2], &endp, 0);
> if (endp == argv[2]) {
> fprintf(stderr, "%s is not a number.\n", argv[2]);
> return 1;
> }
>
> bool print = false;
> if (argz > 3 && argv[3][0]=='p')
> print = true;
>
> unsigned long long cnt = 0;
> while (first <= last) {
> int nDigits = count_digits(first);
> unsigned long long rangeLast = ndig_max(nDigits);
> if (rangeLast > last)
> rangeLast = last;
> cnt += countOneChildsInRange(first, rangeLast, nDigits, print);
> first = rangeLast + 1;
> }
> printf("Found %llu one-childs\n", cnt);
>
> return 0;
> }

Well, it's fast (about 65 seconds on my machine, perhaps 20 times as
fast as my program). But I can't say it's that easy to follow!

It seems to rely on the fact that consecutive numbers are being tested,
so can optimise blocks all having the same numbers of digits. (Exactly
how, I don't know yet.)

So I guess it can't be used to get the one-child status of an arbitrary
number. That's probably the only advantage of the simpler algorithm,
other than being simpler.

Re: Losing my mind: results change with/without printf() statements

<20210702095301.721@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17189&group=comp.lang.c#17189

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
Date: Fri, 2 Jul 2021 17:41:54 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <20210702095301.721@kylheku.com>
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87a6n4hk4c.fsf@bsb.me.uk>
Injection-Date: Fri, 2 Jul 2021 17:41:54 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1e951332b61f28822195145b86653d11";
logging-data="11264"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r10IunBRtstJkYDTyP6Fl0/DbpgL2+mc="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:HbXOorgMNrfKleR9iZHhdYdURdY=
 by: Kaz Kylheku - Fri, 2 Jul 2021 17:41 UTC

On 2021-07-02, Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
> DFS <nospam@dfs.com> writes:
>
>> Not bad numbers for python and F(10^7), but this code is part of me
>> trying to solve Project Euler 413, which asks for F(10^19).
>
> I didn't know that. As you say, a different algorithm is called for.
>
> (My best naive version gets F(10^9) in 4m21.489s and F(10^7) in 2.177s.)

The obvious thing here is to encode custom divisibility tests for
d = [1,19].

For certain divisors, we can test divisibility on the base 10
representation without converting to integer. It's a waste of
time to convert "1235" into 1235 to test it for divisibility by 5,
when we just have to apply the condition "last digit is 0 or 5".

Moreover, in the d=5 case, we can short-circuit to an answer
for each five-digit number. It's a one-child if it starts with 5.
and doesn't contain 0 or any other 5.

int onechild_d5(char *num)
{
return num[0] == '5' && strpbrk(num + 1, "05") == 0;
}

Proof:

1. If the number contains a 5 or 0 in any position other than the first,
then it has at least two substrings divisible by 5: that 0 or 5 itself,
plus strings terminating in that 0 or 5. Therefore, the one-child number
doesn't have a 5 or 0 in any position other than first.

2. A number cannot have leading zeros under the rules, therefore a
one-child number doesn't have a 0 in the first position.

3. The one-child number for d = 5 must have a 0 or 5 somewhere;
therefore it must have a 5 in the first position.

I would write onechild_d1 through onechild_d19 functions, stuffing
them with d-specific shortcuts. Put them into a table, and then
drive them with a main program that does this:

int d;
long long one_child_count;

for (oc = 0, d = 1; d <= 19; d++) {
char n[20];

/* generate d-digit number in n,
stepping it from 100...000 to 99999. */

oc += (octab[d](n) != 0);
}

Incrementing n textually might be faster than repeated sprintfs. So that
is to say, for a given d, we fill the buffer n with:

"10000000" // 1 followed by d-1 zeros

Then we increment textually. We maintain a pointer to the last digit.
If it is '9', we set it to zero, and increment the next digit, otherwise
we increment it.

Dollars to doughnuts says this will beat sprintf because there are no
divisions by ten going on.

The next level of optimization would be to leave the child counting
to the d-specific routines:

/* return number of one-child five-digit numbers */
long long onechild_count_d5(void)
{
/* All these are of the form 5nnnn where the nnnn part
does not contain 0 or 5 anywhere. */

/* In other words, the number of combinations of the 8 digits
1-4, 6-9. */

return 8 * 8 * 8 * 8;
}

This is just an example; I don't mean to insinuate that optimizing d = 5
makes a significant difference if you're going after F(10**19).

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Losing my mind: results change with/without printf() statements

<874kdch9k0.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17190&group=comp.lang.c#17190

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
Date: Fri, 02 Jul 2021 19:09:35 +0100
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <874kdch9k0.fsf@bsb.me.uk>
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87a6n4hk4c.fsf@bsb.me.uk>
<20210702095301.721@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="eebc8e7d3a672789a70c7da0a5748a69";
logging-data="18280"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ufKmjKUaAtUrJLyCIRQDEW72tb4paWis="
Cancel-Lock: sha1:z1hyo+G5qTe9UKoeyFUS55d7Yvw=
sha1:iNvMraEzJFvvs+PzeAbrBXKSVBA=
X-BSB-Auth: 1.6eebd931e38f09bccf8e.20210702190935BST.874kdch9k0.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 2 Jul 2021 18:09 UTC

Kaz Kylheku <563-365-8930@kylheku.com> writes:

> On 2021-07-02, Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>> DFS <nospam@dfs.com> writes:
>>
>>> Not bad numbers for python and F(10^7), but this code is part of me
>>> trying to solve Project Euler 413, which asks for F(10^19).
>>
>> I didn't know that. As you say, a different algorithm is called for.
>>
>> (My best naive version gets F(10^9) in 4m21.489s and F(10^7) in 2.177s.)
>
> The obvious thing here is to encode custom divisibility tests for
> d = [1,19].
>
> For certain divisors, we can test divisibility on the base 10
> representation without converting to integer. It's a waste of
> time to convert "1235" into 1235 to test it for divisibility by 5,
> when we just have to apply the condition "last digit is 0 or 5".

In the "arithmetic" versions, there are no strings.

> Moreover, in the d=5 case, we can short-circuit to an answer
> for each five-digit number. It's a one-child if it starts with 5.
> and doesn't contain 0 or any other 5.

Yes, there are various opportunities for short-circuiting many cases. I
wonder if that's enough to make 10^19 tractable.

Also, problems like this are supposed to be satisfying, and
special-casing sub-string divisibility for lots of different lengths
does not meet that criterion (in my view).
>
> int onechild_d5(char *num)
> {
> return num[0] == '5' && strpbrk(num + 1, "05") == 0;
> }
>
> Proof:
>
> 1. If the number contains a 5 or 0 in any position other than the first,
> then it has at least two substrings divisible by 5: that 0 or 5 itself,
> plus strings terminating in that 0 or 5. Therefore, the one-child number
> doesn't have a 5 or 0 in any position other than first.
>
> 2. A number cannot have leading zeros under the rules, therefore a
> one-child number doesn't have a 0 in the first position.
>
> 3. The one-child number for d = 5 must have a 0 or 5 somewhere;
> therefore it must have a 5 in the first position.
>
> I would write onechild_d1 through onechild_d19 functions, stuffing
> them with d-specific shortcuts. Put them into a table, and then
> drive them with a main program that does this:
>
> int d;
> long long one_child_count;
>
> for (oc = 0, d = 1; d <= 19; d++) {
> char n[20];
>
> /* generate d-digit number in n,
> stepping it from 100...000 to 99999. */
>
> oc += (octab[d](n) != 0);
> }
>
> Incrementing n textually might be faster than repeated sprintfs. So that
> is to say, for a given d, we fill the buffer n with:
>
> "10000000" // 1 followed by d-1 zeros
>
> Then we increment textually. We maintain a pointer to the last digit.
> If it is '9', we set it to zero, and increment the next digit, otherwise
> we increment it.
>
> Dollars to doughnuts says this will beat sprintf because there are no
> divisions by ten going on.

If you wanted to use the string representation then stepping is surely
going to be a win. Mind you, I'd use digit values rather that ASCII
0-9. Maybe that's what you were thinking anyway.

--
Ben.

Re: Losing my mind: results change with/without printf() statements

<87y2aoft70.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17191&group=comp.lang.c#17191

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
Date: Fri, 02 Jul 2021 19:48:19 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <87y2aoft70.fsf@bsb.me.uk>
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87a6n4hk4c.fsf@bsb.me.uk>
<20210702095301.721@kylheku.com> <874kdch9k0.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="eebc8e7d3a672789a70c7da0a5748a69";
logging-data="5910"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dOb0B/uHUrE9els5QT6u/onuFQkDr10I="
Cancel-Lock: sha1:Pvfw9tPQw2Fz0rlURre3HjOSrM4=
sha1:RPmF+9Y/FUEeDMcK8TS88gt/2RA=
X-BSB-Auth: 1.5e641671a8d9457605cf.20210702194819BST.87y2aoft70.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 2 Jul 2021 18:48 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> Kaz Kylheku <563-365-8930@kylheku.com> writes:

>> Dollars to doughnuts says this will beat sprintf because there are no
>> divisions by ten going on.
>
> If you wanted to use the string representation then stepping is surely
> going to be a win. Mind you, I'd use digit values rather that ASCII
> 0-9. Maybe that's what you were thinking anyway.

But neither stepping digits or running a counter can possibly get you to
10**19 in reasonable time. I estimate that, on laptop, just running a
loop from 1 to 10**19 will take more than 130 years.

--
Ben.

Re: Losing my mind: results change with/without printf() statements

<24d36adb-d592-49bd-8267-d73df5d07a5an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17225&group=comp.lang.c#17225

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:5c8c:: with SMTP id r12mr7487521qta.265.1625387275930;
Sun, 04 Jul 2021 01:27:55 -0700 (PDT)
X-Received: by 2002:a0c:edb0:: with SMTP id h16mr7945867qvr.33.1625387275829;
Sun, 04 Jul 2021 01:27:55 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 4 Jul 2021 01:27:55 -0700 (PDT)
In-Reply-To: <sbnima$7p0$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87im1vj6q3.fsf@bsb.me.uk> <O%aDI.906$tE4.1@fx29.iad>
<8735syjrwf.fsf@bsb.me.uk> <54aa8ed0-7069-44c8-a582-d05aa8541ac8n@googlegroups.com>
<87fswwhlu4.fsf@bsb.me.uk> <bf39ecc9-f6c8-499a-8fed-c17d725b10fbn@googlegroups.com>
<245d9902-b854-44d9-9a8e-f4fa2d2fd044n@googlegroups.com> <sbnima$7p0$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <24d36adb-d592-49bd-8267-d73df5d07a5an@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 04 Jul 2021 08:27:55 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Sun, 4 Jul 2021 08:27 UTC

On Friday, July 2, 2021 at 8:34:16 PM UTC+3, Bart wrote:
> On 02/07/2021 17:25, Michael S wrote:
> > On Friday, July 2, 2021 at 5:49:01 PM UTC+3, Michael S wrote:
> >> On Friday, July 2, 2021 at 4:44:33 PM UTC+3, Ben Bacarisse wrote:
>
> >>>> Does it include replacement of division by reciprocal multiplication?
> >>> No, it's a plain integer / and % version. Have you got one that does
> >>> something clever with the divisions?
> >>>
> >>> --
> >>> Ben.
> >> No, I didn't.
> >> Have more interesting things to do.
> >> Besides, brute force is so obvious dead end...
> >
> >
> > Just to prove to myself that brute force is dead end
> > Here is rather clever brute force.
> > It does 1e9 in 26 sec on my aging home PC (i5-3450).
> >
> > #include <stdint.h>
> > #include <stdbool.h>
> > #include <stdlib.h>
> > #include <stdio.h>
> >
> > static bool isOneChild(const uint8_t *digits, int nDigits, const uint8_t *remTab)
> > {
> > int nChilds = 0;
> > for (int beg = 0; beg < nDigits; ++beg) {
> > unsigned r = 0;
> > for (int end = beg; end < nDigits; ++end) {
> > r = remTab[r*10+digits[end]];
> > if (r == 0) {
> > ++nChilds;
> > }
> > }
> > if (nChilds > 1)
> > return false;
> > }
> > return nChilds == 1;
> > }
> >
> > static unsigned long long countOneChildsInRange(uint64_t first, uint64_t last, int nDigits, bool print)
> > {
> > // initialize look-up table
> > uint8_t remTab[200];
> > for (int i = 0; i < nDigits*10; ++i)
> > remTab[i] = i % nDigits;
> >
> > // initialize array of digits
> > uint8_t digits[20];
> > uint64_t x = first;
> > for (int i = 0; i < nDigits; ++i) {
> > digits[nDigits-1-i] = x % 10;
> > x /= 10;
> > }
> >
> > unsigned long long cnt = 0;
> > for (x = first; x <= last; ++x) {
> > if (isOneChild(digits, nDigits, remTab)) {
> > ++cnt;
> > if (print)
> > printf("%llu\n", (unsigned long long)x);
> > }
> > uint8_t lsDig = digits[nDigits-1] + 1;
> > digits[nDigits-1] = lsDig;
> > if (lsDig == 10) {
> > digits[nDigits-1] = 0;
> > for (int i = nDigits-2; i >= 0; --i) {
> > uint8_t d = digits[i] + 1;
> > if (d == 10) {
> > digits[i] = 0;
> > } else {
> > digits[i] = d;
> > break;
> > }
> > }
> > lsDig = 0;
> > }
> > }
> > return cnt;
> > }
> >
> > int count_digits(unsigned long long x)
> > {
> > int c = 0;
> > while (x) {
> > ++c;
> > x /= 10;
> > }
> > return c;
> > }
> >
> > unsigned long long ndig_max(int nDigits)
> > {
> > unsigned long long x = 1;
> > for (int i = 0; i < nDigits; ++i)
> > x *= 10;
> > return x - 1;
> > }
> >
> > int main(int argz, char** argv)
> > {
> > if (argz < 3) {
> > fprintf(stderr, "Consult DFS!\n");
> > return 1;
> > }
> >
> > char* endp;
> > unsigned long long first = strtoull(argv[1], &endp, 0);
> > if (endp == argv[1]) {
> > fprintf(stderr, "%s is not a number.\n", argv[1]);
> > return 1;
> > }
> >
> > unsigned long long last = strtoull(argv[2], &endp, 0);
> > if (endp == argv[2]) {
> > fprintf(stderr, "%s is not a number.\n", argv[2]);
> > return 1;
> > }
> >
> > bool print = false;
> > if (argz > 3 && argv[3][0]=='p')
> > print = true;
> >
> > unsigned long long cnt = 0;
> > while (first <= last) {
> > int nDigits = count_digits(first);
> > unsigned long long rangeLast = ndig_max(nDigits);
> > if (rangeLast > last)
> > rangeLast = last;
> > cnt += countOneChildsInRange(first, rangeLast, nDigits, print);
> > first = rangeLast + 1;
> > }
> > printf("Found %llu one-childs\n", cnt);
> >
> > return 0;
> > }
> Well, it's fast (about 65 seconds on my machine,

Your ability to enjoy slow PCs does not surprise me any more.

> perhaps 20 times as
> fast as my program).

If your program uses strings then only 20 times is a little disappointing.

> But I can't say it's that easy to follow!

Because I wrote it for myself, as a one time exercise and put in virtually no comments.
Still, even in commentless state, it's likely easier to follow for most people than
the code of DFS that started this thread.

>
> It seems to rely on the fact that consecutive numbers are being tested,
> so can optimise blocks all having the same numbers of digits. (Exactly
> how, I don't know yet.)
>
> So I guess it can't be used to get the one-child status of an arbitrary
> number.

It can. It just would be much slower at that then function built for a purpose of
examining a single number. But, I'd guess, even in this scenario it would be within
factor of 3-5 from the best speed achievable with atoi()/strtoull().

> That's probably the only advantage of the simpler algorithm,
> other than being simpler.

I did a simple "pure arithmetic" variant as well. It's really quite short and is closer to an ideal
of mindless brute force. It ended up ~7 times slower than the variant presented above which
is not that bad relatively to speed reported by other posters. Something like 1.5 times faster than
Ben's.

But utility of "mindless brute force" in this challenge is not to be fast, but too look fast and be slow,
in order to convince people that the challenge can't be solved on this path.

Re: Losing my mind: results change with/without printf() statements

<6751375f-4ddb-4ee3-b05a-919a0d57c306n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17226&group=comp.lang.c#17226

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:9d90:: with SMTP id g138mr8646588qke.212.1625394069734;
Sun, 04 Jul 2021 03:21:09 -0700 (PDT)
X-Received: by 2002:ac8:a84:: with SMTP id d4mr7821726qti.109.1625394069568;
Sun, 04 Jul 2021 03:21:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 4 Jul 2021 03:21:09 -0700 (PDT)
In-Reply-To: <87y2aoft70.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87a6n4hk4c.fsf@bsb.me.uk> <20210702095301.721@kylheku.com>
<874kdch9k0.fsf@bsb.me.uk> <87y2aoft70.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6751375f-4ddb-4ee3-b05a-919a0d57c306n@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 04 Jul 2021 10:21:09 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Sun, 4 Jul 2021 10:21 UTC

On Friday, July 2, 2021 at 9:48:30 PM UTC+3, Ben Bacarisse wrote:
> Ben Bacarisse <ben.u...@bsb.me.uk> writes:
> > Kaz Kylheku <563-36...@kylheku.com> writes:
>
> >> Dollars to doughnuts says this will beat sprintf because there are no
> >> divisions by ten going on.
> >
> > If you wanted to use the string representation then stepping is surely
> > going to be a win. Mind you, I'd use digit values rather that ASCII
> > 0-9. Maybe that's what you were thinking anyway.
> But neither stepping digits or running a counter can possibly get you to
> 10**19 in reasonable time. I estimate that, on laptop, just running a
> loop from 1 to 10**19 will take more than 130 years.
>
> --
> Ben.

I think that given ~10 GB of RAM I know how to solve it in approximately 300 core*months, which is borderline doable.
The idea is that, for the hardest case of 19 digits there are 32609741 9-digit strings with no children,
145677482 10-digit strings with no children, 173961837 9-digit strings with one child
and 1044700906 10-digit strings with one child. We can keep all those strings in memory
and examine all combinations of no children with no children and of no children with one child.

For 18 digits there are 68336577 9-digit strings with no children and 176666866 9-digit strings with one child. So, several times fewer suspect combinations.

For 17 digits there are 23501420 9-digit strings with no children,
5218154 8-digit strings with no children, 147342610 9-digit strings with one child
and 23421431 8-digit strings with one child.

For 16 digits there are 17401442 8-digit strings with no children and 25360875 8-digit strings with one child.

And so on, fewer digits, the easier.

But the challenge appears to suggest that it should be done in 1 minute of compute time.
So far, I didn't figure out how to do it so quickly.

Re: Losing my mind: results change with/without printf() statements

<87o8bicjxo.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17230&group=comp.lang.c#17230

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
Date: Sun, 04 Jul 2021 14:01:07 +0100
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <87o8bicjxo.fsf@bsb.me.uk>
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87a6n4hk4c.fsf@bsb.me.uk>
<20210702095301.721@kylheku.com> <874kdch9k0.fsf@bsb.me.uk>
<87y2aoft70.fsf@bsb.me.uk>
<6751375f-4ddb-4ee3-b05a-919a0d57c306n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="88b05831db0d35b478f9edb0e6f6324f";
logging-data="17620"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18THP9/NCYls5I76HlhbiihlGNFlwFXEWc="
Cancel-Lock: sha1:3cdMFI1S3/1CLPJZoTMfrTEp5aI=
sha1:sd+UMG057KUCtwDxbosySAu73UQ=
X-BSB-Auth: 1.da41db12d4c392152a9d.20210704140107BST.87o8bicjxo.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 4 Jul 2021 13:01 UTC

Michael S <already5chosen@yahoo.com> writes:

> But the challenge appears to suggest that it should be done in 1
> minute of compute time. So far, I didn't figure out how to do it so
> quickly.

No, me neither. And I'm not usually drawn to problems that use an
arbitrary base (my code had a base argument in case there was something
interesting about other bases) so I've not given it much thought. But I
admit to be being intrigued now.

--
Ben.

Re: Losing my mind: results change with/without printf() statements

<sbsg26$jj4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17232&group=comp.lang.c#17232

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
Date: Sun, 4 Jul 2021 15:19:37 +0100
Organization: A noiseless patient Spider
Lines: 75
Message-ID: <sbsg26$jj4$1@dont-email.me>
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87im1vj6q3.fsf@bsb.me.uk>
<O%aDI.906$tE4.1@fx29.iad> <8735syjrwf.fsf@bsb.me.uk>
<54aa8ed0-7069-44c8-a582-d05aa8541ac8n@googlegroups.com>
<87fswwhlu4.fsf@bsb.me.uk>
<bf39ecc9-f6c8-499a-8fed-c17d725b10fbn@googlegroups.com>
<245d9902-b854-44d9-9a8e-f4fa2d2fd044n@googlegroups.com>
<sbnima$7p0$1@dont-email.me>
<24d36adb-d592-49bd-8267-d73df5d07a5an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 4 Jul 2021 14:19:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f27073adb751738c5190c9ed9c657862";
logging-data="20068"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TEy+WN6ihBqtdv3W+JmJk3dMVzHY+Txc="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:7odfDJLpAHZplaXYmxXeu0BA0Qo=
In-Reply-To: <24d36adb-d592-49bd-8267-d73df5d07a5an@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210704-2, 04/07/2021), Outbound message
 by: Bart - Sun, 4 Jul 2021 14:19 UTC

On 04/07/2021 09:27, Michael S wrote:
> On Friday, July 2, 2021 at 8:34:16 PM UTC+3, Bart wrote:

>> Well, it's fast (about 65 seconds on my machine,
>
> Your ability to enjoy slow PCs does not surprise me any more.

It's not that slow if my 2010 AMD-whatever is only 2.5 times as slow as
an Intel i5. Or is your main machine even faster?

(My machine can build all of my language projects from scratch (some 100
modules and 150Kloc) in about half a second. The compiler isn't even
optimised. It's hard to see the benefit of spending £100s on a faster
machine.)

>
>> perhaps 20 times as
>> fast as my program).
>
> If your program uses strings then only 20 times is a little disappointing.

You mean, you expected it to be slower (more than 20 times) or faster?

I didn't make any attempt at a fast program except to implement a
slightly simpler algorithm than the OP's, and one I could understand.

But since it depends heavily on atoll(), I made a custom version of that
(in newstrsubstring() below). That made it 3 times faster.

I then got a further 50% boost by replacing sprintf with atoi.

Now it's only about 4.5 times slower than your version. (290 seconds vs
66 seconds for F(10^9).)

So if yours was to take 7,000 years for F(10^9) based on your i5, mine
would now take only 30,000 years instead of 140,000. Lopping off 110,000
years is not a bad result for 5 minutes' work...

------------------------------------------

u64 strsubstring(char* s, int length) {
u64 result;
char c;

c=s[length];
s[length]=0;
result=atoll(s);
s[length]=c;
return result;
}

u64 newstrsubstring(char* s, int length) {
// length should be >=1
u64 result;

result=*s-'0';
++s;
while (--length) {
result=result*10+*s -'0';
++s;
}
return result;
}

>> That's probably the only advantage of the simpler algorithm,
>> other than being simpler.
>
> I did a simple "pure arithmetic" variant as well. It's really quite short and is closer to an ideal
> of mindless brute force. It ended up ~7 times slower than the variant presented above which
> is not that bad relatively to speed reported by other posters. Something like 1.5 times faster than
> Ben's.

So somewhat slower than mine now, but mine still uses strings.

Re: Losing my mind: results change with/without printf() statements

<01e776b0-f487-43a4-a4d3-2d8f5319ba42n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17234&group=comp.lang.c#17234

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ae9:ed4c:: with SMTP id c73mr9586545qkg.37.1625414678881;
Sun, 04 Jul 2021 09:04:38 -0700 (PDT)
X-Received: by 2002:ae9:de47:: with SMTP id s68mr9893754qkf.39.1625414678743;
Sun, 04 Jul 2021 09:04:38 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 4 Jul 2021 09:04:38 -0700 (PDT)
In-Reply-To: <sbsg26$jj4$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87im1vj6q3.fsf@bsb.me.uk> <O%aDI.906$tE4.1@fx29.iad>
<8735syjrwf.fsf@bsb.me.uk> <54aa8ed0-7069-44c8-a582-d05aa8541ac8n@googlegroups.com>
<87fswwhlu4.fsf@bsb.me.uk> <bf39ecc9-f6c8-499a-8fed-c17d725b10fbn@googlegroups.com>
<245d9902-b854-44d9-9a8e-f4fa2d2fd044n@googlegroups.com> <sbnima$7p0$1@dont-email.me>
<24d36adb-d592-49bd-8267-d73df5d07a5an@googlegroups.com> <sbsg26$jj4$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <01e776b0-f487-43a4-a4d3-2d8f5319ba42n@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 04 Jul 2021 16:04:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5753
 by: Michael S - Sun, 4 Jul 2021 16:04 UTC

On Sunday, July 4, 2021 at 5:20:01 PM UTC+3, Bart wrote:
> On 04/07/2021 09:27, Michael S wrote:
> > On Friday, July 2, 2021 at 8:34:16 PM UTC+3, Bart wrote:
>
> >> Well, it's fast (about 65 seconds on my machine,
> >
> > Your ability to enjoy slow PCs does not surprise me any more.
> It's not that slow if my 2010 AMD-whatever is only 2.5 times as slow as
> an Intel i5. Or is your main machine even faster?

This home desktop is from 2012 and even then was considered inexpensive, while not the cheapest possible.
Naturally, PCs I use to do a "real work" like FPGA development are significantly faster.

>
> (My machine can build all of my language projects from scratch (some 100
> modules and 150Kloc) in about half a second. The compiler isn't even
> optimised. It's hard to see the benefit of spending £100s on a faster
> machine.)

Comfortable web browsing, may be?

> >
> >> perhaps 20 times as
> >> fast as my program).
> >
> > If your program uses strings then only 20 times is a little disappointing.
> You mean, you expected it to be slower (more than 20 times) or faster?
>

I meant to say that I expected for may program to be more than 20 times faster than variants resembling one in the first post of this thread.

> I didn't make any attempt at a fast program except to implement a
> slightly simpler algorithm than the OP's, and one I could understand.
>
> But since it depends heavily on atoll(), I made a custom version of that
> (in newstrsubstring() below). That made it 3 times faster.
>
> I then got a further 50% boost by replacing sprintf with atoi.
>
> Now it's only about 4.5 times slower than your version. (290 seconds vs
> 66 seconds for F(10^9).)
>

Well, string-to-number and number-to-string conversions are biggest offenders in original code.
Or did he also have memory allocation in the inner loop? I don't remember.
So, if you replaced conversions with custom routines, you're already pretty close to my variant.
The only remaining major difference is my use of look-up tables instead of modulo operations.
I also saved a little time by not doing number-to-string conversion in the 3rd innermost loop,
for (x = first; x <= last; ++x) {...}
but that's probably not very significant if at all significant.

> So if yours was to take 7,000 years for F(10^9) based on your i5, mine
> would now take only 30,000 years instead of 140,000. Lopping off 110,000
> years is not a bad result for 5 minutes' work...
>

You mean F(10**19) ?
I am afraid your estimate is too optimistic, at least for your code and your PC.
I expect F(10**19) to take 4*1e10 as much time as F(10**9), which would be 370,000 years.

> ------------------------------------------
> u64 strsubstring(char* s, int length) {
> u64 result;
> char c;
>
> c=s[length];
> s[length]=0;
> result=atoll(s);
> s[length]=c;
> return result;
> }
> u64 newstrsubstring(char* s, int length) {
> // length should be >=1
> u64 result;
>
> result=*s-'0';
> ++s;
> while (--length) {
> result=result*10+*s -'0';
> ++s;
> }
> return result;
> }
>
>
> >> That's probably the only advantage of the simpler algorithm,
> >> other than being simpler.
> >
> > I did a simple "pure arithmetic" variant as well. It's really quite short and is closer to an ideal
> > of mindless brute force. It ended up ~7 times slower than the variant presented above which
> > is not that bad relatively to speed reported by other posters. Something like 1.5 times faster than
> > Ben's.
> So somewhat slower than mine now, but mine still uses strings.

But running "arithmetic" variant on my home PC is faster than your code on your home PC :-)
BTW, I don't think that your code could be still considered as "uses strings" in C language sense of the word.

Re: Losing my mind: results change with/without printf() statements

<56760a84-4b88-411d-8480-84c6b7972b76n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17235&group=comp.lang.c#17235

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ae9:f40d:: with SMTP id y13mr10201843qkl.100.1625417499278;
Sun, 04 Jul 2021 09:51:39 -0700 (PDT)
X-Received: by 2002:a0c:edb0:: with SMTP id h16mr9577370qvr.33.1625417499163;
Sun, 04 Jul 2021 09:51:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!feeder1.cambriumusenet.nl!feed.tweak.nl!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 4 Jul 2021 09:51:38 -0700 (PDT)
In-Reply-To: <01e776b0-f487-43a4-a4d3-2d8f5319ba42n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87im1vj6q3.fsf@bsb.me.uk> <O%aDI.906$tE4.1@fx29.iad>
<8735syjrwf.fsf@bsb.me.uk> <54aa8ed0-7069-44c8-a582-d05aa8541ac8n@googlegroups.com>
<87fswwhlu4.fsf@bsb.me.uk> <bf39ecc9-f6c8-499a-8fed-c17d725b10fbn@googlegroups.com>
<245d9902-b854-44d9-9a8e-f4fa2d2fd044n@googlegroups.com> <sbnima$7p0$1@dont-email.me>
<24d36adb-d592-49bd-8267-d73df5d07a5an@googlegroups.com> <sbsg26$jj4$1@dont-email.me>
<01e776b0-f487-43a4-a4d3-2d8f5319ba42n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <56760a84-4b88-411d-8480-84c6b7972b76n@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 04 Jul 2021 16:51:39 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Sun, 4 Jul 2021 16:51 UTC

On Sunday, July 4, 2021 at 7:04:46 PM UTC+3, Michael S wrote:
> I also saved a little time by not doing number-to-string conversion in the 3rd innermost loop,
> for (x = first; x <= last; ++x) {...}
> but that's probably not very significant if at all significant.

I measured it.
Without this optimization the programs runs ~1.5 times slower. So, optimization is not insignificant.
But I admit that at minimal performance cost it can be expressed in more comprehensible way.

Re: Losing my mind: results change with/without printf() statements

<5c9ca972-f228-4702-81b3-4823bb06e49bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17246&group=comp.lang.c#17246

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:4a18:: with SMTP id x24mr11625548qtq.239.1625478279554;
Mon, 05 Jul 2021 02:44:39 -0700 (PDT)
X-Received: by 2002:ae9:e911:: with SMTP id x17mr12962157qkf.371.1625478279367;
Mon, 05 Jul 2021 02:44:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 5 Jul 2021 02:44:39 -0700 (PDT)
In-Reply-To: <87o8bicjxo.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87a6n4hk4c.fsf@bsb.me.uk> <20210702095301.721@kylheku.com>
<874kdch9k0.fsf@bsb.me.uk> <87y2aoft70.fsf@bsb.me.uk> <6751375f-4ddb-4ee3-b05a-919a0d57c306n@googlegroups.com>
<87o8bicjxo.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5c9ca972-f228-4702-81b3-4823bb06e49bn@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 05 Jul 2021 09:44:39 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Mon, 5 Jul 2021 09:44 UTC

On Sunday, July 4, 2021 at 4:01:17 PM UTC+3, Ben Bacarisse wrote:
> Michael S <already...@yahoo.com> writes:
>
> > But the challenge appears to suggest that it should be done in 1
> > minute of compute time. So far, I didn't figure out how to do it so
> > quickly.
> No, me neither. And I'm not usually drawn to problems that use an
> arbitrary base (my code had a base argument in case there was something
> interesting about other bases) so I've not given it much thought. But I
> admit to be being intrigued now.
>
> --
> Ben.

I did something that I should have do from the beginning - estimate of result by Monte Carlo method (with 10M random samples per range).
Estimate = 3.1e15, majority of it in 18-digit and 16-digit ranges.
3.1e15 * 1 nsec = 35 days.
It means that algorithms that are based on examination of each and every results are hopeless even if preliminary filtering
before examination is near-perfect and final examination is blazingly fast.

Re: Losing my mind: results change with/without printf() statements

<87a6n0c1ux.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17254&group=comp.lang.c#17254

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
Date: Mon, 05 Jul 2021 14:43:50 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <87a6n0c1ux.fsf@bsb.me.uk>
References: <vW0DI.53$h45.18@fx16.iad> <sbi84p$ajn$1@dont-email.me>
<Yg2DI.3867$mR.1082@fx33.iad> <hY2DI.505463$N5n7.405017@fx05.ams4>
<Gi4DI.1867$t64.414@fx13.iad> <87a6n4hk4c.fsf@bsb.me.uk>
<20210702095301.721@kylheku.com> <874kdch9k0.fsf@bsb.me.uk>
<87y2aoft70.fsf@bsb.me.uk>
<6751375f-4ddb-4ee3-b05a-919a0d57c306n@googlegroups.com>
<87o8bicjxo.fsf@bsb.me.uk>
<5c9ca972-f228-4702-81b3-4823bb06e49bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="70c6db9135c38e0959c01bebe7c472dd";
logging-data="30053"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Y6YK6lY40sGVdcml4u1kV7b0gF1ssdgk="
Cancel-Lock: sha1:XK3Mx2BLZjrnRCYFYeRArhCD1pg=
sha1:dl5//I4qt7z95TcNZXRGWEJ4Mys=
X-BSB-Auth: 1.4a9301c5a56241b29e00.20210705144350BST.87a6n0c1ux.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 5 Jul 2021 13:43 UTC

Michael S <already5chosen@yahoo.com> writes:

> On Sunday, July 4, 2021 at 4:01:17 PM UTC+3, Ben Bacarisse wrote:
>> Michael S <already...@yahoo.com> writes:
>>
>> > But the challenge appears to suggest that it should be done in 1
>> > minute of compute time. So far, I didn't figure out how to do it so
>> > quickly.
>> No, me neither. And I'm not usually drawn to problems that use an
>> arbitrary base (my code had a base argument in case there was something
>> interesting about other bases) so I've not given it much thought. But I
>> admit to be being intrigued now.
>>
>
> I did something that I should have do from the beginning - estimate of
> result by Monte Carlo method (with 10M random samples per range).
> Estimate = 3.1e15, majority of it in 18-digit and 16-digit ranges.
> 3.1e15 * 1 nsec = 35 days. It means that algorithms that are based on
> examination of each and every results are hopeless even if preliminary
> filtering before examination is near-perfect and final examination is
> blazingly fast.

Interesting. Thanks.

--
Ben.

Re: Losing my mind: results change with/without printf() statements

<2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17275&group=comp.lang.c#17275

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 05 Jul 2021 19:42:48 -0500
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
References: <vW0DI.53$h45.18@fx16.iad> <87o8bicjxo.fsf@bsb.me.uk> <5c9ca972-f228-4702-81b3-4823bb06e49bn@googlegroups.com> <87a6n0c1ux.fsf@bsb.me.uk>
Organization: provalid.com
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
From: keg...@provalid.com (Kent Dickey)
Originator: kegs@provalid.com (Kent Dickey)
Message-ID: <2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com>
Date: Mon, 05 Jul 2021 19:42:48 -0500
Lines: 277
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-K8ufHiTnuYbX8OdOHdPQfkJkMbqICnR6LfENpOu5N0IfFxslZLpN/Qy8bJ5zcugjrlNDZ74uOMSjUkb!CaPgEO5fm0c6VQmmb6iEjaeKP2uLV2PKQgfpM5RAGVsTl7RLIx7H8VncSkPT9YHV81iw4/VdJbE=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 8303
 by: Kent Dickey - Tue, 6 Jul 2021 00:42 UTC

In article <87a6n0c1ux.fsf@bsb.me.uk>,
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>Michael S <already5chosen@yahoo.com> writes:
>
>> On Sunday, July 4, 2021 at 4:01:17 PM UTC+3, Ben Bacarisse wrote:
>>> Michael S <already...@yahoo.com> writes:
>>>
>>> > But the challenge appears to suggest that it should be done in 1
>>> > minute of compute time. So far, I didn't figure out how to do it so
>>> > quickly.
>>> No, me neither. And I'm not usually drawn to problems that use an
>>> arbitrary base (my code had a base argument in case there was something
>>> interesting about other bases) so I've not given it much thought. But I
>>> admit to be being intrigued now.
>>>
>>
>> I did something that I should have do from the beginning - estimate of
>> result by Monte Carlo method (with 10M random samples per range).
>> Estimate = 3.1e15, majority of it in 18-digit and 16-digit ranges.
>> 3.1e15 * 1 nsec = 35 days. It means that algorithms that are based on
>> examination of each and every results are hopeless even if preliminary
>> filtering before examination is near-perfect and final examination is
>> blazingly fast.
>
>Interesting. Thanks.
>
>--
>Ben.

I wrote 2 programs to try to calculate this.

First, there's no nead to atoi/sprintf or whatever. Just do operations
on an array of bytes, and form the numbers with num = (num * 10) + dig
as needed. I'll attach my initial code to show the basic idea.

My main idea was to do exclusion based on initial digits. If the first
five digits (for an example) of an 11-digit number have two children,
then we don't need to look at any more of the remaining 6 digits: we can skip
them all with next = cur + (10^6).

I've gotten through 10^10. All 10-digit numbers have no one-childs (I didn't
realize this until the code finished). Let's say the number is 1234567890.
This has the number 0 and 90 (and others) which are multiples of 10, so no
one child. To be divisible by 10, we need exactly one digit to be 0. But then
we have 0 and some multiple of 10 due to the previous digit--so no one-childs.
So code should just skip all 10-digit numbers.

My next idea was to pre-calc for each digit length (as we move to 11 digit
numbers, calculate using a divisor of 11, for example), pre-calculate the
children for all 6 digit numbers from 000000 to 999999 using that length
divisor. Use this for initial prunings, and to avoid doing any checking
of 1-to-5 digit numbers (it's all rolled up). We need just 3 answers (2 bis)
of info per numbers: 0 children, 1 child, 2+ children. It's probably not worth
it to pack 4 results per byte, but maybe it is. Code still must check 7+
digit sequences with divides, but this takes away a lot of work.

So, 1-8 digit numbers took 5 seconds. 1-9 digit numbers took 11 seconds--
so just over twice as long.

Here's the basic code:

// See https://projecteuler.net/problem=413

#include <stdio.h>
#include <stdlib.h>

typedef unsigned long long dword64;
typedef unsigned int word32;
typedef unsigned char byte;

int
calc_one_child(byte *bptr, int len)
{ dword64 num, div_val, div;
int num_divs;
int i, thislen, j;

div_val = len;
num_divs = 0;
#if 0
printf("calc_one_child, len:%d, value:%d%d%d%d\n", len,
bptr[3], bptr[2], bptr[1], bptr[0]);
#endif
for(i = len - 1; i >= 0; i--) {
// printf("i:%d\n", i);
for(thislen = 1; thislen <= (i+1); thislen++) {
num = 0;
for(j = 0; j < thislen; j++) {
num = (num * 10) + bptr[i - j];
// printf(" this_len:%d, j:%d\n", thislen, j);
}
div = num / div_val;
if((div * div_val) == num) {
num_divs++;
#if 0
printf("num:%d is divisible by %d\n", num,
div_val);
#endif
if(num_divs >= 2) {
return num_divs;
}
}
}
}
return num_divs;
}

int
main(int argc, char **argv)
{ byte array[20];
dword64 dstart, dend, dtmp, dcount, dstart_save;
int len, ret;
int i;

if(argc < 3) {
fprintf(stderr, "Usage: %s start end\n", argv[0]);
exit(1);
}
dstart = strtoll(argv[1], 0, 0);
dstart_save = dstart;
dend = strtoll(argv[2], 0, 0);
for(i = 0; i < 20; i++) {
array[i] = 0;
}
dtmp = dstart;
len = 0;
for(i = 0; i < 20; i++) {
array[i] = dtmp % 10;
dtmp = dtmp / 10;
if(dtmp == 0) {
len = i + 1;
break;
}
}
printf("len: %d\n", len);

dcount = 0;
while(dstart < dend) {
ret = calc_one_child(&array[0], len);
if(ret == 1) {
// printf("%lld is a one-child\n", dstart);
dcount++;
}
dstart++;
for(i = 0; i < 20; i++) {
array[i]++;
if(array[i] < 10) {
break;
}
array[i] = 0;
if(len < (i + 2)) {
len = i + 2;
}
}
}
printf("One-child between %lld and %lld = %lld\n", dstart_save, dend,
dcount);
}

And here's the code with some pruning ability (it forms the numbers more
efficiently, which save about 20% as well):

// See https://projecteuler.net/problem=413

#include <stdio.h>
#include <stdlib.h>

typedef unsigned long long dword64;
typedef unsigned int word32;
typedef unsigned char byte;

#define DO_PRINT 0

int
calc_one_child(byte *bptr, int len)
{ dword64 num, div_val, div, mul;
int num_divs;
int i, j;

div_val = len;
num_divs = 0;
#if DO_PRINT
printf("calc_one_child, len:%d, value:%d%d%d%d\n", len,
bptr[3], bptr[2], bptr[1], bptr[0]);
#endif
for(i = len - 1; i >= 0; i--) {
// This is the 'end' digit, look to higher MSBs
#if DO_PRINT
printf("i:%d\n", i);
#endif
num = 0;
mul = 1;
for(j = i; j < len; j++) {
num = num + (bptr[j] * mul);
mul = mul * 10;
div = num / div_val;
#if DO_PRINT
printf("j:%d %lld / %lld = %lld\n", j,
num, div_val, div);
#endif
if((div * div_val) == num) {
num_divs++;
#if DO_PRINT
printf("num:%lld is divisible by %lld\n",
(dword64)num, (dword64)div_val);
#endif
if(num_divs >= 2) {
return i;
}
}
}
}
return -num_divs; // 1->-1, 0->0
}

int
main(int argc, char **argv)
{ byte array[20];
dword64 dstart, dend, dtmp, dcount, dstart_save, dinc;
int len, ret;
int i;

if(argc < 3) {
fprintf(stderr, "Usage: %s start end\n", argv[0]);
exit(1);
}
dstart = strtoll(argv[1], 0, 0);
dstart_save = dstart;
dend = strtoll(argv[2], 0, 0);
for(i = 0; i < 20; i++) {
array[i] = 0;
}
dtmp = dstart;
len = 0;
for(i = 0; i < 20; i++) {
array[i] = dtmp % 10;
dtmp = dtmp / 10;
if(dtmp == 0) {
len = i + 1;
break;
}
}
printf("len: %d\n", len);

dcount = 0;
while(dstart < dend) {
ret = calc_one_child(&array[0], len);
if(ret < 0) {
#if DO_PRINT
printf("%lld is a one-child\n", dstart);
#endif
dcount++;
ret = 0;
}
dinc = 1;
for(i = 0; i < ret; i++) {
array[i] = 0;
dinc = dinc * 10;
}
dstart += dinc;
for(; i < 20; i++) {
array[i]++;
if(array[i] < 10) {
break;
}
array[i] = 0;
if(len < (i + 2)) {
len = i + 2;
}
}
}
printf("One-child between %lld and %lld = %lld\n", dstart_save, dend,
dcount);
}

Re: Losing my mind: results change with/without printf() statements

<c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17283&group=comp.lang.c#17283

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:4b:: with SMTP id c11mr17229739qvr.18.1625567812032; Tue, 06 Jul 2021 03:36:52 -0700 (PDT)
X-Received: by 2002:a05:620a:4e5:: with SMTP id b5mr6600320qkh.7.1625567811875; Tue, 06 Jul 2021 03:36:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 6 Jul 2021 03:36:51 -0700 (PDT)
In-Reply-To: <2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <vW0DI.53$h45.18@fx16.iad> <87o8bicjxo.fsf@bsb.me.uk> <5c9ca972-f228-4702-81b3-4823bb06e49bn@googlegroups.com> <87a6n0c1ux.fsf@bsb.me.uk> <2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Tue, 06 Jul 2021 10:36:52 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 313
 by: Michael S - Tue, 6 Jul 2021 10:36 UTC

On Tuesday, July 6, 2021 at 3:43:03 AM UTC+3, Kent Dickey wrote:
> In article <87a6n0c...@bsb.me.uk>,
> Ben Bacarisse <ben.u...@bsb.me.uk> wrote:
> >Michael S <already...@yahoo.com> writes:
> >
> >> On Sunday, July 4, 2021 at 4:01:17 PM UTC+3, Ben Bacarisse wrote:
> >>> Michael S <already...@yahoo.com> writes:
> >>>
> >>> > But the challenge appears to suggest that it should be done in 1
> >>> > minute of compute time. So far, I didn't figure out how to do it so
> >>> > quickly.
> >>> No, me neither. And I'm not usually drawn to problems that use an
> >>> arbitrary base (my code had a base argument in case there was something
> >>> interesting about other bases) so I've not given it much thought. But I
> >>> admit to be being intrigued now.
> >>>
> >>
> >> I did something that I should have do from the beginning - estimate of
> >> result by Monte Carlo method (with 10M random samples per range).
> >> Estimate = 3.1e15, majority of it in 18-digit and 16-digit ranges.
> >> 3.1e15 * 1 nsec = 35 days. It means that algorithms that are based on
> >> examination of each and every results are hopeless even if preliminary
> >> filtering before examination is near-perfect and final examination is
> >> blazingly fast.
> >
> >Interesting. Thanks.
> >
> >--
> >Ben.
> I wrote 2 programs to try to calculate this.
>
> First, there's no nead to atoi/sprintf or whatever. Just do operations
> on an array of bytes, and form the numbers with num = (num * 10) + dig
> as needed. I'll attach my initial code to show the basic idea.
>
> My main idea was to do exclusion based on initial digits. If the first
> five digits (for an example) of an 11-digit number have two children,
> then we don't need to look at any more of the remaining 6 digits: we can skip
> them all with next = cur + (10^6).
>
> I've gotten through 10^10. All 10-digit numbers have no one-childs (I didn't
> realize this until the code finished). Let's say the number is 1234567890..
> This has the number 0 and 90 (and others) which are multiples of 10, so no
> one child. To be divisible by 10, we need exactly one digit to be 0. But then
> we have 0 and some multiple of 10 due to the previous digit--so no one-childs.
> So code should just skip all 10-digit numbers.
>
> My next idea was to pre-calc for each digit length (as we move to 11 digit
> numbers, calculate using a divisor of 11, for example), pre-calculate the
> children for all 6 digit numbers from 000000 to 999999 using that length
> divisor. Use this for initial prunings, and to avoid doing any checking
> of 1-to-5 digit numbers (it's all rolled up). We need just 3 answers (2 bis)
> of info per numbers: 0 children, 1 child, 2+ children. It's probably not worth
> it to pack 4 results per byte, but maybe it is. Code still must check 7+
> digit sequences with divides, but this takes away a lot of work.
>
> So, 1-8 digit numbers took 5 seconds. 1-9 digit numbers took 11 seconds--
> so just over twice as long.
>
> Here's the basic code:
>
> // See https://projecteuler.net/problem=413
>
> #include <stdio.h>
> #include <stdlib.h>
>
> typedef unsigned long long dword64;
> typedef unsigned int word32;
> typedef unsigned char byte;
>
> int
> calc_one_child(byte *bptr, int len)
> {
> dword64 num, div_val, div;
> int num_divs;
> int i, thislen, j;
>
> div_val = len;
> num_divs = 0;
> #if 0
> printf("calc_one_child, len:%d, value:%d%d%d%d\n", len,
> bptr[3], bptr[2], bptr[1], bptr[0]);
> #endif
> for(i = len - 1; i >= 0; i--) {
> // printf("i:%d\n", i);
> for(thislen = 1; thislen <= (i+1); thislen++) {
> num = 0;
> for(j = 0; j < thislen; j++) {
> num = (num * 10) + bptr[i - j];
> // printf(" this_len:%d, j:%d\n", thislen, j);
> }
> div = num / div_val;
> if((div * div_val) == num) {
> num_divs++;
> #if 0
> printf("num:%d is divisible by %d\n", num,
> div_val);
> #endif
> if(num_divs >= 2) {
> return num_divs;
> }
> }
> }
> }
> return num_divs;
> }
>
> int
> main(int argc, char **argv)
> {
> byte array[20];
> dword64 dstart, dend, dtmp, dcount, dstart_save;
> int len, ret;
> int i;
>
> if(argc < 3) {
> fprintf(stderr, "Usage: %s start end\n", argv[0]);
> exit(1);
> }
> dstart = strtoll(argv[1], 0, 0);
> dstart_save = dstart;
> dend = strtoll(argv[2], 0, 0);
> for(i = 0; i < 20; i++) {
> array[i] = 0;
> }
> dtmp = dstart;
> len = 0;
> for(i = 0; i < 20; i++) {
> array[i] = dtmp % 10;
> dtmp = dtmp / 10;
> if(dtmp == 0) {
> len = i + 1;
> break;
> }
> }
> printf("len: %d\n", len);
>
> dcount = 0;
> while(dstart < dend) {
> ret = calc_one_child(&array[0], len);
> if(ret == 1) {
> // printf("%lld is a one-child\n", dstart);
> dcount++;
> }
> dstart++;
> for(i = 0; i < 20; i++) {
> array[i]++;
> if(array[i] < 10) {
> break;
> }
> array[i] = 0;
> if(len < (i + 2)) {
> len = i + 2;
> }
> }
> }
> printf("One-child between %lld and %lld = %lld\n", dstart_save, dend,
> dcount);
> }
>
> And here's the code with some pruning ability (it forms the numbers more
> efficiently, which save about 20% as well):
>
> // See https://projecteuler.net/problem=413
>
> #include <stdio.h>
> #include <stdlib.h>
>
> typedef unsigned long long dword64;
> typedef unsigned int word32;
> typedef unsigned char byte;
>
> #define DO_PRINT 0
>
> int
> calc_one_child(byte *bptr, int len)
> {
> dword64 num, div_val, div, mul;
> int num_divs;
> int i, j;
>
> div_val = len;
> num_divs = 0;
> #if DO_PRINT
> printf("calc_one_child, len:%d, value:%d%d%d%d\n", len,
> bptr[3], bptr[2], bptr[1], bptr[0]);
> #endif
> for(i = len - 1; i >= 0; i--) {
> // This is the 'end' digit, look to higher MSBs
> #if DO_PRINT
> printf("i:%d\n", i);
> #endif
> num = 0;
> mul = 1;
> for(j = i; j < len; j++) {
> num = num + (bptr[j] * mul);
> mul = mul * 10;
> div = num / div_val;
> #if DO_PRINT
> printf("j:%d %lld / %lld = %lld\n", j,
> num, div_val, div);
> #endif
> if((div * div_val) == num) {
> num_divs++;
> #if DO_PRINT
> printf("num:%lld is divisible by %lld\n",
> (dword64)num, (dword64)div_val);
> #endif
> if(num_divs >= 2) {
> return i;
> }
> }
> }
> }
> return -num_divs; // 1->-1, 0->0
> }
>
> int
> main(int argc, char **argv)
> {
> byte array[20];
> dword64 dstart, dend, dtmp, dcount, dstart_save, dinc;
> int len, ret;
> int i;
>
> if(argc < 3) {
> fprintf(stderr, "Usage: %s start end\n", argv[0]);
> exit(1);
> }
> dstart = strtoll(argv[1], 0, 0);
> dstart_save = dstart;
> dend = strtoll(argv[2], 0, 0);
> for(i = 0; i < 20; i++) {
> array[i] = 0;
> }
> dtmp = dstart;
> len = 0;
> for(i = 0; i < 20; i++) {
> array[i] = dtmp % 10;
> dtmp = dtmp / 10;
> if(dtmp == 0) {
> len = i + 1;
> break;
> }
> }
> printf("len: %d\n", len);
>
> dcount = 0;
> while(dstart < dend) {
> ret = calc_one_child(&array[0], len);
> if(ret < 0) {
> #if DO_PRINT
> printf("%lld is a one-child\n", dstart);
> #endif
> dcount++;
> ret = 0;
> }
> dinc = 1;
> for(i = 0; i < ret; i++) {
> array[i] = 0;
> dinc = dinc * 10;
> }
> dstart += dinc;
> for(; i < 20; i++) {
> array[i]++;
> if(array[i] < 10) {
> break;
> }
> array[i] = 0;
> if(len < (i + 2)) {
> len = i + 2;
> }
> }
> }
> printf("One-child between %lld and %lld = %lld\n", dstart_save, dend,
> dcount);
> }


Click here to read the complete article
Re: Losing my mind: results change with/without printf() statements

<a_CdnUJgh4wOD3n9nZ2dnUU7-XvNnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17287&group=comp.lang.c#17287

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 06 Jul 2021 12:27:46 -0500
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
References: <vW0DI.53$h45.18@fx16.iad> <87a6n0c1ux.fsf@bsb.me.uk> <2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com> <c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com>
Organization: provalid.com
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
From: keg...@provalid.com (Kent Dickey)
Originator: kegs@provalid.com (Kent Dickey)
Message-ID: <a_CdnUJgh4wOD3n9nZ2dnUU7-XvNnZ2d@giganews.com>
Date: Tue, 06 Jul 2021 12:27:47 -0500
Lines: 58
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-JDaQfybzo3IYUUh09pcDXZ0G4zx05wiFSSMy55GS0DOIX1YvINMxWG+gAt7AvPEQUjaqUE+ctZIA1Dp!FBp9vfsb1AUwANEwEbmvwp7/V0M7XeQA2etEJFDSPOSeLSWNW1hFqJbO2lAtNjcXqiWWs4l6Drg=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 4375
 by: Kent Dickey - Tue, 6 Jul 2021 17:27 UTC

In article <c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com>,
Michael S <already5chosen@yahoo.com> wrote:
>
>Those are still variations of the theme that I outlined in the post from
>Jul 4, 2021, 1:21:16 PM
>As proven in the post from Jul 5, 2021, 12:44:48 PM, as far as original
>1=19 digits challenge is concerned, it's a dead end.
>In order to tackle the original challenge, the positive (one-child)
>results should somehow be discovered and counted in bunches of of at
>least thousands (preferably 100s of thousands) rather than one-by-one.
>Just rejecting negatives in bunches is not sufficient.

I was just posting code I wrote before your posts.

I did not see any "proofs", there was a post with some numbers, with no
explanation of where they came from or why we should believe it. I wrote
some code to get some idea if pruning would work--and for some ranges, it's
very effective, for other ranges, it's not effective at all. Basically,
to see the timing differences for different ranges. My pruning code showed:

size runtime factor number of 1-childs
10^6: 0.046 secs = = 116652
10^7: 0.231 secs = 5.02x = 277674
10^8: 5.374 secs = 23.2x = 13346257
10^9: 11.463 secs =2.13x = 15483217

This shows pruning working very effectively for 10^9. But 8-digit numbers
have so many 1-childs, that pruning the negative just doesn't cut out
enough work. It needs to do something to count groups of 1-childs positively.

It's easy to brute force the digits through 10^9. However, something happens
when the digits are >= 10. I already reported there are no 1-childs when
digits == 10. The problem changes for digits >= 11 since individual digits
can no longer be 1-childs (other than 0). Rather than trying them all, there's
a way to show what patterns result in 1-childs (and not 2-childs or 0-childs),
and then just counting those patterns. This is not obvious to me and would
require a great deal more study, since it seems to revolve around 19-digit
numbers and factors of 19 (and 18, etc.).

I don't see how to partition this problem easily. Take 18-digit numbers. You
can try all 9-digit numbers and calculate for all 10^9 combos whether that
sequence is a 0-child, 1-child, or 2+child. So, all 18-digit numbers of
0-child 9-digit numbers and then 1-child 9-digit numbs, or 1-child 9-digit
numbers then 0-child 9-digit numbers concatenated together would give you a
1-child. But that doesn't work: there are new patterns formed which need to
be accounted for which could generate another 1-child, making the 18-digit
number no longer a 1-child. I don't see how to detect that without forming
them.

I suspect there's a pattern, and that if you take a given divisor (say,
18), and form all strings of length 1 through 9, there's a pattern to the
number of 1-childs for a given length (and we don't see this solving the
problem directly since the divisor is changing as well as the length). And
that this pattern results in a formula for 1-childs of 18 digits, something
like: raw 1-childs for 10^18 - (raw 1-childs for 10^17) - (a few '18' cases
caused by the extra digit going from 17 to 18 digits).

Kent

Re: Losing my mind: results change with/without printf() statements

<bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17295&group=comp.lang.c#17295

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:8407:: with SMTP id g7mr22686374qkd.123.1625612565809;
Tue, 06 Jul 2021 16:02:45 -0700 (PDT)
X-Received: by 2002:ae9:e60c:: with SMTP id z12mr22309638qkf.287.1625612565649;
Tue, 06 Jul 2021 16:02:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 6 Jul 2021 16:02:45 -0700 (PDT)
In-Reply-To: <a_CdnUJgh4wOD3n9nZ2dnUU7-XvNnZ2d@giganews.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.182.191; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.182.191
References: <vW0DI.53$h45.18@fx16.iad> <87a6n0c1ux.fsf@bsb.me.uk>
<2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com> <c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com>
<a_CdnUJgh4wOD3n9nZ2dnUU7-XvNnZ2d@giganews.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Tue, 06 Jul 2021 23:02:45 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Tue, 6 Jul 2021 23:02 UTC

On Tuesday, July 6, 2021 at 8:28:02 PM UTC+3, Kent Dickey wrote:
> In article <c7bfb14a-2084-41c3...@googlegroups.com>,
> Michael S <already...@yahoo.com> wrote:
> >
> >Those are still variations of the theme that I outlined in the post from
> >Jul 4, 2021, 1:21:16 PM
> >As proven in the post from Jul 5, 2021, 12:44:48 PM, as far as original
> >1=19 digits challenge is concerned, it's a dead end.
> >In order to tackle the original challenge, the positive (one-child)
> >results should somehow be discovered and counted in bunches of of at
> >least thousands (preferably 100s of thousands) rather than one-by-one.
> >Just rejecting negatives in bunches is not sufficient.
> I was just posting code I wrote before your posts.
>
> I did not see any "proofs", there was a post with some numbers, with no
> explanation of where they came from or why we should believe it.

There was an explanation: the numbers are estimates found by Monte Carlo method.
For each number of digits I tested 1E7 randomly distributed points and extrapolated.
Later on I repeated the tests with 1E8 point per range and got approximately the same
result. That is, estimates could be off by few per cents, but it wouldn't change the conclusion:
the total number of one-child numbers in range 1:1e19 is too huge for any methods that reject
candidates in bunches but confirm individually.
Why should you believe it? Because I said so and I tend to be reliable in that sort of things.
I didn't post the Monte Carlo code here because
(a) it is trivial, every decent pro has to be able to code something like that in less than 2 hours
(b) it is coded in C++ and the group is about C.
I can save it at my github account if wish to see it.

BTW, here are full results:
1: 10 / 10 * 10 = 1.000000000000000e+01
2: 20 / 90 * 90 = 2.000000000000000e+01
3: 360 / 900 * 900 = 3.600000000000000e+02
4: 2701 / 9000 * 9000 = 2.701000000000000e+03
5: 4096 / 90000 * 90000 = 4.096000000000000e+03
6: 109466 / 900000 * 900000 = 1.094660000000000e+05
7: 161022 / 9000000 * 9000000 = 1.610220000000000e+05
8: 13068583 / 90000000 * 90000000 = 1.306858300000000e+07
9: 237707 / 100000000 * 900000000 = 2.139363000000000e+06
10: 0 / 100000000 * 9000000000 = 0.000000000000000e+00
11: 78609 / 100000000 * 90000000000 = 7.074810000000000e+07
12: 6126028 / 100000000 * 900000000000 = 5.513425200000000e+10
13: 11791 / 100000000 * 9000000000000 = 1.061190000000000e+09
14: 1137562 / 100000000 * 90000000000000 = 1.023805800000000e+12
15: 3414651 / 100000000 * 900000000000000 = 3.073185900000000e+13
16: 7992302 / 100000000 * 9000000000000000 = 7.193071800000000e+14
17: 198 / 100000000 * 90000000000000000 = 1.782000000000000e+11
18: 258937 / 100000000 * 900000000000000000 = 2.330433000000000e+15
19: 30 / 100000000 * 9000000000000000000 = 2.700000000000000e+12
Total 3.084430326475721e+15

> I wrote
> some code to get some idea if pruning would work--and for some ranges, it's
> very effective, for other ranges, it's not effective at all. Basically,
> to see the timing differences for different ranges. My pruning code showed:
>
> size runtime factor number of 1-childs
> 10^6: 0.046 secs = = 116652
> 10^7: 0.231 secs = 5.02x = 277674
> 10^8: 5.374 secs = 23.2x = 13346257
> 10^9: 11.463 secs =2.13x = 15483217
>

I have exact results for up to 13 digits.
Ndigits N-one-childs
1 - 10
2 - 20
3 - 360
4 - 2701
5 - 4096
6 - 109466
7 - 161022
8 - 13068583
9 - 2136960
10 - 0
11 - 71101800
12 - 55121700430
13 - 1057516028
Pay attention, format is slightly different from yours, yours is accumulated, mine is per specific number of digits.
12 and 13 digits took relatively long compute time to find - 38min and 57min respectively. i.e. much more than the time allowed by informal rules of the challenge.

> This shows pruning working very effectively for 10^9. But 8-digit numbers
> have so many 1-childs, that pruning the negative just doesn't cut out
> enough work. It needs to do something to count groups of 1-childs positively.
>
> It's easy to brute force the digits through 10^9. However, something happens
> when the digits are >= 10. I already reported there are no 1-childs when
> digits == 10.

Yes, when the fact is know that's relatively easy to understand.

> The problem changes for digits >= 11 since individual digits
> can no longer be 1-childs (other than 0). Rather than trying them all, there's
> a way to show what patterns result in 1-childs (and not 2-childs or 0-childs),
> and then just counting those patterns. This is not obvious to me and would
> require a great deal more study, since it seems to revolve around 19-digit
> numbers and factors of 19 (and 18, etc.).
>
> I don't see how to partition this problem easily. Take 18-digit numbers. You
> can try all 9-digit numbers and calculate for all 10^9 combos whether that
> sequence is a 0-child, 1-child, or 2+child. So, all 18-digit numbers of
> 0-child 9-digit numbers and then 1-child 9-digit numbs, or 1-child 9-digit
> numbers then 0-child 9-digit numbers concatenated together would give you a
> 1-child. But that doesn't work: there are new patterns formed which need to
> be accounted for which could generate another 1-child, making the 18-digit
> number no longer a 1-child. I don't see how to detect that without forming
> them.
>

Me too.
And yes, 18 digits are the most problematic by far, but 16 digits would also
took months of single-core compute time with this sort of algorithm.

> I suspect there's a pattern, and that if you take a given divisor (say,
> 18), and form all strings of length 1 through 9, there's a pattern to the
> number of 1-childs for a given length (and we don't see this solving the
> problem directly since the divisor is changing as well as the length). And
> that this pattern results in a formula for 1-childs of 18 digits, something
> like: raw 1-childs for 10^18 - (raw 1-childs for 10^17) - (a few '18' cases
> caused by the extra digit going from 17 to 18 digits).
>
> Kent

Re: Losing my mind: results change with/without printf() statements

<KA6FI.173$Yv3.34@fx41.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17296&group=comp.lang.c#17296

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx41.iad.POSTED!not-for-mail
Subject: Re: Losing my mind: results change with/without printf() statements
Newsgroups: comp.lang.c
References: <vW0DI.53$h45.18@fx16.iad> <87a6n0c1ux.fsf@bsb.me.uk>
<2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com>
<c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com>
<a_CdnUJgh4wOD3n9nZ2dnUU7-XvNnZ2d@giganews.com>
<bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com>
From: nos...@dfs.com (DFS)
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
MIME-Version: 1.0
In-Reply-To: <bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 189
Message-ID: <KA6FI.173$Yv3.34@fx41.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Wed, 07 Jul 2021 00:30:34 UTC
Organization: blocknews - www.blocknews.net
Date: Tue, 6 Jul 2021 20:30:32 -0400
X-Received-Bytes: 6274
 by: DFS - Wed, 7 Jul 2021 00:30 UTC

On 7/6/2021 7:02 PM, Michael S wrote:

> I have exact results for up to 13 digits.

> Ndigits N-one-childs
> 1 - 10
> 2 - 20
> 3 - 360
> 4 - 2701
> 5 - 4096
> 6 - 109466
> 7 - 161022
> 8 - 13068583
> 9 - 2136960
> 10 - 0
> 11 - 71101800
> 12 - 55121700430
> 13 - 1057516028

> Pay attention, format is slightly different from yours, yours is accumulated, mine is per specific number of digits.

Per the problem description F(10^1) = 9, which means 0 isn't included.

https://projecteuler.net/problem=413

You may have some insights if you look at the numbers like this:

N Substrings * = one-child
--- ----------------------- ---------------
81. [8, 81, 1] *
82. [8, 82, 2]
83. [8, 83, 3] *
84. [8, 84, 4]
85. [8, 85, 5] *
86. [8, 86, 6]
87. [8, 87, 7] *
88. [8, 88, 8]
89. [8, 89, 9] *
90. [9, 90, 0]
91. [9, 91, 1]
92. [9, 92, 2]
93. [9, 93, 3]
94. [9, 94, 4]
95. [9, 95, 5]
96. [9, 96, 6]
97. [9, 97, 7]
98. [9, 98, 8]
99. [9, 99, 9]
100. [1, 10, 100, 0, 0, 0]
101. [1, 10, 101, 0, 1, 1] *
102. [1, 10, 102, 0, 2, 2]
103. [1, 10, 103, 0, 3, 3]
104. [1, 10, 104, 0, 4, 4] *
105. [1, 10, 105, 0, 5, 5]
106. [1, 10, 106, 0, 6, 6]
107. [1, 10, 107, 0, 7, 7] *
108. [1, 10, 108, 0, 8, 8]
109. [1, 10, 109, 0, 9, 9]
110. [1, 11, 110, 1, 10, 0] *
111. [1, 11, 111, 1, 11, 1] *
112. [1, 11, 112, 1, 12, 2] *
113. [1, 11, 113, 1, 13, 3] *
114. [1, 11, 114, 1, 14, 4] *
115. [1, 11, 115, 1, 15, 5] *
116. [1, 11, 116, 1, 16, 6] *
117. [1, 11, 117, 1, 17, 7] *
118. [1, 11, 118, 1, 18, 8] *
119. [1, 11, 119, 1, 19, 9] *
120. [1, 12, 120, 2, 20, 0]
121. [1, 12, 121, 2, 21, 1]
122. [1, 12, 122, 2, 22, 2] *
123. [1, 12, 123, 2, 23, 3]
124. [1, 12, 124, 2, 24, 4]
125. [1, 12, 125, 2, 25, 5] *
126. [1, 12, 126, 2, 26, 6]
127. [1, 12, 127, 2, 27, 7]
128. [1, 12, 128, 2, 28, 8] *
129. [1, 12, 129, 2, 29, 9]
130. [1, 13, 130, 3, 30, 0]
131. [1, 13, 131, 3, 31, 1] *
132. [1, 13, 132, 3, 32, 2]
133. [1, 13, 133, 3, 33, 3]
134. [1, 13, 134, 3, 34, 4] *
135. [1, 13, 135, 3, 35, 5]
136. [1, 13, 136, 3, 36, 6]
137. [1, 13, 137, 3, 37, 7] *
138. [1, 13, 138, 3, 38, 8]
139. [1, 13, 139, 3, 39, 9]
140. [1, 14, 140, 4, 40, 0] *
141. [1, 14, 141, 4, 41, 1] *
142. [1, 14, 142, 4, 42, 2] *
143. [1, 14, 143, 4, 43, 3] *
144. [1, 14, 144, 4, 44, 4] *
145. [1, 14, 145, 4, 45, 5] *
146. [1, 14, 146, 4, 46, 6] *
147. [1, 14, 147, 4, 47, 7] *
148. [1, 14, 148, 4, 48, 8] *
149. [1, 14, 149, 4, 49, 9] *

They definitely follow patterns.

* All 2-digit numbers of even-odd are one-child.

* 3-digit numbers beginning with the same 2 numbers are one-child,
unless those 2 starting numbers are factors of 3

110. [1, 11, 110, 1, 10, 0] *
111. [1, 11, 111, 1, 11, 1] *
112. [1, 11, 112, 1, 12, 2] *
113. [1, 11, 113, 1, 13, 3] *
114. [1, 11, 114, 1, 14, 4] *
115. [1, 11, 115, 1, 15, 5] *
116. [1, 11, 116, 1, 16, 6] *
117. [1, 11, 117, 1, 17, 7] *
118. [1, 11, 118, 1, 18, 8] *
119. [1, 11, 119, 1, 19, 9] *

220. [2, 22, 220, 2, 20, 0] *
221. [2, 22, 221, 2, 21, 1] *
222. [2, 22, 222, 2, 22, 2] *
223. [2, 22, 223, 2, 23, 3] *
224. [2, 22, 224, 2, 24, 4] *
225. [2, 22, 225, 2, 25, 5] *
226. [2, 22, 226, 2, 26, 6] *
227. [2, 22, 227, 2, 27, 7] *
228. [2, 22, 228, 2, 28, 8] *
229. [2, 22, 229, 2, 29, 9] *

330. [3, 33, 330, 3, 30, 0]
331. [3, 33, 331, 3, 31, 1]
332. [3, 33, 332, 3, 32, 2]
333. [3, 33, 333, 3, 33, 3]
334. [3, 33, 334, 3, 34, 4]
335. [3, 33, 335, 3, 35, 5]
336. [3, 33, 336, 3, 36, 6]
337. [3, 33, 337, 3, 37, 7]
338. [3, 33, 338, 3, 38, 8]
339. [3, 33, 339, 3, 39, 9]

440. [4, 44, 440, 4, 40, 0] *
441. [4, 44, 441, 4, 41, 1] *
442. [4, 44, 442, 4, 42, 2] *
443. [4, 44, 443, 4, 43, 3] *
444. [4, 44, 444, 4, 44, 4] *
445. [4, 44, 445, 4, 45, 5] *
446. [4, 44, 446, 4, 46, 6] *
447. [4, 44, 447, 4, 47, 7] *
448. [4, 44, 448, 4, 48, 8] *
449. [4, 44, 449, 4, 49, 9] *

550. [5, 55, 550, 5, 50, 0] *
551. [5, 55, 551, 5, 51, 1] *
552. [5, 55, 552, 5, 52, 2] *
553. [5, 55, 553, 5, 53, 3] *
554. [5, 55, 554, 5, 54, 4] *
555. [5, 55, 555, 5, 55, 5] *
556. [5, 55, 556, 5, 56, 6] *
557. [5, 55, 557, 5, 57, 7] *
558. [5, 55, 558, 5, 58, 8] *
559. [5, 55, 559, 5, 59, 9] *

660. [6, 66, 660, 6, 60, 0]
661. [6, 66, 661, 6, 61, 1]
662. [6, 66, 662, 6, 62, 2]
663. [6, 66, 663, 6, 63, 3]
664. [6, 66, 664, 6, 64, 4]
665. [6, 66, 665, 6, 65, 5]
666. [6, 66, 666, 6, 66, 6]
667. [6, 66, 667, 6, 67, 7]
668. [6, 66, 668, 6, 68, 8]
669. [6, 66, 669, 6, 69, 9]

770. [7, 77, 770, 7, 70, 0] *
771. [7, 77, 771, 7, 71, 1] *
772. [7, 77, 772, 7, 72, 2] *
773. [7, 77, 773, 7, 73, 3] *
774. [7, 77, 774, 7, 74, 4] *
775. [7, 77, 775, 7, 75, 5] *
776. [7, 77, 776, 7, 76, 6] *
777. [7, 77, 777, 7, 77, 7] *
778. [7, 77, 778, 7, 78, 8] *
779. [7, 77, 779, 7, 79, 9] *

etc

Re: Losing my mind: results change with/without printf() statements

<ad435f65-f4c1-4db7-a565-5404767814ebn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17329&group=comp.lang.c#17329

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:9244:: with SMTP id u65mr30409309qkd.46.1625731379699; Thu, 08 Jul 2021 01:02:59 -0700 (PDT)
X-Received: by 2002:a05:6214:4e2:: with SMTP id cl2mr6647279qvb.55.1625731379569; Thu, 08 Jul 2021 01:02:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 8 Jul 2021 01:02:59 -0700 (PDT)
In-Reply-To: <bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <vW0DI.53$h45.18@fx16.iad> <87a6n0c1ux.fsf@bsb.me.uk> <2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com> <c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com> <a_CdnUJgh4wOD3n9nZ2dnUU7-XvNnZ2d@giganews.com> <bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ad435f65-f4c1-4db7-a565-5404767814ebn@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Thu, 08 Jul 2021 08:02:59 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 147
 by: Michael S - Thu, 8 Jul 2021 08:02 UTC

On Wednesday, July 7, 2021 at 2:02:53 AM UTC+3, Michael S wrote:
> On Tuesday, July 6, 2021 at 8:28:02 PM UTC+3, Kent Dickey wrote:
> > In article <c7bfb14a-2084-41c3...@googlegroups.com>,
> > Michael S <already...@yahoo.com> wrote:
> > >
> > >Those are still variations of the theme that I outlined in the post from
> > >Jul 4, 2021, 1:21:16 PM
> > >As proven in the post from Jul 5, 2021, 12:44:48 PM, as far as original
> > >1=19 digits challenge is concerned, it's a dead end.
> > >In order to tackle the original challenge, the positive (one-child)
> > >results should somehow be discovered and counted in bunches of of at
> > >least thousands (preferably 100s of thousands) rather than one-by-one.
> > >Just rejecting negatives in bunches is not sufficient.
> > I was just posting code I wrote before your posts.
> >
> > I did not see any "proofs", there was a post with some numbers, with no
> > explanation of where they came from or why we should believe it.
> There was an explanation: the numbers are estimates found by Monte Carlo method.
> For each number of digits I tested 1E7 randomly distributed points and extrapolated.
> Later on I repeated the tests with 1E8 point per range and got approximately the same
> result. That is, estimates could be off by few per cents, but it wouldn't change the conclusion:
> the total number of one-child numbers in range 1:1e19 is too huge for any methods that reject
> candidates in bunches but confirm individually.
> Why should you believe it? Because I said so and I tend to be reliable in that sort of things.
> I didn't post the Monte Carlo code here because
> (a) it is trivial, every decent pro has to be able to code something like that in less than 2 hours
> (b) it is coded in C++ and the group is about C.
> I can save it at my github account if wish to see it.
>
> BTW, here are full results:
> 1: 10 / 10 * 10 = 1.000000000000000e+01
> 2: 20 / 90 * 90 = 2.000000000000000e+01
> 3: 360 / 900 * 900 = 3.600000000000000e+02
> 4: 2701 / 9000 * 9000 = 2.701000000000000e+03
> 5: 4096 / 90000 * 90000 = 4.096000000000000e+03
> 6: 109466 / 900000 * 900000 = 1.094660000000000e+05
> 7: 161022 / 9000000 * 9000000 = 1.610220000000000e+05
> 8: 13068583 / 90000000 * 90000000 = 1.306858300000000e+07
> 9: 237707 / 100000000 * 900000000 = 2.139363000000000e+06
> 10: 0 / 100000000 * 9000000000 = 0.000000000000000e+00
> 11: 78609 / 100000000 * 90000000000 = 7.074810000000000e+07
> 12: 6126028 / 100000000 * 900000000000 = 5.513425200000000e+10
> 13: 11791 / 100000000 * 9000000000000 = 1.061190000000000e+09
> 14: 1137562 / 100000000 * 90000000000000 = 1.023805800000000e+12
> 15: 3414651 / 100000000 * 900000000000000 = 3.073185900000000e+13
> 16: 7992302 / 100000000 * 9000000000000000 = 7.193071800000000e+14
> 17: 198 / 100000000 * 90000000000000000 = 1.782000000000000e+11
> 18: 258937 / 100000000 * 900000000000000000 = 2.330433000000000e+15
> 19: 30 / 100000000 * 9000000000000000000 = 2.700000000000000e+12
> Total 3.084430326475721e+15
> > I wrote
> > some code to get some idea if pruning would work--and for some ranges, it's
> > very effective, for other ranges, it's not effective at all. Basically,
> > to see the timing differences for different ranges. My pruning code showed:
> >
> > size runtime factor number of 1-childs
> > 10^6: 0.046 secs = = 116652
> > 10^7: 0.231 secs = 5.02x = 277674
> > 10^8: 5.374 secs = 23.2x = 13346257
> > 10^9: 11.463 secs =2.13x = 15483217
> >
> I have exact results for up to 13 digits.
> Ndigits N-one-childs
> 1 - 10
> 2 - 20
> 3 - 360
> 4 - 2701
> 5 - 4096
> 6 - 109466
> 7 - 161022
> 8 - 13068583
> 9 - 2136960
> 10 - 0
> 11 - 71101800
> 12 - 55121700430
> 13 - 1057516028
> Pay attention, format is slightly different from yours, yours is accumulated, mine is per specific number of digits.
> 12 and 13 digits took relatively long compute time to find - 38min and 57min respectively. i.e. much more than the time allowed by informal rules of the challenge.

Update:
With better code (posted on comp.arch) I managed to brute-force 14 digits.
It took almost 4 hours on a single core, far away from timing requirements of the challenge.
I expect that 17 digits can be ripped in similar time. May be, 19 digits too, not sure about it.
For 15 digits I expect results in 4-5 days.
But ripping 16 or 18 digits with this code will take many months of single-core compute time.
Current results:
1 - 9
2 - 20
3 - 360
4 - 2701
5 - 4096
6 - 109466
7 - 161022
8 - 13068583
9 - 2136960
10 - 0
11 - 71101800
12 - 55121700430
13 - 1057516028
14 - 1023436651875
15 - ???
16 - ???
17 - ???
18 - ???
19 - ???

> > This shows pruning working very effectively for 10^9. But 8-digit numbers
> > have so many 1-childs, that pruning the negative just doesn't cut out
> > enough work. It needs to do something to count groups of 1-childs positively.
> >

I am starting to get an idea of how to count in bunches.
Still have one algorithmic difficulty to figure out before I start coding.

> > It's easy to brute force the digits through 10^9. However, something happens
> > when the digits are >= 10. I already reported there are no 1-childs when
> > digits == 10.
> Yes, when the fact is know that's relatively easy to understand.
> > The problem changes for digits >= 11 since individual digits
> > can no longer be 1-childs (other than 0). Rather than trying them all, there's
> > a way to show what patterns result in 1-childs (and not 2-childs or 0-childs),
> > and then just counting those patterns. This is not obvious to me and would
> > require a great deal more study, since it seems to revolve around 19-digit
> > numbers and factors of 19 (and 18, etc.).
> >
> > I don't see how to partition this problem easily. Take 18-digit numbers. You
> > can try all 9-digit numbers and calculate for all 10^9 combos whether that
> > sequence is a 0-child, 1-child, or 2+child. So, all 18-digit numbers of
> > 0-child 9-digit numbers and then 1-child 9-digit numbs, or 1-child 9-digit
> > numbers then 0-child 9-digit numbers concatenated together would give you a
> > 1-child. But that doesn't work: there are new patterns formed which need to
> > be accounted for which could generate another 1-child, making the 18-digit
> > number no longer a 1-child. I don't see how to detect that without forming
> > them.
> >
> Me too.
> And yes, 18 digits are the most problematic by far, but 16 digits would also
> took months of single-core compute time with this sort of algorithm.
> > I suspect there's a pattern, and that if you take a given divisor (say,
> > 18), and form all strings of length 1 through 9, there's a pattern to the
> > number of 1-childs for a given length (and we don't see this solving the
> > problem directly since the divisor is changing as well as the length). And
> > that this pattern results in a formula for 1-childs of 18 digits, something
> > like: raw 1-childs for 10^18 - (raw 1-childs for 10^17) - (a few '18' cases
> > caused by the extra digit going from 17 to 18 digits).
> >
> > Kent

Re: Losing my mind: results change with/without printf() statements

<06a1aff4-365a-4f91-91d1-56dead415871n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17369&group=comp.lang.c#17369

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:46d0:: with SMTP id h16mr6229169qto.362.1625835129092; Fri, 09 Jul 2021 05:52:09 -0700 (PDT)
X-Received: by 2002:a05:620a:16da:: with SMTP id a26mr16643276qkn.7.1625835128928; Fri, 09 Jul 2021 05:52:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 9 Jul 2021 05:52:08 -0700 (PDT)
In-Reply-To: <ad435f65-f4c1-4db7-a565-5404767814ebn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.182.191; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.182.191
References: <vW0DI.53$h45.18@fx16.iad> <87a6n0c1ux.fsf@bsb.me.uk> <2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com> <c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com> <a_CdnUJgh4wOD3n9nZ2dnUU7-XvNnZ2d@giganews.com> <bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com> <ad435f65-f4c1-4db7-a565-5404767814ebn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <06a1aff4-365a-4f91-91d1-56dead415871n@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 09 Jul 2021 12:52:09 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 172
 by: Michael S - Fri, 9 Jul 2021 12:52 UTC

On Thursday, July 8, 2021 at 11:03:08 AM UTC+3, Michael S wrote:
> On Wednesday, July 7, 2021 at 2:02:53 AM UTC+3, Michael S wrote:
> > On Tuesday, July 6, 2021 at 8:28:02 PM UTC+3, Kent Dickey wrote:
> > > In article <c7bfb14a-2084-41c3...@googlegroups.com>,
> > > Michael S <already...@yahoo.com> wrote:
> > > >
> > > >Those are still variations of the theme that I outlined in the post from
> > > >Jul 4, 2021, 1:21:16 PM
> > > >As proven in the post from Jul 5, 2021, 12:44:48 PM, as far as original
> > > >1=19 digits challenge is concerned, it's a dead end.
> > > >In order to tackle the original challenge, the positive (one-child)
> > > >results should somehow be discovered and counted in bunches of of at
> > > >least thousands (preferably 100s of thousands) rather than one-by-one.
> > > >Just rejecting negatives in bunches is not sufficient.
> > > I was just posting code I wrote before your posts.
> > >
> > > I did not see any "proofs", there was a post with some numbers, with no
> > > explanation of where they came from or why we should believe it.
> > There was an explanation: the numbers are estimates found by Monte Carlo method.
> > For each number of digits I tested 1E7 randomly distributed points and extrapolated.
> > Later on I repeated the tests with 1E8 point per range and got approximately the same
> > result. That is, estimates could be off by few per cents, but it wouldn't change the conclusion:
> > the total number of one-child numbers in range 1:1e19 is too huge for any methods that reject
> > candidates in bunches but confirm individually.
> > Why should you believe it? Because I said so and I tend to be reliable in that sort of things.
> > I didn't post the Monte Carlo code here because
> > (a) it is trivial, every decent pro has to be able to code something like that in less than 2 hours
> > (b) it is coded in C++ and the group is about C.
> > I can save it at my github account if wish to see it.
> >
> > BTW, here are full results:
> > 1: 10 / 10 * 10 = 1.000000000000000e+01
> > 2: 20 / 90 * 90 = 2.000000000000000e+01
> > 3: 360 / 900 * 900 = 3.600000000000000e+02
> > 4: 2701 / 9000 * 9000 = 2.701000000000000e+03
> > 5: 4096 / 90000 * 90000 = 4.096000000000000e+03
> > 6: 109466 / 900000 * 900000 = 1.094660000000000e+05
> > 7: 161022 / 9000000 * 9000000 = 1.610220000000000e+05
> > 8: 13068583 / 90000000 * 90000000 = 1.306858300000000e+07
> > 9: 237707 / 100000000 * 900000000 = 2.139363000000000e+06
> > 10: 0 / 100000000 * 9000000000 = 0.000000000000000e+00
> > 11: 78609 / 100000000 * 90000000000 = 7.074810000000000e+07
> > 12: 6126028 / 100000000 * 900000000000 = 5.513425200000000e+10
> > 13: 11791 / 100000000 * 9000000000000 = 1.061190000000000e+09
> > 14: 1137562 / 100000000 * 90000000000000 = 1.023805800000000e+12
> > 15: 3414651 / 100000000 * 900000000000000 = 3.073185900000000e+13
> > 16: 7992302 / 100000000 * 9000000000000000 = 7.193071800000000e+14
> > 17: 198 / 100000000 * 90000000000000000 = 1.782000000000000e+11
> > 18: 258937 / 100000000 * 900000000000000000 = 2.330433000000000e+15
> > 19: 30 / 100000000 * 9000000000000000000 = 2.700000000000000e+12
> > Total 3.084430326475721e+15
> > > I wrote
> > > some code to get some idea if pruning would work--and for some ranges, it's
> > > very effective, for other ranges, it's not effective at all. Basically,
> > > to see the timing differences for different ranges. My pruning code showed:
> > >
> > > size runtime factor number of 1-childs
> > > 10^6: 0.046 secs = = 116652
> > > 10^7: 0.231 secs = 5.02x = 277674
> > > 10^8: 5.374 secs = 23.2x = 13346257
> > > 10^9: 11.463 secs =2.13x = 15483217
> > >
> > I have exact results for up to 13 digits.
> > Ndigits N-one-childs
> > 1 - 10
> > 2 - 20
> > 3 - 360
> > 4 - 2701
> > 5 - 4096
> > 6 - 109466
> > 7 - 161022
> > 8 - 13068583
> > 9 - 2136960
> > 10 - 0
> > 11 - 71101800
> > 12 - 55121700430
> > 13 - 1057516028
> > Pay attention, format is slightly different from yours, yours is accumulated, mine is per specific number of digits.
> > 12 and 13 digits took relatively long compute time to find - 38min and 57min respectively. i.e. much more than the time allowed by informal rules of the challenge.
> Update:
> With better code (posted on comp.arch) I managed to brute-force 14 digits.
> It took almost 4 hours on a single core, far away from timing requirements of the challenge.
> I expect that 17 digits can be ripped in similar time. May be, 19 digits too, not sure about it.
> For 15 digits I expect results in 4-5 days.
> But ripping 16 or 18 digits with this code will take many months of single-core compute time.
> Current results:
> 1 - 9
> 2 - 20
> 3 - 360
> 4 - 2701
> 5 - 4096
> 6 - 109466
> 7 - 161022
> 8 - 13068583
> 9 - 2136960
> 10 - 0
> 11 - 71101800
> 12 - 55121700430
> 13 - 1057516028
> 14 - 1023436651875
> 15 - ???
> 16 - ???
> 17 - ???
> 18 - ???
> 19 - ???
> > > This shows pruning working very effectively for 10^9. But 8-digit numbers
> > > have so many 1-childs, that pruning the negative just doesn't cut out
> > > enough work. It needs to do something to count groups of 1-childs positively.
> > >
> I am starting to get an idea of how to count in bunches.
> Still have one algorithmic difficulty to figure out before I start coding.
> > > It's easy to brute force the digits through 10^9. However, something happens
> > > when the digits are >= 10. I already reported there are no 1-childs when
> > > digits == 10.
> > Yes, when the fact is know that's relatively easy to understand.
> > > The problem changes for digits >= 11 since individual digits
> > > can no longer be 1-childs (other than 0). Rather than trying them all, there's
> > > a way to show what patterns result in 1-childs (and not 2-childs or 0-childs),
> > > and then just counting those patterns. This is not obvious to me and would
> > > require a great deal more study, since it seems to revolve around 19-digit
> > > numbers and factors of 19 (and 18, etc.).
> > >
> > > I don't see how to partition this problem easily. Take 18-digit numbers. You
> > > can try all 9-digit numbers and calculate for all 10^9 combos whether that
> > > sequence is a 0-child, 1-child, or 2+child. So, all 18-digit numbers of
> > > 0-child 9-digit numbers and then 1-child 9-digit numbs, or 1-child 9-digit
> > > numbers then 0-child 9-digit numbers concatenated together would give you a
> > > 1-child. But that doesn't work: there are new patterns formed which need to
> > > be accounted for which could generate another 1-child, making the 18-digit
> > > number no longer a 1-child. I don't see how to detect that without forming
> > > them.
> > >
> > Me too.
> > And yes, 18 digits are the most problematic by far, but 16 digits would also
> > took months of single-core compute time with this sort of algorithm.
> > > I suspect there's a pattern, and that if you take a given divisor (say,
> > > 18), and form all strings of length 1 through 9, there's a pattern to the
> > > number of 1-childs for a given length (and we don't see this solving the
> > > problem directly since the divisor is changing as well as the length). And
> > > that this pattern results in a formula for 1-childs of 18 digits, something
> > > like: raw 1-childs for 10^18 - (raw 1-childs for 10^17) - (a few '18' cases
> > > caused by the extra digit going from 17 to 18 digits).
> > >
> > > Kent

Solved it, finally.
6 seconds of intentionally non-optimized compute + ~30 hours of thinking and trying, 10 of each due to being stubborn.

1 9 9
2 20 29
3 360 389
4 2701 3090
5 4096 7186
6 109466 116652
7 161022 277674
8 13068583 13346257
9 2136960 15483217
10 0 15483217
11 71101800 86585017
12 55121700430 55208285447
13 1057516028 56265801475
14 1023436651875 1079702453350
15 30731637609504 31811340062854
16 719883432165805 751694772228659
17 195741994241 751890514222900
18 2325274798835849 3077165313058749
19 2253334981970 3079418648040719


Click here to read the complete article
Re: Losing my mind: results change with/without printf() statements

<GuWdnTUsM4OE03X9nZ2dnUU7-R-dnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17370&group=comp.lang.c#17370

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 09 Jul 2021 08:24:41 -0500
Newsgroups: comp.lang.c
Subject: Re: Losing my mind: results change with/without printf() statements
References: <vW0DI.53$h45.18@fx16.iad> <bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com> <ad435f65-f4c1-4db7-a565-5404767814ebn@googlegroups.com> <06a1aff4-365a-4f91-91d1-56dead415871n@googlegroups.com>
Organization: provalid.com
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
From: keg...@provalid.com (Kent Dickey)
Originator: kegs@provalid.com (Kent Dickey)
Message-ID: <GuWdnTUsM4OE03X9nZ2dnUU7-R-dnZ2d@giganews.com>
Date: Fri, 09 Jul 2021 08:24:41 -0500
Lines: 34
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-knsNt5GHAVF1t5I3pbNYYntG+ecxBVyLW48zGxl1iFwP/OkuMFe9c4ifnw5G5+6BtDfX+4aH1chonT4!CNvkTMUzBxnN/h3yy/uF3F9C+crFuAvaT6ZmQJReQm6KRI1zewlEyEhdDpZ/mQ1NxLY9ghvFnlM=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2654
 by: Kent Dickey - Fri, 9 Jul 2021 13:24 UTC

In article <06a1aff4-365a-4f91-91d1-56dead415871n@googlegroups.com>,
Michael S <already5chosen@yahoo.com> wrote:
>Solved it, finally.
>6 seconds of intentionally non-optimized compute + ~30 hours of thinking
>and trying, 10 of each due to being stubborn.
>
> 1 9 9
> 2 20 29
> 3 360 389
> 4 2701 3090
> 5 4096 7186
> 6 109466 116652
> 7 161022 277674
> 8 13068583 13346257
> 9 2136960 15483217
>10 0 15483217
>11 71101800 86585017
>12 55121700430 55208285447
>13 1057516028 56265801475
>14 1023436651875 1079702453350
>15 30731637609504 31811340062854
>16 719883432165805 751694772228659
>17 195741994241 751890514222900
>18 2325274798835849 3077165313058749
>19 2253334981970 3079418648040719
>
>But I cheated - did it in C++ with use of STL containers.
>Of course, I can do it in C, but then bulk of the code will be dealing
>with infrastructure instead of problem in hand.

So, what is the "trick"? Does it extend beyond 19 digits (which is what
fits in a long long)?

Kent

Re: Losing my mind: results change with/without printf() statements

<eb8e43ea-3529-47ab-97f8-c374c1fceec8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17374&group=comp.lang.c#17374

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:4a18:: with SMTP id x24mr33473223qtq.239.1625840403262;
Fri, 09 Jul 2021 07:20:03 -0700 (PDT)
X-Received: by 2002:a05:620a:16b7:: with SMTP id s23mr15589267qkj.495.1625840403132;
Fri, 09 Jul 2021 07:20:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 9 Jul 2021 07:20:02 -0700 (PDT)
In-Reply-To: <GuWdnTUsM4OE03X9nZ2dnUU7-R-dnZ2d@giganews.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.182.191; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.182.191
References: <vW0DI.53$h45.18@fx16.iad> <bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com>
<ad435f65-f4c1-4db7-a565-5404767814ebn@googlegroups.com> <06a1aff4-365a-4f91-91d1-56dead415871n@googlegroups.com>
<GuWdnTUsM4OE03X9nZ2dnUU7-R-dnZ2d@giganews.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <eb8e43ea-3529-47ab-97f8-c374c1fceec8n@googlegroups.com>
Subject: Re: Losing my mind: results change with/without printf() statements
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 09 Jul 2021 14:20:03 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Fri, 9 Jul 2021 14:20 UTC

On Friday, July 9, 2021 at 4:24:57 PM UTC+3, Kent Dickey wrote:
> In article <06a1aff4-365a-4f91...@googlegroups.com>,
> Michael S <already...@yahoo.com> wrote:
> >Solved it, finally.
> >6 seconds of intentionally non-optimized compute + ~30 hours of thinking
> >and trying, 10 of each due to being stubborn.
> >
> > 1 9 9
> > 2 20 29
> > 3 360 389
> > 4 2701 3090
> > 5 4096 7186
> > 6 109466 116652
> > 7 161022 277674
> > 8 13068583 13346257
> > 9 2136960 15483217
> >10 0 15483217
> >11 71101800 86585017
> >12 55121700430 55208285447
> >13 1057516028 56265801475
> >14 1023436651875 1079702453350
> >15 30731637609504 31811340062854
> >16 719883432165805 751694772228659
> >17 195741994241 751890514222900
> >18 2325274798835849 3077165313058749
> >19 2253334981970 3079418648040719
> >
> >But I cheated - did it in C++ with use of STL containers.
> >Of course, I can do it in C, but then bulk of the code will be dealing
> >with infrastructure instead of problem in hand.
> So, what is the "trick"?

Do you really want to know?
I think, it's more interesting to figure it out by yourself. You can see uncommented solution in my github repo.
https://github.com/already5chosen/others/commit/07075aba5bcc3ebbbc45891015f36ac8bd373c71
But I recommend to try to not look for another day or week.

> Does it extend beyond 19 digits (which is what
> fits in a long long)?
>

It would work, if somewhat slower, since all data elements are bigger.
33-34 digits are almost certainly doable on PC with 16GB of RAM, but not in 1 minute.
I don't know how much more is doable, estimation of the size of data structures could serve as a math challenge all by itself.

> Kent

Re: Losing my mind: results change with/without printf() statements

<SRZFI.255$xn6.109@fx23.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17377&group=comp.lang.c#17377

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx23.iad.POSTED!not-for-mail
Subject: Re: Losing my mind: results change with/without printf() statements
Newsgroups: comp.lang.c
References: <vW0DI.53$h45.18@fx16.iad> <87a6n0c1ux.fsf@bsb.me.uk>
<2pmdnZmxQ42VOn79nZ2dnUU7-S_NnZ2d@giganews.com>
<c7bfb14a-2084-41c3-beea-438139f73393n@googlegroups.com>
<a_CdnUJgh4wOD3n9nZ2dnUU7-XvNnZ2d@giganews.com>
<bdc09058-f92c-4084-92c2-5186bfea63bcn@googlegroups.com>
<ad435f65-f4c1-4db7-a565-5404767814ebn@googlegroups.com>
<06a1aff4-365a-4f91-91d1-56dead415871n@googlegroups.com>
From: nos...@dfs.com (DFS)
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
MIME-Version: 1.0
In-Reply-To: <06a1aff4-365a-4f91-91d1-56dead415871n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 11
Message-ID: <SRZFI.255$xn6.109@fx23.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Fri, 09 Jul 2021 15:23:30 UTC
Organization: blocknews - www.blocknews.net
Date: Fri, 9 Jul 2021 11:23:28 -0400
X-Received-Bytes: 1395
 by: DFS - Fri, 9 Jul 2021 15:23 UTC

On 7/9/2021 8:52 AM, Michael S wrote:

> Solved it, finally.

Good job.

FYI: 'triceps' from Japan solved it 00:40:17 after it was posted.

https://projecteuler.net/fastest=413

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor