See the attached image for clarification.
Now let's first explain the basics. It does not matter that the speed is knots, as long as both speeds are using the same measurement. Both are in knots so it is fine. The leave the same port at the same time, so both their courses can be plotted from a single point.
Ship 1: 18 nautical miles per hour times 1.5 hours = 27 nautical miles
Ship 2: 26 nautical miles per hour times 1.5 hours = 39 nautical miles.
The angle between the ships -> 130 - 40 = 90 degrees
This makes it considerably easy since we can simply use Pythagoras on this.
So the light-blue line (Ship 1) has a "length" of 27 and the green line (Ship 2) has a "length" of 39.
Dist^2 = Ship1^2 + Ship2^2
Dist^2 = 27^2 + 39^2 = 2250
Thus Dist = 47.4342 nautical miles.