I am trying to find the initial velocity to slingshot a planet around the sun and through a gap. 

![enter image description here](https://i.stack.imgur.com/rzFPf.png)

The green ball is the planet, and the yellow ball is the sun. In this trial I need to get the planet to go around the sun and through the gap at 278Gm. I have tried different approaches, but nothing seems to be even remotely correct. Anything under 20k m/s will land you in the sun and anything over 50k will slingshot you out of the system. 

I want to know what formula to use so that I can solve this type of problem.