Find a convex combination of scalars given a point within them. I've been banging my head on this one all day! I'm going to do my best to explain the problem, but bear with me.
Given a set of numbers $S = \{X_1, X_2, \dots, X_n\}$ and a scalar $T$, where it is guaranteed that there is at least one member of $S$ that is less than $T$ and at least one member that's greater than $T$,
I'm looking for an algorithm to create a Convex Combination of these scalars that equals $T$. 
For example, for the set $\{2,4\}$ and the scalar $3$, the answer is:
$$.5 \cdot 2 + .5 \cdot 4 = 3.$$
I believe in many cases there are infinite infinitely many solutions.
I'm looking for a generalized algorithm/formula to find these coefficients.
Additionally, I would like for the coefficient weights to be distributed as evenly as possible (of course while still adding up to 1.)
For instance, for the set $\{1,2,4\}$ and the scalar $3$, a technically valid solution would be the same as the first example but with the coefficient for $1$ assigned a weight of 0 - but it would be prefferable to assign a non-zero weight.
I may not be thinking through this last part very clearly :)

If $X_1<T<X_2$, then $T$ is a weighted average of $X_1$ and $X_2$ with weights $\dfrac{X_2-T}{X_2-X_1}$ and $\dfrac{T-X_1}{X_2-X_1}$, as can be checked by a bit of algebra.
Now suppose $X_3$ is also $>T$.  Then $T$ is a weighted average of $X_1$ and $X_3$, and you can find the weights the same way.
Now take $40\%$ of the weight assigned to $X_2$ in the first case, and assign it to $X_2$, and $60\%$ of the weight assigned to $X_3$ in the second case and assign it to $X_3$ and let the weight assigned to $X_1$ be $40\%$ of the weight it got in the first case plus $60\%$ of the weight it got in the first case, and you've got another solution.  And as with $40$ and $60$, so also with $41$ and $59$, and so on, and you've got infinitely many solutions.
But don't say "infinite solutions" if you mean "infinitely many solutions".  "Infinite solutions" means "solutions, each one of which, by itself, is infinite".
Later note in response to comments:
Say you write $4$ as an average of $3$ and $5$ with weights $1/2$, $1/2$.
And you write $4$ as an average of $3$ and $7$ with weights $3/4$, $1/4$.
Then you have $4$ as a weighted average of $3$, $5$, and $7$ with weights $1/2,\ 1/2,\ 0$.
And you have $4$ as a weighted average of $3$, $5$, and $7$ with weights $3/4,\ 0,\ 1/4$.
So find a weighted average of $(1/2,\ 1/2,\ 0)$ and $(3/4,\ 0,\ 1/4)$.  For example, $40\%$ of the first plus $60\%$ of the second is $(0.65,\ 0.2,\ 0.15)$.
Then you have $4$ as a weighted average of $3$, $5$, and $7$ with weights $0.65$, $0.2$, and $0.15$.
And you can come up with infinitely many other ways to write $4$ as a weighted average of $3$, $5$, and $7$ by using other weights than $0.4$ and $0.6$.
