Checking if 3 numbers are an arithmetic progression

Update: The question has now been unlocked. It remains closed. The Unlock is a 'probationary' act, if the situation remains in control, that's fine. If there are further problems with the question, then a permanent "historical" local may be applied.

The above question had a description, and internal test cases which were suggestive of a problem that is not what the question was actually trying to solve.

The description implied that:

  • values had to be increasing (or, optionally, equal).

The reality, is that the requirements are that:

  • values have to have an arithmetic progression (equal differences), (or optionally equal)

The clarification was never really clear, was posted in comments in various places, not in the question, and came after some answers were given, and before other answers were given.

The post is also very popular, and there are a lot of answers.

As far as I can tell, it's a mess, and there's no way to make everyone happy at this point.

What should be done with this question?

  • \$\begingroup\$ Shouldn't the question be deleted? If we edit it answers might be invalidated, but the question itself is very unclear (most answers don't answer OP's problem). \$\endgroup\$
    – IEatBagels
    Commented May 12, 2015 at 1:04
  • 4
    \$\begingroup\$ @TopinFrassi - note that deleting the question will for example strip > 600 reputation from various people.... and that is not something I want to be responsible for... otherwise I will have to live in meta, apologizing all day... ;-) \$\endgroup\$
    – rolfl
    Commented May 12, 2015 at 1:21
  • \$\begingroup\$ Oh, indeed... I think like @nhgirf then! :) \$\endgroup\$
    – IEatBagels
    Commented May 12, 2015 at 1:26

4 Answers 4


The question should absolutely be closed. With or without the edits made to the question, it's completely unclear what the code should be doing.

The code in the question included this line:

InOrderEqual(2, 5 , 11, false);  //true 

With the //true comment indicating that the method should return true given these arguments, yet an examination of the code in the question indicates that if we simply compiled the code from the question, this would actually return false.

The plain English part at first didn't specify that the numbers should be equidistance from each other, then that was edited in, then it was edited out.

Without that plain English part, the code is unclear. With the plain English part, the code is unclear and broken.

I don't think there's a way to look at this question and say it's on-topic.

That there are answers to the question is kind of irrelevant. Answers can't make a question off-topic, and they can't make a question on-topic. A question should be judged on its own merits.

With that said, essentially any edit is going to invalidate some of the answers (some of the answers point out the bugs).

I'd recommend that the answer remain locked so it cannot be edited, and closed so that no new answers can be added to this clearly off-topic question. Perhaps consider locking in a way that prevents deletion of the question, but even if the question gets deleted, users who posted answers and have at least +3 score will at least keep any rep gained.

  • \$\begingroup\$ I'm with this. I don't see a benefit in deleting the question out right, but closing it as unclear is definitely called for and the lock should remain in place so that it cannot be re-opened. Answerers should not be punished for an unclear question. They acted in good faith. OP should be (and is!) encouraged to post a clarified version of the question. \$\endgroup\$
    – RubberDuck
    Commented May 12, 2015 at 11:36

After playing with the various options, I am settling on the following as being the approach I would prefer to take:

  1. unlock the question
  2. close it as "unclear what you are asking"
  3. leave the "Mod Note" on the question so people know there is a discussion about the question.
  4. "protect" the question so that people have another reason to stop and think, before editing or voting-to-reopen.

I am inclined to roll back the @snowbody edit (again). That edit certainly cleared up and centralized a lot of the comments in other places, and normally, I would encourage that, but, in this specific case, the clarification makes most of the answers look... odd.

Let me reiterate that, @snowbody "fixed" the question appropriately, unfortunately it was too late, and the damage was mostly already done. While the first time I rolled back the edit, I thought it was "wrong", I am now convinced it's right.

What I am hoping for here, is to leave the question in a state where no new answers can be made, and I can make people aware that there's been an issue with the question, and that this sort of thing is not normal.

There is no way to edit this question to repair it without invalidating answers, so fixing it is not an option. Any edits of significance would be messy.

My alternatives, at this point, are as follows:

  1. Do what I suggest above - close, mark, and trust that people see it for what it is.
  2. Delete the question (and all the answers) resulting in a net loss of > 600 reputation and a lot of unhappy people who were somewhat innocently duped in to providing answers to a poorly defined question.
  3. Maintain the moderator-lock on the question, which will prevent any changes by anyone, including voting, commenting, etc.
  4. "surgically" go in and repair all the answers, etc. in some way... right? that can be done ;-)
  5. get the OP to post a second question with the alternative meaning, and get people to post their respective answers to the alternative that's related to their answer. Delete those answers from the mismatching version.

The only practical solution is the first, as far as I can tell. It is not ideal, but it is pragmatic. Perhaps I am missing something though. Thoughts?

Follow-on points to stew over:

  1. how did this happen?
  2. is it as messy as it appears?
  3. can this be prevented, or at least identified sooner, in the future?
  • 3
    \$\begingroup\$ closing as unclear what you are asking is definitely the best solution \$\endgroup\$ Commented May 12, 2015 at 10:18
  • 1
    \$\begingroup\$ can this be prevented, or at least identified sooner, in the future? should be a follow-up question for sure. \$\endgroup\$
    – Malachi Mod
    Commented May 13, 2015 at 16:36
  • \$\begingroup\$ <sarcasm> I would actually vote for alternative 4, that one sounds like the most fun </sarcasm> \$\endgroup\$
    – Malachi Mod
    Commented May 13, 2015 at 16:37
  • \$\begingroup\$ Yeah I wondered why you reverted my edit, but thought I had no standing to question someone with 65k rep. \$\endgroup\$
    – Snowbody
    Commented May 22, 2015 at 22:06

This is not really a solution to the problem, but one aspect of it.

The answers were too quick

When you answer a question and suggest a better alternative, it is important that you make sure that your code will return the same result as the original code. Fixing bugs the OP was unaware of is acceptable in an answer, of course. However, this line makes it very clear to me that many of the answers are just outright wrong and changing the behavior of the code in a way that was not intended:

else if (( a + a) - b == (b + b) - c|| b - a == c - b && c > b && b > a)

Something that some of those answers could/should do is to provide two alternatives, one alternative for the case when 1 4 5 should return true and one for when it should return false, so that you make a kind of safeguard/precaution. This way, the OP's intentions don't matter that much, as you cover both cases.

  • \$\begingroup\$ Answerers should not necessarily be punished for not immediately recognizing that the OP's question is broken. Consider far larger blocks of code to which an OP is only reviewing part of the code. \$\endgroup\$
    – nhgrif
    Commented May 12, 2015 at 1:08
  • \$\begingroup\$ @nhgrif Even when you scan larger blocks of code, a line like this should make you stop and think for a while. This is not about larger blocks of code though, in this question the code is simple enough that reviewers should definitely have noticed this line better. \$\endgroup\$ Commented May 12, 2015 at 1:10

As one of the answerers of this question I have the feeling that I have to throw my 2 ct in here too.

I would usually say the same as @Simon André Forsberg but in this special case the OP provided some kind of "test cases" which didn't produce always the right results, like I pointed out in my answer.

Also in the comments to my answer @Kyle mentioned to the OP

Those are strictly increasing. I think you mean they're not an arithmetic sequence, which is something different. You should probably edit your question to make that clear.

but the op refused to clarify what exactly he want to achieve, especially because the OP presented a test case which didn't follow his intention like @TopinFrassi pointed out

2,5,11 should be false

So the said line of code Simon mentioned should make one think, but because I have seen my share of creative coding and the solution I wanted to provide did pass all the test cases of the OP, I posted my altrernative solution to the unclear problem.

What I really can't understand here is that after the OP stated in the comments to my answer

if ( a < b && b < c) does return true even if they are not in strict increasing order. like ( 10, 30, 100 ) would still return true which is not allowed.

he marked it as answer.

That beeing said I personally would go with @rolfl's second alternative

Delete the question (and all the answers) resulting in a net loss of > 600 reputation and a lot of unhappy people who were somewhat innocently duped in to providing answers to a poorly defined question

  • 1
    \$\begingroup\$ 2,5,11 does return true in the code, because of the ( a + a) - b == (b + b) - c condition in the if statement. The question is why that part is there, which makes this question totally unclear. \$\endgroup\$ Commented May 12, 2015 at 10:18

You must log in to answer this question.

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