Not sure if this helps but here is a solution I found on SO:
and here are solutions if the lengths are the same: