8
\$\begingroup\$

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.
| |
\$\endgroup\$
6
\$\begingroup\$

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

You can choose to

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

Copy-friendly version:

You can choose to
1. output truthy/falsy using your language's convention (swapping is allowed), or
2. use two distinct 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.

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

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.

| |
\$\endgroup\$
  • \$\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 Aug 12 at 4:46
  • 1
    \$\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 Aug 12 at 4:53
  • 3
    \$\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 Aug 12 at 14:44
3
\$\begingroup\$

"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.
| |
\$\endgroup\$
2
\$\begingroup\$

"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!

| |
\$\endgroup\$

You must log in to answer this question.

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