123 votes

Interpretation of Truthy/Falsey

Consider the following pseudocode: if (x) { print "x is truthy"; } else { print "x is falsy"; } If it results in a runtime or a compile-time error then <...
user avatar
  • 42.8k
42 votes

Interpretation of Truthy/Falsey

Truthy/Falsey should be taken as strictly defined in the given language. For example, in javascript, the following are always falsey: undefined null NaN 0 "" false And other values are always ...
user avatar
39 votes

Interpretation of Truthy/Falsey

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, ...
user avatar
24 votes

What's a string?

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 ...
user avatar
19 votes

Standard definitions of terms within specifications

"uniformly random" There are two distinct things to define for "uniform" (in the context of uniformly distributed random variables). If "uniform" is not specified, then &...
user avatar
  • 10.7k
19 votes

Interpretation of Truthy/Falsey

Don't forget program exit codes! If my C or C++ or perl or bash or ... program calls exit(0) this action could be considered truthy, and calling ...
user avatar
16 votes

Standard definitions of terms within specifications

"Black-Box-Functions" 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 ...
user avatar
  • 43.1k
14 votes

Interpretation of Truthy/Falsey

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, ...
user avatar
  • 9,960
12 votes

Standard definitions of terms within specifications

"Positive", "Negative", "Non-Negative", "Non-Positive" Positive, by default, means strictly positive, ie. all N larger than zero. Zero is not a positive number. ...
user avatar
  • 44.7k
11 votes
Accepted

How can we clearly define "Must work for theoretically large values"?

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 ...
user avatar
  • 99.4k
9 votes
Accepted

What counts as distinct and consistent?

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 <...
user avatar
  • 57.1k
7 votes

Standard definitions of terms within specifications

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 ...
user avatar
  • 1,005
6 votes

How can we clearly define "Must work for theoretically large values"?

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 ...
user avatar
  • 87.7k
5 votes

What are string literals?

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 ...
user avatar
3 votes

What's a string?

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, ...
user avatar
2 votes

Interpretation of Truthy/Falsey

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 ...
user avatar
  • 2,622
2 votes

Interpretation of Truthy/Falsey

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 ...
user avatar
  • 5,575
2 votes

What's a string?

If a language makes a distinction between char[] and String, I think a good question to ask is "Does a char[] print like a ...
user avatar
  • 28.5k
1 vote

What's a string?

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 ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible