Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. function solve(arr) {
  2. let x1 = arr[0],
  3. y1 = arr[1],
  4. x2 = arr[2],
  5. y2 = arr[3];
  6.  
  7. calc(x1, y1, 0, 0);
  8. calc(x2, y2, 0, 0);
  9. calc(x1, y1, x2, y2);
  10.  
  11.  
  12. function calc(x1, y1, x2, y2) {
  13. let result = Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2));
  14.  
  15. if (Number.isInteger(result)) {
  16. console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is valid`);
  17. }
  18. else {
  19. console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is invalid`);
  20. }
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement