# Alternate solution - what counts as an insightful observation?

One of our latest HNQ's has drawn the attention of alternate solutions.

Soon after the question was posted I answered it with an alternate solution, and got quite a few upvotes. My first version looked like this, it has 0 downvotes:

The best solution is to use str.join(), using ', ' as the joining string.

print(', '.join(flavours) + '.')

Another answer is the following. It has 2 downvotes but no comments saying to review the code:

Using f-strings, which are pretty fast:

flavors = ['chocolate', 'vanilla', 'caramel', 'strawberry', 'coffee']

print(f'{", ".join(flavors)}.')

Another answer is the following, with 1 downvote:

Another option: print(str(flavours).replace("'","")[1:-1]+".")

It has the following comment at 4 votes:

It's starting to look like SO here. Could you also review the OP's code and explain your method?

Another answer is, it had a few downvotes before the comment saying it's broken arrived.

flavours = ['chocolate','vanilla','caramel','strawberry','coffee']
print(flavours.replace('[','').replace(']','').replace('\'',''))

Botched, but gives you chocolate,vanilla,caramel,strawberry,coffee

To me all the answers look the same - "here's an alternate solution".

In retrospect maybe my answer is low-quality and is worthy of the following comment:

It's starting to look like SO here. Could you also review the OP's code and explain your method?

# When providing an alternate solution, what do you have to say for your answer to pass the "one insightful observation"?

Does my answer 'pass' this? Or is it low quality and I deserve some downvotes for violating site rules?

The problem starts with the question, which is barely on topic and would be a better fit on Stack Overflow.

That said, a comparison between your original answer and Reinderien's seems to illustrate the difference between an alternative solution and an alternative solution with an insightful observation: you said

The best solution is ...

whereas he said

The most expensive part of your solution is the call to index. That needs to be avoided because it does a search for the current item on each iteration.

I.e. he explained in what aspect it was better (it's faster) and why it was better in that aspect (it removes a linear search from the loop).

I think the minimum expectation of an insightful observation with an alternative answer should be to say what parameter(s) it improves - speed, memory consumption, readability / maintainability, reusability, bugs fixed, etc. For speed and memory consumption, ideally it would also say whether the improvement is asymptotic (e.g. $$\O(n^2)\$$ to $$\O(n)\$$ in this case) or just an improved constant factor.

If it had been me I would have argued that the solution with join was better on three counts rather than one (speed, readability, and flexibility because you can do more with a string than with characters you've already printed), but that's by the by.

• Given that my answer still suffers from these problems, and I've seen two of the other answers deleted - presumably for this reason - I don't see why I'm not being penalized. Whilst I will be editing my answer to include some comments to make it so it's on the correct side of the fence, I don't see why my answer seems to be exempt from our guide lines - no downvotes, comments or delete votes.
– Peilonrayz Mod
Aug 30 '19 at 14:55
• Just guessing: maybe the others got flagged in the "First posts" queue? Aug 30 '19 at 21:49
• I really don't think so, just the meta effect.
– Peilonrayz Mod
Aug 31 '19 at 12:27
• @Peilonrayz My gut feeling tells me it has something to do with the number of points next to your name. I'm not saying it's fair, but it might just be the explanation.
– Mast Mod
Sep 23 '19 at 6:31