17
\$\begingroup\$

The Factorial challenge is one of the canonical challenges on our site. Just like "Hello World", "Add two numbers", "Primality test", and "Fibonacci", it attracts answers written in newly created languages every now and then. But still, it has a set of old-fashioned requirements on the domain, performance, and banning built-ins:

  • Does not use any built-in libraries that can calculate the factorial (this includes any form of eval)
  • Can calculate factorials for numbers up to 125
  • Can calculate the factorial for the number 0 (equal to 1)
  • Completes in under a minute for numbers up to 125

The third point is perfectly valid requirement because it is part of the definition of factorial, but other three have problems.

125! is a 210-digit integer, which cannot be accurately represented in machine precision (neither int64 nor float64), so it obviously requires infinite-precision integers (either built-in or rolling one's own), which unnecessarily penalizes the languages without built-in support. Some of the pre-existing answers may already fail this requirement.

The performance requirement is even worse. It entirely bans the Turing tarpits where the only operation on a number is increment, since it would need to run the increment command at least 125! times to get the answer no matter what. If you insist to implement multi-digit system to enhance the performance, it doesn't solve the problem; it just changes the problem to the one in the previous paragraph.

Note that many existing answers already violate some of the rules, mostly by using machine-size int/float number type or by using Brainfuck and ignoring performance.

I believe that, under the current site culture, we consider a solution valid if

  • it solves the task at least theoretically in finite time, given enough time and memory;
  • if it uses limited precision built-in number type, the solution would work for higher numbers if the number type were infinite-precision.

And I think, if we agree that it is one of the canonical challenges, we should encourage participation in more languages by lifting the restrictions.

So the question is (as in the title): Should we remove unnecessary restrictions on the factorial challenge?

\$\endgroup\$
6
  • \$\begingroup\$ Wouldn't doing this render every existing answer in a language that doesn't have an arbitrary precision built-in not a serious contender? \$\endgroup\$ Aug 13, 2020 at 1:04
  • 8
    \$\begingroup\$ @pppery Nope, answers are not forced to choose the optimal approach. It's okay to be the shortest undersome additional conditions (using approach X). \$\endgroup\$
    – DELETE_ME
    Aug 13, 2020 at 1:50
  • 1
    \$\begingroup\$ @pppery I glanced through all ~200 answers currently posted, and I think no answers so far actually implemented multi-precision arithmetic from scratch. Most answers in languages without arbitrary precision support are just using float64. \$\endgroup\$
    – Bubbler
    Aug 13, 2020 at 2:02
  • \$\begingroup\$ (and thus are invalid)? \$\endgroup\$ Aug 13, 2020 at 2:04
  • 2
    \$\begingroup\$ @pppery If you mean for the answers using float64, yes IMO, or at least questionable because it does calculate the thing, but with loss of precision. This part makes the current challenge unclear too. \$\endgroup\$
    – Bubbler
    Aug 13, 2020 at 2:07
  • 1
    \$\begingroup\$ Personally I'm opposed to edits being made that obviously conflict with a challenge writer's explicit intentions (regardless of the community's collective opinion on those intentions). What would be the attitude towards creating a new factorial challenge that removes the restrictions? Would it be different enough not to be considered a duplicate? \$\endgroup\$
    – Dingus
    Aug 13, 2020 at 12:23

3 Answers 3

14
\$\begingroup\$

No, we shouldn't, but...

I agree with the idea that we should not change a challenge unless the original OP wants to, especially when changing these rules might make older answers non-competitive.

However, I am fully in support of the idea of a "canonical" challenge. Here on CGSE many of us, myself included, have developed our own programming languages. These canonical challenges are excellent places to demonstrate the power of esoteric languages! Of course, there are many languages where tasks like these would be trivial, but there are a lot of languages (e.g. brainf*** and my new language) where solutions would be very interesting and creative.

I would be in support of someone posting a new, completely vanilla factorial challenge with only the third requirement. As it does not have the other three arbitrary restrictions, I would argue that this challenge would not be a dupe of the old challenge (but others might disagree). These other requirements actually stopped me from posting a creative answer in my new language, and there is no vanilla factorial challenge to post it on.

tl;dr

I don't think we should change the linked challenge but I would like to see a new, completely vanilla factorial challenge which only has the third requirement.

EDIT:

We finally have a vanilla factorial challenge! Here's the answer that didn't fit the requirements of the last challenge (it didn't fit because it uses eval functions)

\$\endgroup\$
3
  • 1
    \$\begingroup\$ +1. Yes, in this sense, my answer contradicts myself. We should open a new factorial challenge, and close the old one as dupe. \$\endgroup\$ Aug 17, 2020 at 2:34
  • \$\begingroup\$ Now I suppose this one is the consensus - my answer +3/-4, caird's answer +6/-5, this one +11/-2. \$\endgroup\$ Aug 19, 2020 at 14:27
  • 2
    \$\begingroup\$ I just wrote the sandbox challenge for the "vanilla factorial". \$\endgroup\$
    – Bubbler
    Aug 20, 2020 at 0:14
4
\$\begingroup\$

No, we shouldn't

Unless the original OP, Kevin Brown agrees that we should, I believe we shouldn't change the challenge. If any existing answers to the challenge are invalid, then raise that point with the answerers, and if unaddressed, flag the answers as invalid.

If a language cannot answer a challenge as it's currently written, then it cannot answer that challenge. Not every language can comply and compete in every challenge. The requirements of the question do make it harder to compete in than, for example, "Add two numbers", but that doesn't mean we should edit it in order to "make it easier".

Furthermore, I disagree with the idea of a "canonical" challenge. Challenges like "Hello, World!" and "Primality test" were specifically drafted to be catalogue questions, open to as many languages as possible. However, as a general rule, we have abandoned catalogue questions, so, in my view, there is no need to edit an existing challenge to make it more of a catalogue-style question.

Ultimately, we shouldn't make a challenge easier, just so more people can compete. It's been an oversight for the past 10 years that none of the invalid answers have been corrected/removed, but that's what we should be correcting, not the (perfectly valid) question spec.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Question: is closing the question & create a new one without those restrictions acceptable? (Almost certainly not.) If not, then how do we deal with this challenge? We definitely need a factorial question so we can post our golfed factorial programs there, but if they are flagged, ...nope. It's impossible to let the OP change because he's already not on PPCG for many years. We have already removed restrictions from challenges without agreement from the OP. I seem to recall there are better examples, but all I could find is \$\endgroup\$ Aug 13, 2020 at 12:46
  • 1
    \$\begingroup\$ this for now. I'm also frowned upon the decision of abandoning catalog. \$\endgroup\$ Aug 13, 2020 at 12:47
  • \$\begingroup\$ @HighlyRadioactive If it’s accepted that we shouldn’t change the challenge, then you‘re free to open a meta question on whether we should post a „canon“ factorial question. I‘m not sure how to deal with it, I‘m just saying that we shouldn’t edit someone‘s question to make it more accessible. Personally, if someone decided one of my questions wasn’t accessible enough and edited it to make it so, I‘d immediately reverse the edit and ask them to not do it again. And Kevin Brown is still (somewhat) active on the site, having visited the site today according to their profile \$\endgroup\$ Aug 13, 2020 at 12:50
  • \$\begingroup\$ I think we already have consensus on we shall not open new challenges but I can't find it. (Since you can't move the answers on the old challenge, and the goal of such questions are to keep things at a single place, not two.) Although, I'm pretty new to Meta. \$\endgroup\$ Aug 13, 2020 at 12:52
  • 1
    \$\begingroup\$ I was going to suggest possibly re-asking it with more "current" rules (and closing the old one as a dupe), but I'm not sure if that's a good idea, since it'll open up a horrible can of worms any time we get a certain level of consensus shift. \$\endgroup\$
    – Giuseppe
    Aug 13, 2020 at 17:00
-1
\$\begingroup\$

Yes, we should.

Just like closing old challenges as duplicates of new challenges.

\$\endgroup\$
1
  • \$\begingroup\$ I think the point of the factorial function is how does one handle large integers. \$\endgroup\$
    – Xwtek
    Dec 13, 2021 at 14:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .