Fit specific line segments on one curve?

Hi there, i need some ideas how to solve this problem:
lets say i have 2 line segments, A is 4 long, B is 5 long.
then there is a line C wich is 11 long. What i want is grasshopper to add A and B together to get as close as possible to length of C. its totally ok if all segments of A and B together are a bit longer or shorter then C as long as they keep their original individual length.

I hope its kind of understandable…

Any Idea how i would do somehting like that? i guess i would need some kind of recursive algorithm?

Cheers and Thanks for Ideas!!