Create a google sheet with your data.
Open the sheet
then go to Extensions > Apps Script
This will open your app script project, give it a name, and you need to edit the script, as per your logic
Here is my sample sheet structure
This is the script (Generated via ChatGPT, didn't test the...