Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

For every complex problem, there is a solution that is simple, neat, and wrong. -- H. L. Mencken


devel / comp.lang.ada / Re: project euler 29

SubjectAuthor
* project euler 29CSYH (QAQ)
+* Re: project euler 29Jeffrey R.Carter
|`- Re: project euler 29Keith Thompson
+* Re: project euler 29Ben Bacarisse
|`* Re: project euler 29Francesc Rocher
| `* Re: project euler 29Ben Bacarisse
|  `* Re: project euler 29Ben Bacarisse
|   `* Re: project euler 29Francesc Rocher
|    +- Re: project euler 29Paul Rubin
|    `* Re: project euler 29Ben Bacarisse
|     `* Re: project euler 29Paul Rubin
|      `* Re: project euler 29Ben Bacarisse
|       `* Re: project euler 29Paul Rubin
|        `* Re: project euler 29Ben Bacarisse
|         `* Re: project euler 29Francesc Rocher
|          `* Re: project euler 29Ben Bacarisse
|           `* Re: project euler 29Francesc Rocher
|            `* Re: project euler 29Ben Bacarisse
|             `* Re: project euler 29Paul Rubin
|              +* Re: project euler 29comp.lang.ada
|              |`- Re: project euler 29comp.lang.ada
|              `- Re: project euler 29Ben Bacarisse
`- Re: project euler 29Jeffrey R.Carter

1
project euler 29

<beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10057&group=comp.lang.ada#10057

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5991:0:b0:415:2360:d099 with SMTP id e17-20020ac85991000000b004152360d099mr20108qte.12.1694768597207;
Fri, 15 Sep 2023 02:03:17 -0700 (PDT)
X-Received: by 2002:a9d:7a92:0:b0:6b7:4ec4:cbb1 with SMTP id
l18-20020a9d7a92000000b006b74ec4cbb1mr244990otn.7.1694768596969; Fri, 15 Sep
2023 02:03:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.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.ada
Date: Fri, 15 Sep 2023 02:03:16 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=54.199.214.131; posting-account=fZvo4QoAAABi0pYBrtK7uR0nkDKUP_JT
NNTP-Posting-Host: 54.199.214.131
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
Subject: project euler 29
From: schen309@asu.edu (CSYH (QAQ))
Injection-Date: Fri, 15 Sep 2023 09:03:17 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1736
 by: CSYH (QAQ) - Fri, 15 Sep 2023 09:03 UTC

Hello, everyone.
Now this time, I am facing trouble for problem #29.
As I know integer type is for 32 bits. but for this problem as me to find out the 2 ** 100 and even 100 ** 100.
I used python to get the answer correctly in 5 minutes.

context = []
for a in range(2,101):
for b in range(2,101):
context.append(a**b)
len(list(set(context)))

I know the algorithm is easy, but I am pretty interesting how to calculate a large like it. And thanks for the help from problem 26, your discussions come my every working hour.

for this problem I want to know how to know is there an easy way to store a large number like 100 ** 100, and how do U make a similar function like "set(context)" to delete the duplicated value in a vector.
Thanks
From CSYH(QAQ)

Re: project euler 29

<ue19di$35ura$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10059&group=comp.lang.ada#10059

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Fri, 15 Sep 2023 11:50:42 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <ue19di$35ura$1@dont-email.me>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 15 Sep 2023 09:50:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0e274621ec3606d81273a7f3bf7ecc67";
logging-data="3341162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IJT1A2pOLs0vyM0spXpuVi1E7o5ovgyU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:FJdnn0hpxHeLK4n0ME2a0imZxxU=
Content-Language: en-US
In-Reply-To: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
 by: Jeffrey R.Carter - Fri, 15 Sep 2023 09:50 UTC

On 2023-09-15 11:03, CSYH (QAQ) wrote:
>
> for this problem I want to know how to know is there an easy way to store a large number like 100 ** 100, and how do U make a similar function like "set(context)" to delete the duplicated value in a vector.

You will need an unbounded-integer pkg. If you want to write portable code in a
standard language, then you can write Ada 12 using a library such as
PragmARC.Unbounded_Numbers.Integers
(https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-unbounded_numbers-integers.ads).
This will compile with both GNAT and ObjectAda.

If you want to write non-portable code in a non-standard, Ada-like language,
then you can use the GNAT language, which is mostly Ada 12 with some Ada 23
features, one of which is the Ada-23 standard package
Ada.Numerics.Big_Numbers.Big_Integers
(http://www.ada-auth.org/standards/22aarm/html/AA-A-5-6.html). This can only be
compiled with GNAT. Note that, unlike PragmARC.Unbounded_Numbers.Integers,
GNAT's implementation of Ada.Numerics.Big_Numbers.Big_Integers is not truly
unbounded. I don't know if it will hold 101 ** 101 without modification.

You can store the results directly in a set from the standard library to avoid
duplicate values. If I understand your Python (probably not), you would want to
output the result of Length for the resulting set.

--
Jeff Carter
"I didn't squawk about the steak, dear. I
merely said I didn't see that old horse
that used to be tethered outside here."
Never Give a Sucker an Even Break
103

Re: project euler 29

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

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10060&group=comp.lang.ada#10060

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Fri, 15 Sep 2023 16:42:38 +0100
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <874jjvmoi9.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4742dca9d4b952760dd7dfa5b429dc5b";
logging-data="3484712"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zyvgoX0Im1uAbNMA3tVJaginR8z46xkQ="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:Tzj7LjVEQ+dJw6sL99xn04e69Ug=
sha1:X/G4lIaS037qjxndfNaejMtXqKY=
X-BSB-Auth: 1.d4ec49fadd4a48a6cc4c.20230915164238BST.874jjvmoi9.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 15 Sep 2023 15:42 UTC

"CSYH (QAQ)" <schen309@asu.edu> writes:

> Now this time, I am facing trouble for problem #29. As I know integer
> type is for 32 bits. but for this problem as me to find out the 2 **
> 100 and even 100 ** 100. I used python to get the answer correctly in
> 5 minutes.
>
> context = []
> for a in range(2,101):
> for b in range(2,101):
> context.append(a**b)
> len(list(set(context)))
>
> I know the algorithm is easy, but I am pretty interesting how to
> calculate a large like it.

Most of the Project Euler problems have solutions that are not always
the obvious one (though sometimes the obvious one is the best). You
can, of course, just use a big number type (or write your own!) but this
problem can be solved without having to use any large numbers at all.

--
Ben.

Re: project euler 29

<ue212d$38a2g$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10061&group=comp.lang.ada#10061

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Fri, 15 Sep 2023 18:34:21 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <ue212d$38a2g$1@dont-email.me>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 15 Sep 2023 16:34:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="062f53d45a4aaf358284ad27508dd214";
logging-data="3418192"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18F4oCllPEWOOrV3BVXcBTYBE+HNCu7c+A="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:HWhZGTwhcwnh+82bS0YVG7qot9g=
In-Reply-To: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
Content-Language: en-US
 by: Jeffrey R.Carter - Fri, 15 Sep 2023 16:34 UTC

On 2023-09-15 11:03, CSYH (QAQ) wrote:
> As I know integer type is for 32 bits. but for this problem as me to find out the 2 ** 100 and even 100 ** 100.

I missed this the first time.

No, you don't know that Integer is 32 bits. ARM 3.5.4 (21)
[http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-3-5-4.html] requires

"In an implementation, the range of Integer shall include the range –2**15+1 ..
+2**15–1."

There are compilers for which Integer is less than 32 bits, so assuming
otherwise is not portable. I know a lot of people don't care about portability,
but I've also seen projects that spent large sums porting code that they thought
didn't have to be portable. The cost of writing portable code is usually much
smaller than the cost of porting non-portable code.

Of course, you can always declare your own integer type with whatever range is
appropriate for your problem, though the compiler doesn't always have to accept
it. I don't know any compiler that doesn't accept 32-bit integer declarations,
nor any targeting 64-bit platforms that doesn't accept 64-bit integers. But
you're unlikely to find a compiler that will accept

range 2 .. 101 ** 101

In King (https://github.com/jrcarter/King) the compiler must accept all integer
type declarations.

--
Jeff Carter
"I didn't squawk about the steak, dear. I
merely said I didn't see that old horse
that used to be tethered outside here."
Never Give a Sucker an Even Break
103

Re: project euler 29

<87led7l3dg.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10062&group=comp.lang.ada#10062

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Fri, 15 Sep 2023 11:04:27 -0700
Organization: None to speak of
Lines: 15
Message-ID: <87led7l3dg.fsf@nosuchdomain.example.com>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<ue19di$35ura$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="9ac44d6307d20f3d8275c69cb9172ea8";
logging-data="3531042"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vw3uoutYERcLHUZNm3wEO"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:uBplki4Web3IG8YMeB1NkQhX0Do=
sha1:TqNsbvNkDVV+L17dla0F75KOCQw=
 by: Keith Thompson - Fri, 15 Sep 2023 18:04 UTC

"Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:
[...]
> can only be compiled with GNAT. Note that, unlike
> PragmARC.Unbounded_Numbers.Integers, GNAT's implementation of
> Ada.Numerics.Big_Numbers.Big_Integers is not truly unbounded. I don't
> know if it will hold 101 ** 101 without modification.

It only has to hold 100 ** 100. The Python code in the parent uses the
expression `range(2,101)`. Python's range() function yields a range
that includes the first bound and excludes the second bound.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: project euler 29

<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10064&group=comp.lang.ada#10064

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:57c4:0:b0:64a:742c:dcbd with SMTP id y4-20020ad457c4000000b0064a742cdcbdmr94021qvx.1.1694858827231;
Sat, 16 Sep 2023 03:07:07 -0700 (PDT)
X-Received: by 2002:a05:6808:13c6:b0:3a8:7543:ca00 with SMTP id
d6-20020a05680813c600b003a87543ca00mr1756806oiw.5.1694858827026; Sat, 16 Sep
2023 03:07:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.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.ada
Date: Sat, 16 Sep 2023 03:07:06 -0700 (PDT)
In-Reply-To: <874jjvmoi9.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=77.75.179.3; posting-account=ZswU3AoAAAA4QKiyoxEpA3Hh7ry7Cau3
NNTP-Posting-Host: 77.75.179.3
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com> <874jjvmoi9.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
Subject: Re: project euler 29
From: francesc.rocher@gmail.com (Francesc Rocher)
Injection-Date: Sat, 16 Sep 2023 10:07:07 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1995
 by: Francesc Rocher - Sat, 16 Sep 2023 10:07 UTC

El dia divendres, 15 de setembre de 2023 a les 17:42:43 UTC+2, Ben Bacarisse va escriure:
> "CSYH (QAQ)" <sche...@asu.edu> writes:
>
> > Now this time, I am facing trouble for problem #29. As I know integer
> > type is for 32 bits. but for this problem as me to find out the 2 **
> > 100 and even 100 ** 100. I used python to get the answer correctly in
> > 5 minutes.

> Most of the Project Euler problems have solutions that are not always
> the obvious one (though sometimes the obvious one is the best). You
> can, of course, just use a big number type (or write your own!) but this
> problem can be solved without having to use any large numbers at all.

Please take a look at this solution: https://github.com/rocher/alice-project_euler-rocher/blob/main/src/0001-0100/p0029_distinct_powers.adb
It's not using any big numbers library.

---
Francesc Rocher

Re: project euler 29

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

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10065&group=comp.lang.ada#10065

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Sat, 16 Sep 2023 21:59:51 +0100
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <87sf7dltq0.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b7cd21ae8fc8adc867bcadd01f23c303";
logging-data="5937"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OiEkc4swGF6x60V7q3HEPZSgWb1ojMqk="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:9fsqdOYCU74GWzp1RYeWXO76iyA=
sha1:qeHQckUi0VMab/aRPHRkBAiPWp0=
X-BSB-Auth: 1.2dd886ed9cfcbee44bb8.20230916215951BST.87sf7dltq0.fsf@bsb.me.uk
 by: Ben Bacarisse - Sat, 16 Sep 2023 20:59 UTC

Francesc Rocher <francesc.rocher@gmail.com> writes:

> El dia divendres, 15 de setembre de 2023 a les 17:42:43 UTC+2, Ben Bacarisse va escriure:
>> "CSYH (QAQ)" <sche...@asu.edu> writes:
>>
>> > Now this time, I am facing trouble for problem #29. As I know integer
>> > type is for 32 bits. but for this problem as me to find out the 2 **
>> > 100 and even 100 ** 100. I used python to get the answer correctly in
>> > 5 minutes.
>
>> Most of the Project Euler problems have solutions that are not always
>> the obvious one (though sometimes the obvious one is the best). You
>> can, of course, just use a big number type (or write your own!) but this
>> problem can be solved without having to use any large numbers at all.
>
> Please take a look at this solution:
> https://github.com/rocher/alice-project_euler-rocher/blob/main/src/0001-0100/p0029_distinct_powers.adb

Why?

--
Ben.

Re: project euler 29

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

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10066&group=comp.lang.ada#10066

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Sat, 16 Sep 2023 22:56:06 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <87jzsplr49.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b7cd21ae8fc8adc867bcadd01f23c303";
logging-data="26237"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1849B2ld/A16Lyvd1MR5CAMGN7Zg6suzxE="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:A8D5bKcfdJLxt0a5miOMlouaikk=
sha1:mMpJKDcb+0+Lz4q7FIRce+aAVEU=
X-BSB-Auth: 1.99b865d81c3d3a5a87ca.20230916225606BST.87jzsplr49.fsf@bsb.me.uk
 by: Ben Bacarisse - Sat, 16 Sep 2023 21:56 UTC

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

> Francesc Rocher <francesc.rocher@gmail.com> writes:
>
>> El dia divendres, 15 de setembre de 2023 a les 17:42:43 UTC+2, Ben Bacarisse va escriure:
>>> "CSYH (QAQ)" <sche...@asu.edu> writes:
>>>
>>> > Now this time, I am facing trouble for problem #29. As I know integer
>>> > type is for 32 bits. but for this problem as me to find out the 2 **
>>> > 100 and even 100 ** 100. I used python to get the answer correctly in
>>> > 5 minutes.
>>
>>> Most of the Project Euler problems have solutions that are not always
>>> the obvious one (though sometimes the obvious one is the best). You
>>> can, of course, just use a big number type (or write your own!) but this
>>> problem can be solved without having to use any large numbers at all.
>>
>> Please take a look at this solution:
>> https://github.com/rocher/alice-project_euler-rocher/blob/main/src/0001-0100/p0029_distinct_powers.adb
>
> Why?

That came over as rather curt. I meant what is it about the code that
you are drawing my attention to -- its particular use of Ada, its
structure, the algorithm, the performance...? What (and where) is
Euler_Tools?

--
Ben.

Re: project euler 29

<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10070&group=comp.lang.ada#10070

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:8b86:b0:76f:130a:c957 with SMTP id qx6-20020a05620a8b8600b0076f130ac957mr136182qkn.11.1694976991172;
Sun, 17 Sep 2023 11:56:31 -0700 (PDT)
X-Received: by 2002:a05:6808:3089:b0:3a7:5742:ce92 with SMTP id
bl9-20020a056808308900b003a75742ce92mr3270283oib.0.1694976990828; Sun, 17 Sep
2023 11:56:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.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.ada
Date: Sun, 17 Sep 2023 11:56:30 -0700 (PDT)
In-Reply-To: <87jzsplr49.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=77.75.179.3; posting-account=ZswU3AoAAAA4QKiyoxEpA3Hh7ry7Cau3
NNTP-Posting-Host: 77.75.179.3
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk> <a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
Subject: Re: project euler 29
From: francesc.rocher@gmail.com (Francesc Rocher)
Injection-Date: Sun, 17 Sep 2023 18:56:31 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3203
 by: Francesc Rocher - Sun, 17 Sep 2023 18:56 UTC

El dia dissabte, 16 de setembre de 2023 a les 23:56:11 UTC+2, Ben Bacarisse va escriure:
> Ben Bacarisse <ben.u...@bsb.me.uk> writes:
>
> > Francesc Rocher <frances...@gmail.com> writes:
> >
> >> El dia divendres, 15 de setembre de 2023 a les 17:42:43 UTC+2, Ben Bacarisse va escriure:
> >>> "CSYH (QAQ)" <sche...@asu.edu> writes:
> >>>
> >>> > Now this time, I am facing trouble for problem #29. As I know integer
> >>> > type is for 32 bits. but for this problem as me to find out the 2 **
> >>> > 100 and even 100 ** 100. I used python to get the answer correctly in
> >>> > 5 minutes.
> >>
> >>> Most of the Project Euler problems have solutions that are not always
> >>> the obvious one (though sometimes the obvious one is the best). You
> >>> can, of course, just use a big number type (or write your own!) but this
> >>> problem can be solved without having to use any large numbers at all.
> >>
> >> Please take a look at this solution:
> >> https://github.com/rocher/alice-project_euler-rocher/blob/main/src/0001-0100/p0029_distinct_powers.adb
> >
> > Why?
> That came over as rather curt. I meant what is it about the code that
> you are drawing my attention to -- its particular use of Ada, its
> structure, the algorithm, the performance...? What (and where) is
> Euler_Tools?

Well, I was sending the answer to the thread, not to anyone in particular.

I simply thought that, since you mention that this can be solved without having to use
big numbers, people in this group could be interested in seeing how. My solution to this
problem dates back to earlier this year, when I solved the first 30 problems of Project
Euler.

Euler_Tools is a repository of functions that I'm collecting while solving new problems
of Project Euler. In case you want to take a look, https://github.com/rocher/euler_tools

Also, do you have a different approach to solve this 29th problem?

BR
---
Francesc Rocher

Re: project euler 29

<874jjsquln.fsf@nightsong.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10071&group=comp.lang.ada#10071

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Sun, 17 Sep 2023 15:54:12 -0700
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <874jjsquln.fsf@nightsong.com>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="02e6da0e6d12432512a57a13e6ebb466";
logging-data="624102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cmFPp1MMsdUrYg0X2IU3q"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:kxx0mr/Eo+tGS01Os6n3HzzWlPk=
sha1:ZcfSxU2jTiYtL87cswah2lQFks8=
 by: Paul Rubin - Sun, 17 Sep 2023 22:54 UTC

Francesc Rocher <francesc.rocher@gmail.com> writes:
> Also, do you have a different approach to solve this 29th problem?

I see two natural approaches: 1) use bignums--it didn't occur to me to
not use them until this discussion. 2) Notice that a**b == c**d exactly
when the two sides have the same prime factorization, and the factors
of a**b are just the factors of a repeated b times, so you can count up
the distinct tuples of factors.

Method #2 is efficient (since a,b,c,d are all < 100) and doesn't use
bignums, but it is a fair amount of code to write unless you have
convenient libraries at hand for factorization and can easily count sets
of distinct tuples. I guess there are fancier approaches possible too,
that avoid searching 100**2 combinations, but 100**2 is just 10000 which
is small.

Certainly both are easier to do if your language or libraries has
convenient features for dealing with variable sized objects like
bignums, or sets of tuples. The bignum approach is less efficient but
it is much easier to code. The Python expression

len(set(a**b for a in range(2,101) for b in range(2,101)))

takes around 25 msec to compute on my old slow laptop.

I will look at your Ada solution!

Re: project euler 29

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

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10072&group=comp.lang.ada#10072

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Mon, 18 Sep 2023 00:08:05 +0100
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <87ediwl7oq.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4a1f049c3c0d7d3aa42e2e5e10f8a54b";
logging-data="624817"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1945EvsoBFspCKfzzgswJJ7SuJI6EVlQWU="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:tUb53hYHU1WDMiTqrKbweSZS6+A=
sha1:O+6sNKy7Dpll0zNIv+cY+8wTG3k=
X-BSB-Auth: 1.20123c5add9ec73cc8d4.20230918000805BST.87ediwl7oq.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 17 Sep 2023 23:08 UTC

Francesc Rocher <francesc.rocher@gmail.com> writes:

> El dia dissabte, 16 de setembre de 2023 a les 23:56:11 UTC+2, Ben Bacarisse va escriure:
>> Ben Bacarisse <ben.u...@bsb.me.uk> writes:
>>
>> > Francesc Rocher <frances...@gmail.com> writes:
>> >
>> >> El dia divendres, 15 de setembre de 2023 a les 17:42:43 UTC+2, Ben Bacarisse va escriure:
>> >>> "CSYH (QAQ)" <sche...@asu.edu> writes:
>> >>>
>> >>> > Now this time, I am facing trouble for problem #29. As I know integer
>> >>> > type is for 32 bits. but for this problem as me to find out the 2 **
>> >>> > 100 and even 100 ** 100. I used python to get the answer correctly in
>> >>> > 5 minutes.
>> >>
>> >>> Most of the Project Euler problems have solutions that are not always
>> >>> the obvious one (though sometimes the obvious one is the best). You
>> >>> can, of course, just use a big number type (or write your own!) but this
>> >>> problem can be solved without having to use any large numbers at all.
>> >>
>> >> Please take a look at this solution:
>> >> https://github.com/rocher/alice-project_euler-rocher/blob/main/src/0001-0100/p0029_distinct_powers.adb
>> >
>> > Why?
>> That came over as rather curt. I meant what is it about the code that
>> you are drawing my attention to -- its particular use of Ada, its
>> structure, the algorithm, the performance...? What (and where) is
>> Euler_Tools?
>
> Well, I was sending the answer to the thread, not to anyone in
> particular.

I see.

> I simply thought that, since you mention that this can be solved
> without having to use big numbers, people in this group could be
> interested in seeing how. My solution to this problem dates back to
> earlier this year, when I solved the first 30 problems of Project
> Euler.
>
> Euler_Tools is a repository of functions that I'm collecting while
> solving new problems of Project Euler. In case you want to take a
> look, https://github.com/rocher/euler_tools

I was more interested to see if I could compile your code to compare
timings etc, but I don't know how to put the pieces together.

> Also, do you have a different approach to solve this 29th problem?

Yes, but it's not in Ada. I implemented an equality test for a^b ==
c^d.

--
Ben.

Re: project euler 29

<87zg1kpcjh.fsf@nightsong.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10073&group=comp.lang.ada#10073

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Sun, 17 Sep 2023 17:09:38 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <87zg1kpcjh.fsf@nightsong.com>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="02e6da0e6d12432512a57a13e6ebb466";
logging-data="646671"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ADWhWG/i/Qo7Z/yINFR/A"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:V1Fdk6wmCuXRgMpreGRnHqR5IK4=
sha1:oytZRX9CpL2T+DWWbaLvMFEXuNI=
 by: Paul Rubin - Mon, 18 Sep 2023 00:09 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> Also, do you have a different approach to solve this 29th problem?
>
> Yes, but it's not in Ada. I implemented an equality test for a^b ==
> c^d.

Oh interesting, based on a comment in Francesc's code, I think I see a
method to do it without the auxiliary array, at a small increase in
runtime cost. Basically given a and b, you can find their prime factors
and easily enumerate the combinations x,y with a**b==x**y and
1 <= x,y <= 100. You can label each "equivalence class" by the (a,b)
with the smallest possible a.

So you just loop through 1 <= a,b <= 100 and count only the a,b pairs
where a is the smallest a for its equivalence class. I might see if I
can code this, which should also let me describe it more concisely.

Re: project euler 29

<8734zcl4j0.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10074&group=comp.lang.ada#10074

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Mon, 18 Sep 2023 01:16:19 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <8734zcl4j0.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4a1f049c3c0d7d3aa42e2e5e10f8a54b";
logging-data="643104"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SGt11WrJM/gu8BofXctTyY6bUSD9leB4="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:bxVD6sBPf+hJjS5KJmeY8mLbzBs=
sha1:/BblLvuSBXWQj0OWqRs+rnC0TCw=
X-BSB-Auth: 1.9382678f80c36cfff3d0.20230918011619BST.8734zcl4j0.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 18 Sep 2023 00:16 UTC

Paul Rubin <no.email@nospam.invalid> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>> Also, do you have a different approach to solve this 29th problem?
>>
>> Yes, but it's not in Ada. I implemented an equality test for a^b ==
>> c^d.
>
> Oh interesting, based on a comment in Francesc's code, I think I see a
> method to do it without the auxiliary array, at a small increase in
> runtime cost. Basically given a and b, you can find their prime factors
> and easily enumerate the combinations x,y with a**b==x**y and
> 1 <= x,y <= 100. You can label each "equivalence class" by the (a,b)
> with the smallest possible a.
>
> So you just loop through 1 <= a,b <= 100 and count only the a,b pairs
> where a is the smallest a for its equivalence class. I might see if I
> can code this, which should also let me describe it more concisely.

This is likely to be fast which is why I wanted to compile Francesc's to
try it out. Mind you, a naive a^b == c^d test gives pretty good
performance for the kind of range requested.

--
Ben.

Re: project euler 29

<87v8c8oyby.fsf@nightsong.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10075&group=comp.lang.ada#10075

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Sun, 17 Sep 2023 22:16:33 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <87v8c8oyby.fsf@nightsong.com>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com>
<8734zcl4j0.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="02e6da0e6d12432512a57a13e6ebb466";
logging-data="856656"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kIUl2vZyFvD1RkYit7OEW"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:RAJXe15tR8eVhqg4P40N11IVZ0k=
sha1:GjXiCpraLX7YjQRWtghpIYTbFQs=
 by: Paul Rubin - Mon, 18 Sep 2023 05:16 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> So you just loop through 1 <= a,b <= 100 and count only the a,b pairs
>> where a is the smallest a for its equivalence class.
> This is likely to be fast which is why I wanted to compile Francesc's to
> try it out. Mind you, a naive a^b == c^d test gives pretty good
> performance for the kind of range requested.

But Francesc's program doesn't use that method. It only suggests it in
a comment. The program actually works by building a list, sorting it,
and counting the groups.

Re: project euler 29

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

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10076&group=comp.lang.ada#10076

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Mon, 18 Sep 2023 12:31:10 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <87wmwnk9a9.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com>
<8734zcl4j0.fsf@bsb.me.uk> <87v8c8oyby.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4a1f049c3c0d7d3aa42e2e5e10f8a54b";
logging-data="1839543"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T7XHjht7pJXy3onTbRhYVjMNwRrP4DE8="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:32w+zvH0YRZE2DI+7OvIsHZvHLk=
sha1:fZvG2XFDurwdUeqU6FxNA3m83dY=
X-BSB-Auth: 1.87458021581c817cab5d.20230918123110BST.87wmwnk9a9.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 18 Sep 2023 11:31 UTC

Paul Rubin <no.email@nospam.invalid> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>> So you just loop through 1 <= a,b <= 100 and count only the a,b pairs
>>> where a is the smallest a for its equivalence class.
>> This is likely to be fast which is why I wanted to compile Francesc's to
>> try it out. Mind you, a naive a^b == c^d test gives pretty good
>> performance for the kind of range requested.
>
> But Francesc's program doesn't use that method. It only suggests it in
> a comment. The program actually works by building a list, sorting it,
> and counting the groups.

I only looked briefly and thought it used the factor method to decide if
the power is one that occurs earlier in the sequence. Two trivial
things, starting with Answer as the full NxN count and then decrementing
Answer made me think that was what it was doing.

--
Ben.

Re: project euler 29

<7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10077&group=comp.lang.ada#10077

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:8d07:b0:76d:c79b:4bb8 with SMTP id rb7-20020a05620a8d0700b0076dc79b4bb8mr169208qkn.1.1695042261803;
Mon, 18 Sep 2023 06:04:21 -0700 (PDT)
X-Received: by 2002:a05:6808:17a3:b0:3a1:d419:9c64 with SMTP id
bg35-20020a05680817a300b003a1d4199c64mr3716486oib.5.1695042261462; Mon, 18
Sep 2023 06:04:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.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.ada
Date: Mon, 18 Sep 2023 06:04:21 -0700 (PDT)
In-Reply-To: <87wmwnk9a9.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=77.75.179.3; posting-account=ZswU3AoAAAA4QKiyoxEpA3Hh7ry7Cau3
NNTP-Posting-Host: 77.75.179.3
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk> <a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk> <715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com> <8734zcl4j0.fsf@bsb.me.uk>
<87v8c8oyby.fsf@nightsong.com> <87wmwnk9a9.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
Subject: Re: project euler 29
From: francesc.rocher@gmail.com (Francesc Rocher)
Injection-Date: Mon, 18 Sep 2023 13:04:21 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3610
 by: Francesc Rocher - Mon, 18 Sep 2023 13:04 UTC

> > But Francesc's program doesn't use that method. It only suggests it in
> > a comment. The program actually works by building a list, sorting it,
> > and counting the groups.

> I only looked briefly and thought it used the factor method to decide if
> the power is one that occurs earlier in the sequence. Two trivial
> things, starting with Answer as the full NxN count and then decrementing
> Answer made me think that was what it was doing.

Exactly, that's the point: to find if for a given base+exponent a**b there is an
equivalent x**y with 2 <= a < x <= 100 and 2 <= y <= 100, first a and b are
factored as a product of prime numbers. In case a has multiple times the same
factor, e.g. 27 = 3*3*3 = 3**3, then the exponent 3 is used as a new factor of the
exponent. Introducing this factor requires that the list of factors of b must be
sorted to find a new base x, a < x. Otherwise you could find x > 100 and consider
that there is no such pair x and y within the limits. That's the only reason the list
of factors is sorted when a new one is introduced.

Example:
27**100 = (3*3*3)**(2*2*5*5)
= (3**3)**(2*2*5*5)
= 3**(2*2*3*5*5)
= 9**(2*3*5*5)
= 81**(3*5*5)
= 81**75

On the other hand, the algorithm first assumes that all possible combinations of
a**b are unique, and then subtracts 1 each time x and y are found for a and b.

Implementing the equality operator for a**b = x**y is also an alternative algorithm.
Using it would require a loop for a in 2..99, b in 2..100, x in a+1..100 and y in 2..100.
Is this correct? Or are there other constraints?

Anyway, for big numbers, having the equality operator a**b = x**y with the factoring
method is a good idea.

Unfortunately, my Project Euler programs are prepared to be inserted into the new Alice
project, which is a (big) work in progress and cannot be compiled easily (it requires
Alire, Project Euler for Alice and my sources, which depend on the Euler Tools).
If anyone is interested, for performance comparison or whatever reason, I can
provide a stand alone version.

BR,
-- Francesc Rocher

Re: project euler 29

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

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10078&group=comp.lang.ada#10078

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Mon, 18 Sep 2023 15:20:16 +0100
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <87il87k1gf.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com>
<8734zcl4j0.fsf@bsb.me.uk> <87v8c8oyby.fsf@nightsong.com>
<87wmwnk9a9.fsf@bsb.me.uk>
<7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4a1f049c3c0d7d3aa42e2e5e10f8a54b";
logging-data="1900518"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19P3mM57jLWSXsa30sBYR9kM6zIdGbJXN0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:ZC91k396AUZAeh1N6wjpimm6tt0=
sha1:nLUC4Cl0Pb2iu7jHimSVtuKYb+0=
X-BSB-Auth: 1.7df04d4eafe56f73bc6b.20230918152016BST.87il87k1gf.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 18 Sep 2023 14:20 UTC

Francesc Rocher <francesc.rocher@gmail.com> writes:

>> > But Francesc's program doesn't use that method. It only suggests it in
>> > a comment. The program actually works by building a list, sorting it,
>> > and counting the groups.
>
>> I only looked briefly and thought it used the factor method to decide if
>> the power is one that occurs earlier in the sequence. Two trivial
>> things, starting with Answer as the full NxN count and then decrementing
>> Answer made me think that was what it was doing.
>
> Exactly,

I thought so.

> Implementing the equality operator for a**b = x**y is also an
> alternative algorithm. Using it would require a loop for a in 2..99,
> b in 2..100, x in a+1..100 and y in 2..100. Is this correct? Or are
> there other constraints?

Well I just stored the unique pairs found so far. It's not very
efficient, but perfectly fast enough for a,b in [2, 100].

> If anyone is interested, for performance comparison or whatever reason, I can
> provide a stand alone version.

I am curious, but only if it's not too much work.

--
Ben.

Re: project euler 29

<1d8a7e1f-187c-4975-976c-004103882e2fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10079&group=comp.lang.ada#10079

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:b30:b0:656:160d:370 with SMTP id w16-20020a0562140b3000b00656160d0370mr204778qvj.8.1695056106496;
Mon, 18 Sep 2023 09:55:06 -0700 (PDT)
X-Received: by 2002:a05:6830:1d49:b0:6be:ff29:ff3f with SMTP id
p9-20020a0568301d4900b006beff29ff3fmr2816356oth.0.1695056106237; Mon, 18 Sep
2023 09:55:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!border-1.nntp.ord.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.ada
Date: Mon, 18 Sep 2023 09:55:05 -0700 (PDT)
In-Reply-To: <87il87k1gf.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=77.75.179.3; posting-account=ZswU3AoAAAA4QKiyoxEpA3Hh7ry7Cau3
NNTP-Posting-Host: 77.75.179.3
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk> <a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk> <715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com> <8734zcl4j0.fsf@bsb.me.uk>
<87v8c8oyby.fsf@nightsong.com> <87wmwnk9a9.fsf@bsb.me.uk> <7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
<87il87k1gf.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1d8a7e1f-187c-4975-976c-004103882e2fn@googlegroups.com>
Subject: Re: project euler 29
From: francesc.rocher@gmail.com (Francesc Rocher)
Injection-Date: Mon, 18 Sep 2023 16:55:06 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: Francesc Rocher - Mon, 18 Sep 2023 16:55 UTC

> I am curious, but only if it's not too much work.

Pre-condition: alr must be installed in your system.
Then, three simple steps:

1. this: git clone git@github.com/rocher/euler_tools
or: git clone https://github.com/rocher/euler_tools
2. cd euler_tools/examples
3. alr build

Included examples are problems 26 (discussed in a different thread) and 29.

BR
---
Francesc Rocher

Re: project euler 29

<877conjnge.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10080&group=comp.lang.ada#10080

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Mon, 18 Sep 2023 20:22:41 +0100
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <877conjnge.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com>
<8734zcl4j0.fsf@bsb.me.uk> <87v8c8oyby.fsf@nightsong.com>
<87wmwnk9a9.fsf@bsb.me.uk>
<7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
<87il87k1gf.fsf@bsb.me.uk>
<1d8a7e1f-187c-4975-976c-004103882e2fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4a1f049c3c0d7d3aa42e2e5e10f8a54b";
logging-data="2015877"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2vNrsPaaKJeNqjaxm5IHYBo8ahRu664w="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:akgXHOuumnCN385vO3epDjzCfdw=
sha1:nax14U+wUIhXODVFBBAItyEYNKU=
X-BSB-Auth: 1.cb1555901f6366e73c0e.20230918202241BST.877conjnge.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 18 Sep 2023 19:22 UTC

Francesc Rocher <francesc.rocher@gmail.com> writes:

>> I am curious, but only if it's not too much work.
>
> Pre-condition: alr must be installed in your system.
> Then, three simple steps:
>
> 1. this: git clone git@github.com/rocher/euler_tools
> or: git clone https://github.com/rocher/euler_tools
> 2. cd euler_tools/examples
> 3. alr build

Thanks. The https clone worked but I got

$ git clone git@github.com/rocher/euler_tools
fatal: repository 'git@github.com/rocher/euler_tools' does not exist

from the first.

--
Ben.

Re: project euler 29

<87r0mvp90f.fsf@nightsong.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10081&group=comp.lang.ada#10081

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Mon, 18 Sep 2023 12:38:08 -0700
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <87r0mvp90f.fsf@nightsong.com>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com>
<8734zcl4j0.fsf@bsb.me.uk> <87v8c8oyby.fsf@nightsong.com>
<87wmwnk9a9.fsf@bsb.me.uk>
<7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
<87il87k1gf.fsf@bsb.me.uk>
<1d8a7e1f-187c-4975-976c-004103882e2fn@googlegroups.com>
<877conjnge.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="02e6da0e6d12432512a57a13e6ebb466";
logging-data="2024161"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/o19egcbkbiR96f5U7XGd"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:SdP4sW66bugIoB/ZDpQoCdfox30=
sha1:hgS0Xd3ma2sgF7wqJt0lxFNsxYc=
 by: Paul Rubin - Mon, 18 Sep 2023 19:38 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
> $ git clone git@github.com/rocher/euler_tools
> fatal: repository 'git@github.com/rocher/euler_tools' does not exist

Try the https link instead. You may need to enroll an ssh public key on
github for the other way to work. Also maybe try euler_tools.git
instead of just euler_tools. I'm in the middle of something right now
but can check on it tonight if you don't have any luck and if Francesc
doesn't get back to you.

Re: project euler 29

<9cd51788-b164-4ecc-8360-210baab16a99n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10082&group=comp.lang.ada#10082

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:668:b0:76d:a57f:6f5a with SMTP id a8-20020a05620a066800b0076da57f6f5amr195201qkh.3.1695066742618;
Mon, 18 Sep 2023 12:52:22 -0700 (PDT)
X-Received: by 2002:a05:6808:15a4:b0:3a1:f2a4:3d7 with SMTP id
t36-20020a05680815a400b003a1f2a403d7mr4682531oiw.1.1695066742405; Mon, 18 Sep
2023 12:52:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.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.ada
Date: Mon, 18 Sep 2023 12:52:21 -0700 (PDT)
In-Reply-To: <87r0mvp90f.fsf@nightsong.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.75.179.3; posting-account=ZswU3AoAAAA4QKiyoxEpA3Hh7ry7Cau3
NNTP-Posting-Host: 77.75.179.3
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk> <a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk> <715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com> <8734zcl4j0.fsf@bsb.me.uk>
<87v8c8oyby.fsf@nightsong.com> <87wmwnk9a9.fsf@bsb.me.uk> <7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
<87il87k1gf.fsf@bsb.me.uk> <1d8a7e1f-187c-4975-976c-004103882e2fn@googlegroups.com>
<877conjnge.fsf@bsb.me.uk> <87r0mvp90f.fsf@nightsong.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9cd51788-b164-4ecc-8360-210baab16a99n@googlegroups.com>
Subject: Re: project euler 29
From: francesc.rocher@gmail.com (comp.lang.ada)
Injection-Date: Mon, 18 Sep 2023 19:52:22 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1925
 by: comp.lang.ada - Mon, 18 Sep 2023 19:52 UTC

> > $ git clone g...@github.com/rocher/euler_tools
> > fatal: repository 'g...@github.com/rocher/euler_tools' does not exist

Typo: it should be git@github.com:rocher/euler_tools
As Paul said, it requires having a github account configured with an ssh key.

BR
---
Francesc Rocher

Re: project euler 29

<45c21641-ffda-4d88-aceb-d8de1d6d7878n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10083&group=comp.lang.ada#10083

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:4b2d:0:b0:656:2d0a:fab4 with SMTP id s13-20020ad44b2d000000b006562d0afab4mr209504qvw.8.1695066960839;
Mon, 18 Sep 2023 12:56:00 -0700 (PDT)
X-Received: by 2002:a05:6870:c82b:b0:1c5:87d6:b779 with SMTP id
ee43-20020a056870c82b00b001c587d6b779mr3477472oab.8.1695066960528; Mon, 18
Sep 2023 12:56:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!border-1.nntp.ord.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.ada
Date: Mon, 18 Sep 2023 12:56:00 -0700 (PDT)
In-Reply-To: <9cd51788-b164-4ecc-8360-210baab16a99n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.75.179.3; posting-account=ZswU3AoAAAA4QKiyoxEpA3Hh7ry7Cau3
NNTP-Posting-Host: 77.75.179.3
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk> <a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk> <715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com> <8734zcl4j0.fsf@bsb.me.uk>
<87v8c8oyby.fsf@nightsong.com> <87wmwnk9a9.fsf@bsb.me.uk> <7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
<87il87k1gf.fsf@bsb.me.uk> <1d8a7e1f-187c-4975-976c-004103882e2fn@googlegroups.com>
<877conjnge.fsf@bsb.me.uk> <87r0mvp90f.fsf@nightsong.com> <9cd51788-b164-4ecc-8360-210baab16a99n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <45c21641-ffda-4d88-aceb-d8de1d6d7878n@googlegroups.com>
Subject: Re: project euler 29
From: francesc.rocher@gmail.com (comp.lang.ada)
Injection-Date: Mon, 18 Sep 2023 19:56:00 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 7
 by: comp.lang.ada - Mon, 18 Sep 2023 19:56 UTC

> Typo: it should be g...@github.com:rocher/euler_tools

Damn it! The server modifies the address!!
It should say, without spaces: git [at] github.com:rocher/euler_tools

BR
---
Francesc Rocher

Re: project euler 29

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

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=10084&group=comp.lang.ada#10084

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: project euler 29
Date: Mon, 18 Sep 2023 21:01:57 +0100
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <87v8c7i72i.fsf@bsb.me.uk>
References: <beaa0494-5783-4130-b96f-1a5271466678n@googlegroups.com>
<874jjvmoi9.fsf@bsb.me.uk>
<a10a258f-8a3a-4017-bb30-8fe5629089ffn@googlegroups.com>
<87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk>
<715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com>
<87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com>
<8734zcl4j0.fsf@bsb.me.uk> <87v8c8oyby.fsf@nightsong.com>
<87wmwnk9a9.fsf@bsb.me.uk>
<7a98a430-a01d-41e7-80fe-bc2e1e1592d3n@googlegroups.com>
<87il87k1gf.fsf@bsb.me.uk>
<1d8a7e1f-187c-4975-976c-004103882e2fn@googlegroups.com>
<877conjnge.fsf@bsb.me.uk> <87r0mvp90f.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4a1f049c3c0d7d3aa42e2e5e10f8a54b";
logging-data="2032392"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lo06JekmtNDz4kvJspV+OJT+jBj5PcDE="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:tLERBEp05xbWm5ld8/sJ0hq7FMg=
sha1:cX6hGXYCIVoHiUubVBRIjPtINSM=
X-BSB-Auth: 1.7c3fdbb72d27e71b5dbe.20230918210157BST.87v8c7i72i.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 18 Sep 2023 20:01 UTC

Paul Rubin <no.email@nospam.invalid> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> $ git clone git@github.com/rocher/euler_tools
>> fatal: repository 'git@github.com/rocher/euler_tools' does not exist
>
> Try the https link instead.

I said it worked in the text just prior to the part you quoted!

--
Ben.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor