Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arrInput){
- let x1=arrInput[0];
- let y1=arrInput[1];
- let x2=arrInput[2];
- let y2=arrInput[3];
- let firstToCsDistance =Math.sqrt(Math.pow(0-x1,2)+Math.pow(0-y1,2));
- let secondToCsDistance =Math.sqrt(Math.pow(0-x2,2)+Math.pow(0-y2,2));
- let firstToSecond = Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
- if(Number.isInteger(firstToCsDistance)){
- console.log(`{${x1}, ${y1}} to {0, 0} is valid`);
- } else {
- console.log(`{${x1}, ${y1}} to {0, 0} is invalid`);
- }
- if(Number.isInteger(secondToCsDistance)){
- console.log(`{${x2}, ${y2}} to {0, 0} is valid`);
- } else {
- console.log(`{${x2}, ${y2}} to {0, 0} is invalid`);
- }
- if(Number.isInteger(firstToSecond)){
- console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is valid`);
- } else {
- console.log(`{${x1}, ${y1}} to {${x2}, ${y2}} is invalid`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement