The problem #6 of IMO 2009 reads:
Let a 1, a 2, a 3, ..., a n, be distinct positive integers and let T be a set of n-1positive integers not containing a 1+a 2+a 3+...+a n, A grasshopper is to jump along the real axis, starting at the point 0 and making n jumps to the right with lengths a 1, a 2, a 3, ..., a n in some order. Prove that the order can be chosen in such a way that the grasshopper never lands on any point in T.
Your task is to replicate it.
Two sets S, T positive integers, with:
S having n distinct elements
T having n-1 elements not containing the sum of the numbers in S
A montonically increasing sequence of positive integers J = b1, b 2, b 3, ..., b n, such that:
The numbers b1, b 2-b 1, , b 3-b 2, ..., b n-b n-1 are permutation of the elements of S
J and T are disjoint
- Your code should use O(P(t)) search time, where P(t) is a polynomial with degree <4
- This is a code golf, so shortest maintaining the rule wins.
Good luck golfing ! Thanks to @MartinEnder for the suggestion !