Welcome to the forums! Before we can help, let us know what you have tried so far, are you able to write it in plain english, not code, to see if you understand what the problem expects?
From there we can go step by step figuring it out in actual code, once we get the pseudo code down, doing so will help a lot versus just jumping into the code itself.