2
\$\begingroup\$

This question already has an answer here:

When solving a , a program takes an input and either accepts or rejects it. How is accepting and rejecting defined for the purposes of code golf?

\$\endgroup\$

marked as duplicate by Stephen, mbomb007, HyperNeutrino, Gryphon - Reinstate Monica, pppery Aug 2 '17 at 1:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1
\$\begingroup\$

In challenges, solutions output one of two distinct outputs, depending on the properties of the input. "Accepting" and "rejecting" can be mapped to those two distinct outputs - one represents acceptance, and the other represents rejection. How the mapping is done depends on the challenge - if the challenge is of the "Does the input have property X" variety, then the "accepted" output is whichever output is given for inputs with the property, and the "rejected" output is the other one.

For challenges of the form "Is the input part of set X or set Y", it's less clear (especially if X and Y are not complements of each other). But, in those challenges, there's not really a need to distinguish "acceptance" from "rejection" (and if there is, the challenge can be rephrased as "Does the input belong to set X?").

\$\endgroup\$
-1
\$\begingroup\$

The programmer chooses either to output a truthy/falsey value, or to crash or not crash

The programmer picks between two options:

  • Their program always outputs a truthy/falsey value. If it corresponds to true, it has accepted the input. If it corresponds to false, it has rejected the input. (If it does not output a truthy value, it has neither accepted nor rejected the input, and, depending on the question, is probably incorrect.)
  • Their program either terminates with no errors or with errors. If it terminates with no errors, it has accepted the input. If it terminates with errors, it has rejected the input. (If it does not terminate, it has neither accepted nor rejected the input, and, depending on the question, is probably incorrect.)
\$\endgroup\$
  • 3
    \$\begingroup\$ "a truthy value [...] If it corresponds to false," What? \$\endgroup\$ – Doorknob Jun 1 '17 at 22:51
  • \$\begingroup\$ @Doorknob like, boolean like \$\endgroup\$ – PyRulez Jun 1 '17 at 23:05
  • \$\begingroup\$ Evaluating truthiness for an output is a bit weird. Let's say a program writes the character 0 to standard output. Is that truthy? In some languages, all non-empty strings are truthy. Or are we implicitly assuming there is some kind of type conversion and parsing of the output into some other type? Are we assuming that the text "0" should be read as an integer, and then evaluated, as if it was an expression in that same language? It's all pretty weird and murky. Is no output falsy? Is a newline with nothing else falsy? Etc. \$\endgroup\$ – Steve Bennett Jun 5 '17 at 7:52

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