Talk:Pandigital prime

From Rosetta Code

Direct copy of Project Euler problems

This is the second Project Euler problem which is proposed as Rosetta Task without any change. Of course, there is no copyright on this problems but are we going to take all Project Euler problems to feed Rosetta Code? Moreover, this is not fair for Project Euler as we are now spoiling its problems by providing solutions. I suggest removing this task and the task Permuted_multiples. --lscrd (talk) 16:19, 5 September 2021 (UTC)

I agree. If I hadn't gotten so much push back before when I tried to moderate added draft tasks this would already be gone. --Thundergnat (talk) 17:39, 5 September 2021 (UTC)
I also agree that Calmosoft should be asked to desist from posting any more unmodified Project Euler tasks or risk having them deleted. However, I'd let the ones that have already been posted stand as a lot of thought has been put into finding optimal solutions by various contributors. --PureFox (talk) 17:54, 5 September 2021 (UTC)
+1 however Permuted_multiples potentially has some merit, unlike this task and especially Special_pythagorean_triplet, which is entirely about devising an efficient algorithm and nothing at all to do with the differences between programming languages. Mind you the same could be said for the older Sum_multiples_of_3_and_5. I certainly don't envy anyone trying to police this. One thing Calmosoft is either unwilling or incapable of comprehending is that projecteuler plainly says "don't", though it is more debateable as to who is making a more of a fool of themselves: him for posting these tasks in the first place, or those of us that far too eagerly start submitting solutions, and I am not entirely innocent there. --Pete Lomax (talk) 18:08, 5 September 2021 (UTC)


Problem is, we all provide solutions to these tasks and then say we want to delete them - maybe if we just ignored the tasks we don't like, didn't post solutions and waited for Thundergnat to rule on them, there might be more justification for deleting them. Perhaps we could flag then as "Under Review - post solutions at your own risk" or something ?

RC has a Category:Simple for easier programming tasks - the Sum_multiples_of_3_and_5 could fall into that category. I like that task as a small amount of thought can yield a better solution than the obvious one.

What do you particularly dislike about Special_pythagorean_triplet (a task you have provided two solutions for) ?
No description (grounds alone for immediate deletion imo) and no added value. See also below. --Pete Lomax (talk) 02:30, 6 September 2021 (UTC)
Other than several of the solution authors haven't read the task description and/or have neglected to calculate a * b * c, I have no problem with it. I for one, put not inconsiderable thought and effort into it, as I imagine Nigel, yourself and several other people did too. For that reason alone I think it should stand.

However, I must agree that RC should not just be a collection of tasks "find primes with property X" and "solve Project Euler Problem Y" and perhaps we should draw the line here.

The use of the task test verbatim from Project Euler worried me considerably, however I believe their license allows it - after re-reading the license page several times, I came to the concluson that the bit that says it can't be re-published is refering to everything else except the problem itself. I'm not a lawyer though, so I could be wrong... Whether their license means the task page as a whole is now under the Creative Commons license is also something I'm not qualified to say. It might be better to change the description to something like "Solve the Project Euler problem here" (where here is a link to their page) and remove all actual PE text.

--Tigerofdarkness (talk) 19:25, 5 September 2021 (UTC)
This is not only a problem of license, but also to be fair with other projects. And one of Euler Project rules is that those who have found a solution accept to not publish it. To be honest, this rule doesn’t apply to problems 1 to 100. Here is what is stated in Project Euler “about” page:
However, the rule about sharing solutions outside of Project Euler does not apply to the first one-hundred problems, as long as any discussion clearly aims to instruct methods, not just provide answers, and does not directly threaten to undermine the enjoyment of solving later problems. Problems 1 to 100 provide a wealth of helpful introductory teaching material and if you are able to respect our requirements, then we give permission for those problems and their solutions to be discussed elsewhere.
But I’m not sure that simply referring to some Project Euler problem without any added value respects the requirements.
--lscrd (talk) 19:53, 5 September 2021 (UTC)


I see your point - I'm not a Project Euler member and was not aware of their request re-solutions to their problems. I agree this is worrying and distasteful.
However, looking at the Sum multiples of 3 and 5 task, it was created in 2013 and has thus been precendent setting for 8 years. Paddy flagged the (possible) Project Euler origin in 2013 but that didn't stop 102 languages providing solutions.
As far as I can see, we have three options (not that it is up to me):

  • Delete all Project Euler related tasks, no matter how many solutions they have and ban such tasks in future.
  • Accept where we are but ban anything from Project Euler in future.
  • Continue in our mis-guided ways.

Unfortunately, I think either the first or second option should be adopted. We should certainly say no-more in future.
--Tigerofdarkness (talk) 20:25, 5 September 2021 (UTC)
I’m a Project Euler member but I didn’t remember the special rule for problems 1 to 100. I found it when I looked more precisely to the rules in the “about” page. As there is some flexibility for these problems, reusing them is not a really a violation of Project Euler rules. And, in fact, if there as discussions about the algorithms, we respect Project Euler requirements.
So, even if I still think than reusing he problem without any added value is a bit unfair, I’m now more forgiving. I suggest that we avoid Project Euler tasks if possible, except if we have some added value to offer. And that in any case, we refuse tasks which are not from the first hundred ones as it would be a clear violation of Project Euler rules. To be honest, this is only a policy position. You can solve any task without being a member and, so, are not committed to follow, even morally, Project Euler rules.
Hmm, I think plagiarism is equally immoral whether you are a member or not. --Pete Lomax (talk) 02:56, 6 September 2021 (UTC)
For existing tasks, I finally propose to keep them. At least, the limits of what is acceptable are somewhat more clear.
--lscrd (talk) 21:02, 5 September 2021 (UTC)
To recap, the about page of projecteuler states
I learned so much solving problem XXX, so is it okay to publish my solution elsewhere?
...Please do not deny others what you have so richly valued yourself.
...However/1 to 100/if you are able to respect/to be discussed elsewhere.
A "good" rosettacode task (usually) asks for implementation of a specific algorithm, with links to wikipedia/mathworld/oeis and some if not all expected results, whereas projecteuler is "solve this puzzle", with no algorithm and never any answer. The former encourages comparable submissions (the primary purpose of this site), and things that could (with due care) be re-used elsewhere, whereas the latter encourages highly divergent solutions and almost always non-reusable code.
(Obviously not every task submission is comparable on rc, but that is inevitable if you allow imperative/functional/declarative/stack-based/object-oriented and all the other programming paradigms.)
"Puzzles" are not a good fit, and it is clearly totally disrespectful to just dump them verbatim here. There is also a subtlety that I too missed on first reading:
That page grants some permission to publish a solution, but in no way expresses permission to ask for other solutions on a different site.
The only exception would/might be to further explore some clearly specified approach. --Pete Lomax (talk) 02:30, 6 September 2021 (UTC)


How about ...

... altering the task description to include zero? This gives it a different answer. Here is a proposed solution in C#: <lang csharp>using System;

class Program {

 // Find the highest pandigital number in base 10 (including the digit zero)

 // Since the sum-of-digits of the pandigital numbers 0..9 and 0..8 are respectively 45 and 36, (both
 // divisible by 3 and therefore always composite), we will only be looking at pandigital numbers 0..7

 static void Main(string[] args) {
   var sw = System.Diagnostics.Stopwatch.StartNew();
   // The difference between every permutation is a multiple of 9.  To check odds only, start at XXXXXX01
   // and decrement by 18.  It's slightly faster to check pan-digitality before the multi-factor test.

   for (int x = 76543201; ; x -= 18) {

     // Tests for pan-digitality of x
     // Hard-coded to only check for digits 0 through 7.  If a duplicate occurs, at least one of the
     // other required digits 0..7 will be missing, and therefore rejected.
     var s = x.ToString();
     for (var ch = '0'; ch < '8'; ch++) if (s.IndexOf(ch) < 0) goto bottom;

     // Multi-factor test
     // There is no check for even numbers since starting on an odd number and stepping by an even number
     if (x % 3 == 0) continue;
     for (int i = 1; i * i < x; ) {
       if (x % (i += 4) == 0) goto bottom;
       if (x % (i += 2) == 0) goto bottom;
     }
     sw.Stop(); Console.Write("{0} {1} μs", x, sw.Elapsed.TotalMilliseconds * 1000); break;
     bottom: ;
   }
 }

}</lang>

Output:

@ Tio.run:

76540231 41.4 μs
--Enter your username (talk) 16:48, 10 September 2021 (UTC)

P.S. The task description would have to be altered to give the example of the 0..4 pandigital as follows:

Task
The following problem is inspired by Project Euler problem 41.
We shall say that an 0..n number is pandigital if it makes use of all the digits 0 to n exactly once. For example, 43201 is a 0..4 pandigital and is also prime.
What is the largest 0..n pandigital prime that exists?
Assume that the problem is talking about decimal numbers.

The goofy thing is that the highest odd 0..4 pandigital number is also prime, so not much of a search is needed for 0..4 pandigital. This may be why P.E. didn't include the zero in their problem.

Good idea, assuming the authors of the existing solutions are OK with it (currently there are 11).--Tigerofdarkness (talk) 20:17, 10 September 2021 (UTC)
Why not do both? As in: a pandigitial makes use of all the digits 1 to n, a pandigital0 uses all the digits 0 to n. Added a "with 0" section to the Phix entry, even with the full inner workings of both the output is still quite short. --Pete Lomax (talk) 10:00, 11 September 2021 (UTC)
Yeah, doing both seems a better idea to me and, if we make the '0' version optional, the existing solutions will still be valid. --PureFox (talk) 10:43, 11 September 2021 (UTC)
OK, added the optional part, and removed my non-0 version. --Pete Lomax (talk) 12:33, 11 September 2021 (UTC)