Step 1) turn off your computer
Step 2) get paper and pencil
Step 3) write down in English (or any other natural language of your choice) the steps you would give a 10 year old child if they had to do this by hand.
Step 4) revise that list at least 5 times, further simplifying and clarifying the steps each time.
ONLY when you have completed the above should you consider writing a single line of code.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors