Challenges tagged as involve "deciding whether the input meets certain criteria". Although some challenges with this tag involve more than two categories, most involve only two categories, which seems to be the main purpose of the tag. This meta question refers to two-category decision problems only. The challenge is then equivalent to a question, such as "is the input number even?", and any possible input can be classified as "affirmative" if the answer is "yes", and "negative" if the answer is "no".

The purpose of this meta question is to decide a policy for the default options for output in two-category decision-problems. Having a default policy would be good, so that challenge writers don't need to state what is allowed as an output in every challenge. This related meta question asks what are some good options for challenge writers to use. Of course, answers to that meta question may be good answers for this one, but choosing the default options is a different matter, which deserves to be voted on separately.

Here are some possibilities regarding allowed outputs. This list is not meant to be exhaustive:

  1. "Consistent / consistent": Produce a consistent output (a number, a string, anything) for affirmative inputs, and a different, consistent output (again, it can be anything) for negative inputs. There are only two possible outputs.
  2. "Consistent / non-consistent": Produce a consistent output for affirmative inputs, and any other, non-consistent output for negative inputs. "Non-consistent" here means that each negative input can produce a different output.
  3. "Non-consistent truthy / non-consistent falsy": produce a non-consistent truthy output if the input is affirmative, and a non-consistent falsy output if it is negative. Each input produces a possibly different output.
  4. "Consistent truthy / consistent falsy": like 1, but in addition the consistent output for affirmative input must be truthy, and the consistent output for negative input must be falsy.
  5. "Non-consistent falsy / non-consistent truthy": like 3, but swapped. So an affirmative input produces any falsy output, and a negative input produces any truthy output.

Please post or vote answers to this meta question indicating which options should be the default for decision problems. Note that

  • It probably makes sense to allow more than one options as default. For example, a proposed default rule might be to let answer writers choose between options 1 and 3 above. For clarity, each answer to this meta question should be self-contained, and state all the possibilities that are proposed as default policy.
  • The default rules would only apply if the challenge doesn't specify otherwise. Of course, any challenge writer can override the default rules.
  • "Truthy" and "falsy" are defined as usual.
  • This meta question doesn't address output formats, whose general default rules are well established.
  • \$\begingroup\$ It's the policy for "ouput"? I can't edit, unfortunately... \$\endgroup\$
    – W D
    Commented Mar 1, 2022 at 5:39
  • \$\begingroup\$ @WD Thank you! Corrected \$\endgroup\$
    – Luis Mendo
    Commented Mar 1, 2022 at 13:17

7 Answers 7


Truthy/falsy using your language's convention (swapping allowed), or two distinct values to represent true/false respectively

You can choose to

  • output truthy/falsy using your language's convention (swapping is allowed), or
  • use two distinct, fixed values to represent true (affirmative) or false (negative) respectively.

Copy-friendly version:

For output, you can choose to
* output truthy/falsy using your language's convention (swapping is allowed), or
* use two distinct, fixed values to represent true (affirmative) or false (negative) respectively.

This one is what I regularly use on my own challenges. It has some slightly different wording from Luis Mendo's suggestion. I had some criticisms on the output "restriction" when I disallowed swapping truthy/falsy for case 1, but didn't face any when I allowed it.

  • \$\begingroup\$ Yes and yes. Changed the wording of "truthy/falsy" in option 2; I hope it's clearer now. \$\endgroup\$
    – Bubbler
    Commented Aug 11, 2020 at 23:52
  • \$\begingroup\$ Yes, I think it’s clearer now. And I like your proposal \$\endgroup\$
    – Luis Mendo
    Commented Aug 12, 2020 at 0:11

A function submission may reject inputs by raise an exception

Some language have supports with exception. For example, when parsing an integer, the function may raise / throw an exception when the given input is invalid integer format.

The function submission may accept the input by returning without exceptions, but raise an exception when reject the inputs.


No default

Keep it so that challenge writers need to specify.

I don't think any option has become standard enough to be default -- my meta question has multiple well-upvoted suggestions, and recent challenges have used various rules. Given this, a default would strike me as a hidden rule, with it being confusing for a challenge to not say and expect solvers to know from this meta post or the like.

I'm for standardizing defaults in general, but I think we're not at that point for decision problem output.

  • 1
    \$\begingroup\$ I see your point. On the other hand, often the challenge writer forgets to specify, and thus the challenge is not well defined \$\endgroup\$
    – Luis Mendo
    Commented Aug 12, 2020 at 4:46
  • 2
    \$\begingroup\$ @LuisMendo In that vein, I'd be for something weaker as "here's what we suggest challenge writers use by default", and suggest challenge writers who didn't specify use that. I was kind-of hoping to gather that with my meta question, but it turned into more brainstorming new ideas I hadn't considered, which was probably actually more useful. I guess we could also edit such challenges ourselves, but I think this is something where an asker might have a reasonable preference to use something different for the challenge they intend, so I'd prefer to have them edit it. \$\endgroup\$
    – xnor
    Commented Aug 12, 2020 at 4:53
  • 4
    \$\begingroup\$ @LuisMendo I'd really prefer if we don't allow people to elide output information like that from the challenge, intentionally or accidentally. It means that newcomers need to go to the meta or the tag wiki to find out what they need to do. Of course some things have to be elided to keep the challenge sizes sane, but I don't think that it is valuable to have it elided in this case. So if someone leaves out the output specification I think it is a good thing that that challenge is unclear since it an easy enough fix that improves the challenge. \$\endgroup\$
    – Wheat Wizard Mod
    Commented Aug 12, 2020 at 14:44

"Consistent / consistent" or "non-consistent truthy / non-consistent falsy"

By default, the answer writer can choose any of these (options 1 and 3 described in the question):

  • Produce two consistent outputs for affirmative and negative inputs respectively; or
  • Produce a possibly non-consistent truthy output if the input is affirmative, and a possibly non-consistent falsy output if it is negative.

"Consistent / non-consistent" or "non-consistent truthy / non-consistent falsy", both invertible, answerer chooses

Although I feel a certain impulse to advocate for lenient rules considering my inclination to take full advantage of them, the real rationale for these defaults is reducing uninteresting parts of solutions, because any solution written under these rules could be trivially modified to meet stricter ones through equality checks and negations, obscuring and weighing down the clever meat of a solution, and that's no fun. Such an argument could be taken so far as to support any two disjoint sets of outputs as an acceptable method, which is clearly not acceptable, but reducing that to a simpler form is interesting--or else that wouldn't be what all these challenges are about!


When output using exit status, a success exit means accept, a failed exit means reject

A full program may accept / reject an input by its exit status. Typically, a zero exit status means success (accept), and a non-zero exit status means fail (reject) on most platforms.


An HTTP Server may use 2xx response status codes to accept inputs, use 4xx response status codes to reject inputs

Typically, 2xx response status means the execution is successful, while 4xx response status means the input is invalid. The same semantics may be applied to decision problems.


You must log in to answer this question.

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