An uneasy problem with Arithmetic Sequences?

Revision en5, by duckladydinh, 2018-04-28 14:28:41

Hi everyone,

today, I am stuck with a problem. I hope you can help me with it. I think this is a very interesting problem and I am not even sure there exists a deterministic solution to it. The problem is as follows:

" Given n (n <= 1000, but O(n^3) is also fine) distinct integers, group them into sets of at least 4 elements, and each set is an Arithmetic Sequences. " Example:

Input: 1250, 3748, 6246, 8744, 2493, 4993, 7493, 9993, 2497, 4996, 7495, 9994, 2498, 4997, 7496, 9995, 2499, 4998, 7497, 9996

Output: (1250, 3748, 6246, 8744), (2493, 4993, 7493, 9993), (2497, 4996, 7495, 9994), (2498, 4997, 7496, 9995), (2499, 4998, 7497, 9996)

In this test, if you find the longest sequence first, then the rest will not form any valid sequence anymore.

(Assumption: For the given input, there always exists at least one solution that satisfies the constraints and no number is left)

I have spent hours working on this problem but unfortunately I cannot think of any ideas that will work well in general. What do you think?

Thank you.

#### History

Revisions

Rev. Lang. By When Δ Comment
en7 duckladydinh 2018-05-02 00:59:22 355
en6 duckladydinh 2018-04-28 14:29:56 2 Tiny change: 'ces. \n"\nExample:' -> 'ces. \n"\n\nExample:'
en5 duckladydinh 2018-04-28 14:28:41 113
en4 duckladydinh 2018-04-28 14:25:50 291
en3 duckladydinh 2018-04-28 14:05:25 2 Tiny change: 'ces. \n"\n(Assumpt' -> 'ces. \n"\n\n(Assumpt'
en2 duckladydinh 2018-04-28 14:05:06 131
en1 duckladydinh 2018-04-28 01:15:33 580 Initial revision (published)