C

Alice lives on a lattice. The lattice consists of points that have integer coordinates.

One day Alice decided she wants to go for a walk. She starts at lattice point A and goes straight to lattice point B. After reaching B, she turns 90 degrees to the right and moves straight in that direction. What is the first lattice point that Alice will reach after the turn?

The points A and B have coordinates (AX, AY) and (BX, BY) respectively. You can assume that A and B are distinct.

Write a function:

function solution(AX, AY, BX, BY);

that, given four integers AX, AY, BX and BY, finds the coordinates of the first lattice point that Alice will reach after turning right. It must return a string with two coordinates separated with a comma, without any spaces.

For example, given:

AX = -1 AY = 3 BX = 3 BY = 1

the function should return "2,-1".

Also, given:

AX = 2 AY = 2 BX = 2 BY = -3

the function should return "1,-3".

Assume that:

  • AX, AY, BX and BY are integers within the range [−50..50];
  • points A and B are distinct.

In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.