Much of the code involves mirroring and sorting the guide curves you provided.
In a way, it reminds me of this thread, where the challenge was creating the guide curves: