Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2016
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let x1 = Number(input[0]);
  3.     let y1 = Number(input[1]);
  4.     let x2 = Number(input[2]);
  5.     let y2 = Number(input[3]);
  6.     let x3 = Number(input[4]);
  7.     let y3 = Number(input[5]);
  8.  
  9.     let distance12 = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  10.     let distance23 = Math.sqrt(Math.pow((x3 - x2), 2) + Math.pow((y3 - y2), 2));
  11.     let distance13 = Math.sqrt(Math.pow((x3 - x1), 2) + Math.pow((y3 - y1), 2));
  12.  
  13.  
  14.     if ((distance12 <= distance13) && (distance13 => distance23)) {
  15.        let a = distance12 + distance23;
  16.         console.log('1->2->3: ' + a);
  17.     }
  18.     else if ((distance12 <= distance23) && (distance13 < distance23)) {
  19.         let b = distance13 + distance12;
  20.         console.log('2->1->3: '+ b);
  21.     }
  22.     else {
  23.         let c = distance23 + distance13;
  24.         console.log('1->3->2: ' + c);
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement