From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: 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 Message-ID: <87il87k1gf.fsf@bsb.me.uk> References: <874jjvmoi9.fsf@bsb.me.uk> <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 Xref: news.eternal-september.org comp.lang.ada:65677 List-Id: Francesc Rocher 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.