Can I improve upon code from another answer in a game of code golf, do I have to ask, or is it not allowed?


1 Answer 1


I think this really depends on the situation.

If you're just saving a few more bytes without any significant changes to the approach, consider being nice and leave a comment such that the original author can improve the code themselves.

If you can actually save something by changing part of the algorithm substantially, I think it's usually alright to post it as a new answer. However, if you reuse any parts of another answer (and if it's just the input parsing), it's common courtesy to credit the other answer as the source for it. Reusing parts of others' answers has been done in the past, and if it's done with attribution I think it's fine. Of course, you can still consider "donating" your idea to the original author (who will sometimes tell you to post it separately anyway if it's sufficiently different).

It also makes a bit of a difference if you're beating the leading answer by shortening it a bit further, or if neither your nor the original is anywhere near the top spot. In the latter case, it's much less of a big deal.

In short: yes, in general you may reuse or improve on others' answers, but first consider being a good sportsman, use common sense, and always give credit where credit is due.

  • \$\begingroup\$ Thanks! This clears up a lot of things. \$\endgroup\$ Apr 2, 2015 at 21:17
  • 11
    \$\begingroup\$ Despite the bad reputation PPCG appears to have garnered itself with over the past couple of days, I have found that in general almost all participants here are very sportsmanlike and don't let a bad argument ruin a good game. Competition can be healthy and even intense here, but I don't remember ever seeing a bad loser here. Attribution helps a lot, I think \$\endgroup\$ Apr 2, 2015 at 22:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .