15
0
Given an integer n
as input, return a list containing n
, repeated n
times. For example, the program would take 5
and turn it into [5,5,5,5,5]
. The elements need to be integers, not strings. No built-in functions that accomplish the task are allowed.
This is code-golf, so standard rules apply.
Why no builtins? – Okx – 2017-08-21T10:36:21.350
@Okx I meant built-in functions which already do this, must have used the wrong word, i'll edit the post. – Bruno E – 2017-08-21T10:37:42.030
I edited the question such that it is a bit more readable and fits our standard format better. – Mr. Xcoder – 2017-08-21T10:38:55.413
1Should
n=0
be supported? – Arnauld – 2017-08-21T10:46:53.82043
@BrunoE That still doesn’t answer the why. Do you have an actual reason to ban built-ins? To quote xnor: In general, if your challenge is too simple to be interesting, it won't be saved by banning things.
– Lynn – 2017-08-21T10:52:21.8632Related. – Adám – 2017-08-21T11:06:05.183
With your current prohibition on built-ins, is this valid?
– Adám – 2017-08-21T11:18:29.2901Does it matter? This is meant to be fun, we can have different opinions on what is and isn't valid. – Bruno E – 2017-08-21T11:51:03.527
13@BrunoE while I agree with the sentiment, we prefer objectivity here at ppcg. Either something is or is not valid, opinions shouldn't come into the equation. – Skidsdev – 2017-08-21T11:57:22.933
5@BrunoE The specs must be made such that one can indisputably decide whether an entry is valid or not. Please share your thoughts on the existing answers and make the specs more objective when it comes to
built-in
. – Mr. Xcoder – 2017-08-21T12:42:49.877in which case, I'll (begrudgingly) say the entry is invalid. – Bruno E – 2017-08-21T12:50:53.027
@Lynn then let the challenge be considered 'uninsteresting'. Nobody is under any obligation to answer, but a fair number of people seem to have found it interesting enough. – Bruno E – 2017-08-21T12:53:55.607
1Along with @Arnauld's comment, can we assume the input is non-negative? – kamoroso94 – 2017-08-21T23:21:35.560
6I'm still confused what counts as a "built-in" for this task. Is Python's
*
operator ok? What's an example of a built-in that isn't ok? – Steve Bennett – 2017-08-22T07:14:59.9938
I am suprised nobody has mentioned this yet, but we have a sandbox for challenges where you can post them to get feedback on them, before they go live. This way you might've prevented discussing the rules of the challenge while others already submitted their answers.
– JAD – 2017-08-23T06:34:03.193Can we leave the output on the stack for stack based languages, or do we have to print it? – MildlyMilquetoast – 2017-09-08T21:31:21.013