Some languages have ambiguity in what is considered truthy/falsey. For example in c, zero vs non-zero is always FALSE vs TRUE from the point of view of conditional operators. But many standard APIs, for example return -1 for FAILURE and >=0 for SUCCESS. So answers may choose (and explicitly state) whatever sets of values they like to represent truthy vs ...
I agree with the wikipedia definition. It's a sequence of characters. As the name suggests, it's one-dimensional. I program a lot in C and sometimes in Pascal, which both implement strings in different ways.
C doesn't have a string type, only char with a string by convention being terminated by a zero byte.
Original Pascal has a String type which has a ...
The term "random" means that you may:
Use your language's built-in random number generator,
Use /dev/random, or
Create a RNG that is equivalent to a standard RNG (such as the Mersenne Twister).
"input" and "output"
Refer to Default for Code Golf: Input/Output methods. The list includes, but not is limited to:
function argument/return value
command line arguments/program exit code
reading from/writing to a file
popping from/pushing to the stack (for stack-based languages like GolfScript; this is essentially the equivalent ...
There are two distinct things to define for "uniform" (in the context of uniformly distributed random variables).
If "uniform" is not specified, then "random" does not imply uniformly random.
If "uniform" is specified, the standard PRNG (pseudo random number generator) of your programming ...
The content (i.e. the code) of black-box-functions may not be accessed, you can only call them (passing arguments if applicable) and observe their output.
They should also have no side effects, except for e.g. accessing RNGs or time, but no communication with the rest of the program should take place other than through the ...
"Positive", "Negative", "Non-Negative", "Non-Positive"
Positive, by default, means strictly positive, ie. all N larger than zero. Zero is not a positive number.
Negative means all N less than zero. Zero is not a negative number.
Non-negative means all N larger than or equal to zero. Zero is a non-negative number.
I would partition values into the categories truthy, falsy, and indeterminate according to the following rules:
The following values are considered falsy:
the zero value of the type of the result, if any
a NULL pointer
an array, the product of its dimensions being zero
a number whose absolute difference to 0 is not larger than 2-44.
a string literal parsed ...
This is what I use in my challenges (with slightly different wordings):
The algorithm should theoretically work for arbitrarily large input values. In practice, it is acceptable if the program is limited by time, memory, or data-type size.
Small variations may be needed in each challenge:
The arbitrarily large input values part may be tailored to the ...
Outputs are consistent if they are equal in the sanest and most obvious way of comparing them. For example, if you have two char * strings in C or C++, and you try
a == b
you will get a falsy value even if the strings are equal. But every half-decent C programmer knows that you don't compare strings with ==. That's the reason this SO question has almost 50,...
Universally testable answers
An answer will be considered to be universally testable if:
It is written in a programming language which has a compiler/interpreter available on Windows, Linux & Mac where said compiler/interpreter can be downloaded from the web free of charge (not including free trials) and does not require sign up/registration.
or it is ...
I don't this cannot be defined in in an objective and satisfactory way.
We can talk about the behavior of a program as more memory is added to a computer, or more computing time is given. Since we actually contruct proofs about behavior based on the semantics of the language, this is entirely objective. (note that this is not computable, so it cannot be ...
I find this might be a case where the OP expects answers to respect the “spirit of the law” rather than solely the “letter of the law.”
If the OP expected full compliance, then yes, languages like bash would likely be wholly disqualified. Rather, I think the OP usually means “do not use any ‘dead string’ which will directly contribute to the answer.” That ...
I think Truthy/Falsey instead of being language specific is problem (answer) specific. So in a language we can define different truthy/falsey s based on different conditions. For example one can define truthy as 53 and other things regarded as falsey and in the other problem truthy may be defined as an empty list and anything else may be defined as falsey.
If a language makes a distinction between char and String, I think a good question to ask is "Does a char print like a string?" If it is possible to print a char so that it looks like String, then you can use it. Many questions give the option of printing or returning the output, so I think the returned output should look similar to the printed ...
A string is also a list of single character strings. For example:
["H", "e", "l", "l", "o", ",", " ", "w", "o", "r", "l", "d", "!"]
While technically different, this is not thematically different from a list of characters. Therefore I believe agrees with the current consensus' conclusion that the Wikipedia definition of "a sequence of characters". I don't ...
You're over-thinking the problem. Unless the challenge specifically states that you must use the native "string" type of the language, you get to interpret what "string" means in a way that's most advantageous to your implementation.
Answers should be able to specify what is truthy and what is falsy
Almost all of the answers here are either ambiguous or put some languages at a disadvantage.
For the top rated answer, there are many languages that don't have conditionals: Bitwise Cyclic Tag, any Turing Machine, etcetera.
For the answers that give values beforehand for what is truthy and ...