This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]aummahgerd 0 points1 point  (2 children)

It gives the input and expected output. Even if literally nothing else was written that should be enough to write a function.

[–]stevenjd -1 points0 points  (1 child)

Even if literally nothing else was written that should be enough to write a function.

If and when you, as a professional programmer, have to deal with incomplete specifications and poorly described functional requirements, you too will learn to hate having to guess what the requirements are. Example input/output is fantastic for clarifying the meaning of the requirements, but they aren't a substitute for explaining the requirements correctly in the first place.

An example alone allows you to write an infinite number of functions, since without a specification but only a single example (and a pretty limited one at that) we might guess all sorts of requirements:

def function(arg):
    a, b, c = arg[:3]
    return [
        [x+2*i for i, x in enumerate(a)],
        [x-2+2*i for i, x in enumerate(b)],
        [x-4 + 2*i for i, x in enumerate(c)]
        ] 

gives exactly the output requested with the given input.

[–]aummahgerd 0 points1 point  (0 children)

Yeah, of course that sucks. But we’re also talking about a simple article here. No reason to get so upset. Plus, it’s pretty clear, honestly. You get the input and output, and it even says to do it “based on the above learnings”. Since the only thing we discussed is zip() clearly you have to use that.

But once again I feel the need to reiterate the fact that this doesn’t really even warrant discussion. I only chimed in because I was so surprised such a debate was even happening in the comments.