Okay, this may sound a bit mean, but...
This is the kind of problem that's simple enough, yet also so specific to your program, that we really shouldn't write the code for you. That's partly because only you know exactly what you want it to do (and if you can write down exactly what you want here in English, you might as well do it in C++ instead), but also because you need to learn to solve the simple things yourself if you're ever going to be able to finish a program.
Now, if you can describe a precise algorithm (say, in pseudocode) that solves your problem, and you just don't know how to implement a specific piece of it using SFML, then try searching the tutorials and documentation first, and if you can't find it, THEN you can ask us what to do, and we can probably help.