Velocity using spring contraction [closed]

I'm trying to determine the maximum final velocity of a body with which it contracts a spring until it touches the wall. It happens only with the presence of maximum energy. So, I've taken the kinetic energy and used the first derivative to obtain the maximum velocity. Is this the right way to solve this problem? It only gives the minimum velocity which is zero..!

-
Of the original kinetic energy of the body, some goes into potential energy in the spring and the remainder is left as kinetic energy of the now slowed object ... –  John Rennie Sep 25 '12 at 17:40
potential energy means it goes to friction? I'm taking friction as zero. That means it doesn't stop. –  BadSniper Sep 25 '12 at 17:44
Potential energy is the energy stored in the spring, not friction. –  John Rennie Sep 25 '12 at 18:17
The potential energy in the spring is $0.5kx^2$, where $k$ is the spring constant and $x$ is the length of the spring. Subtract this off the original kinetic energy, and what you have left is the kinetic energy of the body after it has compressed the spring. I don't see where a derivative is involved. –  John Rennie Sep 26 '12 at 6:23
Can you please describe your problem with equations and / or diagram? I am having trouble understanding what it is that you're not undestanding! –  WetSavannaAnimal aka Rod Vance Mar 2 at 1:09

closed as off-topic by Brandon Enright, jinawee, Dilaton, V. Moretti, Kyle KanosMar 2 at 1:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework-like questions should ask about a specific physics concept and show some effort to work through the problem. We want our questions to be useful to the broader community, and to future users. See our meta site for more guidance on how to edit your question to make it better" – Brandon Enright, jinawee, Dilaton, V. Moretti, Kyle Kanos
If this question can be reworded to fit the rules in the help center, please edit the question.