This is one of H. E. Dudeney’s train puzzles.
“Two railway trains, one four hundred feet long and the other two hundred feet long, ran on parallel rails. It was found that when they went in opposite directions they passed each other in five seconds, but when they ran in the same direction the faster train would pass the other in fifteen seconds. A curious passenger worked out from these facts the rate per hour at which each train ran. Can the reader discover the correct answer? Of course, each train ran with a uniform velocity.”