3
\$\begingroup\$

Similar to What's a string?

If a challenge says that the input will be “a number”, what data types are acceptable?

Obviously, types like int and float are numeric.

What about strings? Command-line arguments and stuff read from standard input will naturally be string or sequence-of-char objects, so we'll have to accept string input in those cases. But do we accept strings as function arguments, if the language has dedicated data types for representing numbers?

What about lists of digits, like representing 12345 as [1, 2, 3, 4, 5] (list of digits as numbers) or ['1', '2', '3', '4', '5'] (list of digits as char/string)?

Edit: No, I don't think this is a duplicate of Default for Code Golf: Input/Output methods. That question's answers focus on where the input can come from: From command-line arguments, from a file, from a GUI input box, etc. Whereas my question is about what type of input should be acceptable.

| |
\$\endgroup\$

Browse other questions tagged .