Solution of a three-body problem in one-dimension