Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- valid = arr => {
- const [x1, y1, x2, y2] = arr;
- const result= []
- const a = Math.sqrt(x1 ** 2 + y1 ** 2);
- const b = Math.sqrt(x2 ** 2 + y2 ** 2);
- const c = Math.sqrt((y1 - y2) ** 2 + (x1 - x2) ** 2);
- const isValid = (a, x, y) =>
- a === Math.floor(a)
- ? result.push(`{${x}, ${y}} to {0, 0} is valid`)
- : result.push(`{${x}, ${y}} to {0, 0} is invalid`);
- isValid(a, x1, y1);
- isValid(b, x2, y2);
- c === Math.floor(c)
- ? result.push(`{${x1}, ${y1}} to {${x2}, ${y2}} is valid`)
- : result.push(`{${x1}, ${y1}} to {${x2}, ${y2}} is invalid`);
- return result.join('\n')
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement