A diamond is a quadrilateral whose four sides all have the same length and whose diagonals are parallel to the coordinate axes.
You are given N distinct points on a plane. Count the number of different diamonds that can be constructed using these points as vertices (two diamonds are different if their sets of vertices are different). Do not count diamonds whose area is empty.
Write a function:
function solution(X, Y);
that, given two arrays X and Y, each containing N integers, representing N points (where X[K], Y[K] are the coordinates of the K-th point), returns the number of diamonds on the plane.
For example, for N = 7 points whose coordinates are specified in arrays X = [1, 1, 2, 2, 2, 3, 3] and Y = [3, 4, 1, 3, 5, 3, 4], the function should return 2, since we can find two diamonds as shown in the picture below:
Given arrays: X = [1, 2, 3, 3, 2, 1], Y = [1, 1, 1, 2, 2, 2], the function should return 0, since there are no diamonds on the plane:
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [4..1,500];
- each element of arrays X and Y is an integer within the range [0..N-1];
- given N points are pairwise distinct.
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]])
}
}
function combinations(array, r) {
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]])
}
}
function combinations(array, r) {
if r >
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]])
}
}
function combinations(A, r) {
if (r > A.length) {
return;
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
}
function combinations(A, r) {
if (r > A.length) {
return;
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
for
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
for i
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
for (let i = 0; i < A.length; i++) {
for (let j = i; )
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; )
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
}
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push()
}
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push([])
}
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A, r) {
if (r > A.length) {
return;
}
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinations(points, 2);
}
function combinations(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinationsOfTwo(points);
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinationsOfTwo(points);
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ [ 1, 3 ], [ 1, 3 ] ] [ [ 1, 3 ], [ 1, 4 ] ] [ [ 1, 3 ], [ 2, 1 ] ] [ [ 1, 3 ], [ 2, 3 ] ] [ [ 1, 3 ], [ 2, 5 ] ] [ [ 1, 3 ], [ 3, 3 ] ] [ [ 1, 3 ], [ 3, 4 ] ] [ [ 1, 4 ], [ 1, 4 ] ] [ [ 1, 4 ], [ 2, 1 ] ] [ [ 1, 4 ], [ 2, 3 ] ] [ [ 1, 4 ], [ 2, 5 ] ] [ [ 1, 4 ], [ 3, 3 ] ] [ [ 1, 4 ], [ 3, 4 ] ] [ [ 2, 1 ], [ 2, 1 ] ] [ [ 2, 1 ], [ 2, 3 ] ] [ [ 2, 1 ], [ 2, 5 ] ] [ [ 2, 1 ], [ 3, 3 ] ] [ [ 2, 1 ], [ 3, 4 ] ] [ [ 2, 3 ], [ 2, 3 ] ] [ [ 2, 3 ], [ 2, 5 ] ] [ [ 2, 3 ], [ 3, 3 ] ] [ [ 2, 3 ], [ 3, 4 ] ] [ [ 2, 5 ], [ 2, 5 ] ] [ [ 2, 5 ], [ 3, 3 ] ] [ [ 2, 5 ], [ 3, 4 ] ] [ [ 3, 3 ], [ 3, 3 ] ] [ [ 3, 3 ], [ 3, 4 ] ]
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ [ 1, 1 ], [ 1, 1 ] ] [ [ 1, 1 ], [ 2, 1 ] ] [ [ 1, 1 ], [ 3, 1 ] ] [ [ 1, 1 ], [ 3, 2 ] ] [ [ 1, 1 ], [ 2, 2 ] ] [ [ 1, 1 ], [ 1, 2 ] ] [ [ 2, 1 ], [ 2, 1 ] ] [ [ 2, 1 ], [ 3, 1 ] ] [ [ 2, 1 ], [ 3, 2 ] ] [ [ 2, 1 ], [ 2, 2 ] ] [ [ 2, 1 ], [ 1, 2 ] ] [ [ 3, 1 ], [ 3, 1 ] ] [ [ 3, 1 ], [ 3, 2 ] ] [ [ 3, 1 ], [ 2, 2 ] ] [ [ 3, 1 ], [ 1, 2 ] ] [ [ 3, 2 ], [ 3, 2 ] ] [ [ 3, 2 ], [ 2, 2 ] ] [ [ 3, 2 ], [ 1, 2 ] ] [ [ 2, 2 ], [ 2, 2 ] ] [ [ 2, 2 ], [ 1, 2 ] ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push(A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push(A[i],A[j]);
}
}
return comb;
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1, 3 ] [ 1, 3 ] [ 1, 3 ] [ 1, 4 ] [ 1, 3 ] [ 2, 1 ] [ 1, 3 ] [ 2, 3 ] [ 1, 3 ] [ 2, 5 ] [ 1, 3 ] [ 3, 3 ] [ 1, 3 ] [ 3, 4 ] [ 1, 4 ] [ 1, 4 ] [ 1, 4 ] [ 2, 1 ] [ 1, 4 ] [ 2, 3 ] [ 1, 4 ] [ 2, 5 ] [ 1, 4 ] [ 3, 3 ] [ 1, 4 ] [ 3, 4 ] [ 2, 1 ] [ 2, 1 ] [ 2, 1 ] [ 2, 3 ] [ 2, 1 ] [ 2, 5 ] [ 2, 1 ] [ 3, 3 ] [ 2, 1 ] [ 3, 4 ] [ 2, 3 ] [ 2, 3 ] [ 2, 3 ] [ 2, 5 ] [ 2, 3 ] [ 3, 3 ] [ 2, 3 ] [ 3, 4 ] [ 2, 5 ] [ 2, 5 ] [ 2, 5 ] [ 3, 3 ] [ 2, 5 ] [ 3, 4 ] [ 3, 3 ] [ 3, 3 ] [ 3, 3 ] [ 3, 4 ]
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ 1, 1 ] [ 1, 1 ] [ 1, 1 ] [ 2, 1 ] [ 1, 1 ] [ 3, 1 ] [ 1, 1 ] [ 3, 2 ] [ 1, 1 ] [ 2, 2 ] [ 1, 1 ] [ 1, 2 ] [ 2, 1 ] [ 2, 1 ] [ 2, 1 ] [ 3, 1 ] [ 2, 1 ] [ 3, 2 ] [ 2, 1 ] [ 2, 2 ] [ 2, 1 ] [ 1, 2 ] [ 3, 1 ] [ 3, 1 ] [ 3, 1 ] [ 3, 2 ] [ 3, 1 ] [ 2, 2 ] [ 3, 1 ] [ 1, 2 ] [ 3, 2 ] [ 3, 2 ] [ 3, 2 ] [ 2, 2 ] [ 3, 2 ] [ 1, 2 ] [ 2, 2 ] [ 2, 2 ] [ 2, 2 ] [ 1, 2 ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ [ 1, 3 ], [ 1, 3 ] ] [ [ 1, 3 ], [ 1, 4 ] ] [ [ 1, 3 ], [ 2, 1 ] ] [ [ 1, 3 ], [ 2, 3 ] ] [ [ 1, 3 ], [ 2, 5 ] ] [ [ 1, 3 ], [ 3, 3 ] ] [ [ 1, 3 ], [ 3, 4 ] ] [ [ 1, 4 ], [ 1, 4 ] ] [ [ 1, 4 ], [ 2, 1 ] ] [ [ 1, 4 ], [ 2, 3 ] ] [ [ 1, 4 ], [ 2, 5 ] ] [ [ 1, 4 ], [ 3, 3 ] ] [ [ 1, 4 ], [ 3, 4 ] ] [ [ 2, 1 ], [ 2, 1 ] ] [ [ 2, 1 ], [ 2, 3 ] ] [ [ 2, 1 ], [ 2, 5 ] ] [ [ 2, 1 ], [ 3, 3 ] ] [ [ 2, 1 ], [ 3, 4 ] ] [ [ 2, 3 ], [ 2, 3 ] ] [ [ 2, 3 ], [ 2, 5 ] ] [ [ 2, 3 ], [ 3, 3 ] ] [ [ 2, 3 ], [ 3, 4 ] ] [ [ 2, 5 ], [ 2, 5 ] ] [ [ 2, 5 ], [ 3, 3 ] ] [ [ 2, 5 ], [ 3, 4 ] ] [ [ 3, 3 ], [ 3, 3 ] ] [ [ 3, 3 ], [ 3, 4 ] ]
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ [ 1, 1 ], [ 1, 1 ] ] [ [ 1, 1 ], [ 2, 1 ] ] [ [ 1, 1 ], [ 3, 1 ] ] [ [ 1, 1 ], [ 3, 2 ] ] [ [ 1, 1 ], [ 2, 2 ] ] [ [ 1, 1 ], [ 1, 2 ] ] [ [ 2, 1 ], [ 2, 1 ] ] [ [ 2, 1 ], [ 3, 1 ] ] [ [ 2, 1 ], [ 3, 2 ] ] [ [ 2, 1 ], [ 2, 2 ] ] [ [ 2, 1 ], [ 1, 2 ] ] [ [ 3, 1 ], [ 3, 1 ] ] [ [ 3, 1 ], [ 3, 2 ] ] [ [ 3, 1 ], [ 2, 2 ] ] [ [ 3, 1 ], [ 1, 2 ] ] [ [ 3, 2 ], [ 3, 2 ] ] [ [ 3, 2 ], [ 2, 2 ] ] [ [ 3, 2 ], [ 1, 2 ] ] [ [ 2, 2 ], [ 2, 2 ] ] [ [ 2, 2 ], [ 1, 2 ] ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push([X[i], Y[i]]);
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ [ 1, 3 ], [ 1, 4 ] ] [ [ 1, 3 ], [ 2, 1 ] ] [ [ 1, 3 ], [ 2, 3 ] ] [ [ 1, 3 ], [ 2, 5 ] ] [ [ 1, 3 ], [ 3, 3 ] ] [ [ 1, 3 ], [ 3, 4 ] ] [ [ 1, 4 ], [ 2, 1 ] ] [ [ 1, 4 ], [ 2, 3 ] ] [ [ 1, 4 ], [ 2, 5 ] ] [ [ 1, 4 ], [ 3, 3 ] ] [ [ 1, 4 ], [ 3, 4 ] ] [ [ 2, 1 ], [ 2, 3 ] ] [ [ 2, 1 ], [ 2, 5 ] ] [ [ 2, 1 ], [ 3, 3 ] ] [ [ 2, 1 ], [ 3, 4 ] ] [ [ 2, 3 ], [ 2, 5 ] ] [ [ 2, 3 ], [ 3, 3 ] ] [ [ 2, 3 ], [ 3, 4 ] ] [ [ 2, 5 ], [ 3, 3 ] ] [ [ 2, 5 ], [ 3, 4 ] ] [ [ 3, 3 ], [ 3, 4 ] ]
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ [ 1, 1 ], [ 2, 1 ] ] [ [ 1, 1 ], [ 3, 1 ] ] [ [ 1, 1 ], [ 3, 2 ] ] [ [ 1, 1 ], [ 2, 2 ] ] [ [ 1, 1 ], [ 1, 2 ] ] [ [ 2, 1 ], [ 3, 1 ] ] [ [ 2, 1 ], [ 3, 2 ] ] [ [ 2, 1 ], [ 2, 2 ] ] [ [ 2, 1 ], [ 1, 2 ] ] [ [ 3, 1 ], [ 3, 2 ] ] [ [ 3, 1 ], [ 2, 2 ] ] [ [ 3, 1 ], [ 1, 2 ] ] [ [ 3, 2 ], [ 2, 2 ] ] [ [ 3, 2 ], [ 1, 2 ] ] [ [ 2, 2 ], [ 1, 2 ] ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({X[i], Y[i]]);
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({X[i], Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push({A[i],A[j]});
}
}
return comb;
}
solution.js:8 points.push({X[i], Y[i]}); ^ SyntaxError: Unexpected token [ at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:402:29) at Promise.resolve.then (/tmp/exec.js:436:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
solution.js:8 points.push({X[i], Y[i]}); ^ SyntaxError: Unexpected token [ at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:402:29) at Promise.resolve.then (/tmp/exec.js:436:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({1:X[i], Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push({A[i],A[j]});
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push({A[i],A[j]});
}
}
return comb;
}
solution.js:20 comb.push({A[i],A[j]}); ^ SyntaxError: Unexpected token [ at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:402:29) at Promise.resolve.then (/tmp/exec.js:436:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
solution.js:20 comb.push({A[i],A[j]}); ^ SyntaxError: Unexpected token [ at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:402:29) at Promise.resolve.then (/tmp/exec.js:436:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ { x: 1, y: 3 }, { x: 1, y: 4 } ] [ { x: 1, y: 3 }, { x: 2, y: 1 } ] [ { x: 1, y: 3 }, { x: 2, y: 3 } ] [ { x: 1, y: 3 }, { x: 2, y: 5 } ] [ { x: 1, y: 3 }, { x: 3, y: 3 } ] [ { x: 1, y: 3 }, { x: 3, y: 4 } ] [ { x: 1, y: 4 }, { x: 2, y: 1 } ] [ { x: 1, y: 4 }, { x: 2, y: 3 } ] [ { x: 1, y: 4 }, { x: 2, y: 5 } ] [ { x: 1, y: 4 }, { x: 3, y: 3 } ] [ { x: 1, y: 4 }, { x: 3, y: 4 } ] [ { x: 2, y: 1 }, { x: 2, y: 3 } ] [ { x: 2, y: 1 }, { x: 2, y: 5 } ] [ { x: 2, y: 1 }, { x: 3, y: 3 } ] [ { x: 2, y: 1 }, { x: 3, y: 4 } ] [ { x: 2, y: 3 }, { x: 2, y: 5 } ] [ { x: 2, y: 3 }, { x: 3, y: 3 } ] [ { x: 2, y: 3 }, { x: 3, y: 4 } ] [ { x: 2, y: 5 }, { x: 3, y: 3 } ] [ { x: 2, y: 5 }, { x: 3, y: 4 } ] [ { x: 3, y: 3 }, { x: 3, y: 4 } ]
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
[ { x: 1, y: 1 }, { x: 2, y: 1 } ] [ { x: 1, y: 1 }, { x: 3, y: 1 } ] [ { x: 1, y: 1 }, { x: 3, y: 2 } ] [ { x: 1, y: 1 }, { x: 2, y: 2 } ] [ { x: 1, y: 1 }, { x: 1, y: 2 } ] [ { x: 2, y: 1 }, { x: 3, y: 1 } ] [ { x: 2, y: 1 }, { x: 3, y: 2 } ] [ { x: 2, y: 1 }, { x: 2, y: 2 } ] [ { x: 2, y: 1 }, { x: 1, y: 2 } ] [ { x: 3, y: 1 }, { x: 3, y: 2 } ] [ { x: 3, y: 1 }, { x: 2, y: 2 } ] [ { x: 3, y: 1 }, { x: 1, y: 2 } ] [ { x: 3, y: 2 }, { x: 2, y: 2 } ] [ { x: 3, y: 2 }, { x: 1, y: 2 } ] [ { x: 2, y: 2 }, { x: 1, y: 2 } ]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair[0])
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair[0])
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
{ x: 1, y: 3 } { x: 1, y: 3 } { x: 1, y: 3 } { x: 1, y: 3 } { x: 1, y: 3 } { x: 1, y: 3 } { x: 1, y: 4 } { x: 1, y: 4 } { x: 1, y: 4 } { x: 1, y: 4 } { x: 1, y: 4 } { x: 2, y: 1 } { x: 2, y: 1 } { x: 2, y: 1 } { x: 2, y: 1 } { x: 2, y: 3 } { x: 2, y: 3 } { x: 2, y: 3 } { x: 2, y: 5 } { x: 2, y: 5 } { x: 3, y: 3 }
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
{ x: 1, y: 1 } { x: 1, y: 1 } { x: 1, y: 1 } { x: 1, y: 1 } { x: 1, y: 1 } { x: 2, y: 1 } { x: 2, y: 1 } { x: 2, y: 1 } { x: 2, y: 1 } { x: 3, y: 1 } { x: 3, y: 1 } { x: 3, y: 1 } { x: 3, y: 2 } { x: 3, y: 2 } { x: 2, y: 2 }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
console.log(pair[0], pair[1])
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
{ x: 1, y: 3 } { x: 1, y: 4 } { x: 1, y: 3 } { x: 2, y: 1 } { x: 1, y: 3 } { x: 2, y: 3 } { x: 1, y: 3 } { x: 2, y: 5 } { x: 1, y: 3 } { x: 3, y: 3 } { x: 1, y: 3 } { x: 3, y: 4 } { x: 1, y: 4 } { x: 2, y: 1 } { x: 1, y: 4 } { x: 2, y: 3 } { x: 1, y: 4 } { x: 2, y: 5 } { x: 1, y: 4 } { x: 3, y: 3 } { x: 1, y: 4 } { x: 3, y: 4 } { x: 2, y: 1 } { x: 2, y: 3 } { x: 2, y: 1 } { x: 2, y: 5 } { x: 2, y: 1 } { x: 3, y: 3 } { x: 2, y: 1 } { x: 3, y: 4 } { x: 2, y: 3 } { x: 2, y: 5 } { x: 2, y: 3 } { x: 3, y: 3 } { x: 2, y: 3 } { x: 3, y: 4 } { x: 2, y: 5 } { x: 3, y: 3 } { x: 2, y: 5 } { x: 3, y: 4 } { x: 3, y: 3 } { x: 3, y: 4 }
Invalid result type, integer expected, 'undefined' found Perhaps you are missing a 'return'?stdout:
{ x: 1, y: 1 } { x: 2, y: 1 } { x: 1, y: 1 } { x: 3, y: 1 } { x: 1, y: 1 } { x: 3, y: 2 } { x: 1, y: 1 } { x: 2, y: 2 } { x: 1, y: 1 } { x: 1, y: 2 } { x: 2, y: 1 } { x: 3, y: 1 } { x: 2, y: 1 } { x: 3, y: 2 } { x: 2, y: 1 } { x: 2, y: 2 } { x: 2, y: 1 } { x: 1, y: 2 } { x: 3, y: 1 } { x: 3, y: 2 } { x: 3, y: 1 } { x: 2, y: 2 } { x: 3, y: 1 } { x: 1, y: 2 } { x: 3, y: 2 } { x: 2, y: 2 } { x: 3, y: 2 } { x: 1, y: 2 } { x: 2, y: 2 } { x: 1, y: 2 }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if ()
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x)
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
} else if (pair[0].y === pair[1].y) {
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let m
} else if (pair[0].y === pair[1].y) {
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = ()
} else if (pair[0].y === pair[1].y) {
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
} else if (pair[0].y === pair[1].y) {
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
} else if (pair[0].y === pair[1].y) {
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === i)
} else if (pair[0].y === pair[1].y) {
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let byMeanX = []
let byMeanY = []
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
le
let byMeanX = []
let byMeanY = []
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = []
let byMeanY = []
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, )
let byMeanY = []
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => {})
let byMeanY = []
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => {0)
let byMeanY = []
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = []
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => 0);
let byMeanY = Array.from({ length: max + 1}, () => 0);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2
let iMeanX = parseInt(meanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => 0);
let byMeanY = Array.from({ length: max + 1}, () => 0);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2
let iMeanY = parseInt(meanY)
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => 0);
let byMeanY = Array.from({ length: max + 1}, () => 0);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => 0);
let byMeanY = Array.from({ length: max + 1}, () => 0);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (iMeanX)
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => 0);
let byMeanY = Array.from({ length: max + 1}, () => 0);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX)
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => 0);
let byMeanY = Array.from({ length: max + 1}, () => 0);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX])
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => 0);
let byMeanY = Array.from({ length: max + 1}, () => 0);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === 0) {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => );
let byMeanY = Array.from({ length: max + 1}, () => 0);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === 0) {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => []);
let byMeanY = Array.from({ length: max + 1}, () => []);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === 0) {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => []);
let byMeanY = Array.from({ length: max + 1}, () => []);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] ) {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = Array.from({ length: max + 1}, () => []);
let byMeanY = Array.from({ length: max + 1}, () => []);
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][]) {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][]) {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair]) {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1
} else {
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].y]++;
}
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for let
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanX) {
console.log()
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanX) {
console.log(x);
if x
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if x
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (x
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (x in
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (by
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasProperty
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x)
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY.hasOwnProperty()
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[].hasOwnProperty()
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y) {
d += bMeanX[x][y]
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y) {
d += bMeanX[x][y] * bMeanY[y][x];
}
}
}
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
solution.js:46 if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y) { ^ SyntaxError: Unexpected token { at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:402:29) at Promise.resolve.then (/tmp/exec.js:436:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
solution.js:46 if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y) { ^ SyntaxError: Unexpected token { at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:402:29) at Promise.resolve.then (/tmp/exec.js:436:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
TypeError: byMeanY is not iterable at solution (solution.js:42:19) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
TypeError: byMeanY is not iterable at solution (solution.js:42:19) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
cons
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
TypeError: byMeanY is not iterable at solution (solution.js:42:19) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
{}
TypeError: byMeanY is not iterable at solution (solution.js:42:19) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
{}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
TypeError: byMeanY is not iterable at solution (solution.js:44:19) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
{}
TypeError: byMeanY is not iterable at solution (solution.js:44:19) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
{}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
{}
{}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
con
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] {}
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] {}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
consol
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal x equal x equal x equal x equal {}
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] x equal x equal x equal {}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal y equal y equal x equal x equal x equal y equal x equal {}
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal y equal x equal y equal x equal x equal y equal y equal y equal {}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('meanX, iMeanX:', )
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('meanX, iMeanX:', meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal meanX, iMeanX: 1 1 y equal y equal y equal x equal meanX, iMeanX: 2 2 x equal meanX, iMeanX: 2 2 x equal meanX, iMeanX: 2 2 y equal x equal meanX, iMeanX: 3 3 {}
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal y equal x equal meanX, iMeanX: 1 1 y equal x equal meanX, iMeanX: 2 2 x equal meanX, iMeanX: 3 3 y equal y equal y equal {}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:', meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal p.x meanX, iMeanX: 1 1 1 y equal y equal y equal x equal p.x meanX, iMeanX: 2 2 2 x equal p.x meanX, iMeanX: 2 2 2 x equal p.x meanX, iMeanX: 2 2 2 y equal x equal p.x meanX, iMeanX: 3 3 3 {}
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal y equal x equal p.x meanX, iMeanX: 1 1 1 y equal x equal p.x meanX, iMeanX: 2 2 2 x equal p.x meanX, iMeanX: 3 3 3 y equal y equal y equal {}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].x) {
console.log('x equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
TypeError: Cannot read property '3' of undefined at solution (solution.js:25:36) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here
TypeError: Cannot read property '1' of undefined at solution (solution.js:25:36) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined)
if (byMeanX[iMeanX][pair[0].y] !== undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
TypeError: Cannot read property '2' of undefined at solution (solution.js:40:36) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanY)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
TypeError: Cannot read property '2' of undefined at solution (solution.js:40:36) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanX[iMeanY] === undefined) {
byMeanX[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
TypeError: Cannot read property '2' of undefined at solution (solution.js:43:36) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMean[iMeanY] === undefined) {
byMeanX[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] !== undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here x equal here x equal here y equal p.x meanX, iMeanX: 2 2.5 2 x equal { '2': { '2': NaN }, '3': { '2': NaN }, '4': { '2': NaN } } { '2': { '3': 1, '4': 1 } }
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
// for (let y of byMeanY) {
// console.log(y);
// for (let x of byMeanY[y]) {
// console.log(x);
// if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
// diamonds += bMeanX[x][y] * bMeanY[y][x];
// }
// }
// }
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here x equal here x equal here y equal p.x meanX, iMeanX: 2 2.5 2 x equal { '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } }
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of byMeanY) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of byMeanY.keys) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
console.log(y);
for (let x of byMeanY[y]) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
console.log(y);
for (let x of Object.keys(byMeanY[y])) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += bMeanX[x][y] * bMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
ReferenceError: bMeanX is not defined at solution (solution.js:60:29) at solutionWrapper (/tmp/exec.js:412:28) at Promise.resolve.then (/tmp/exec.js:438:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3stdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here x equal here x equal here y equal p.x meanX, iMeanX: 2 2.5 2 x equal { '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } } 2 2
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
console.log(y);
for (let x of Object.keys(byMeanY[y])) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
console.log(y);
for (let x of Object.keys(byMeanY[y])) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, non-integer number foundstdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here x equal here x equal here y equal p.x meanX, iMeanX: 2 2.5 2 x equal { '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } } 2 2 3 2 4 2
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
console.log(y);
for (let x of Object.keys(byMeanY[y])) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log()
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
console.log(y);
for (let x of Object.keys(byMeanY[y])) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, non-integer number foundstdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here x equal here x equal here y equal p.x meanX, iMeanX: 2 2.5 2 x equal { '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } } 2 2 multi: NaN 3 2 4 2
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
console.log(y);
for (let x of Object.keys(byMeanY[y])) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
console.log(y);
for (let x of Object.keys(byMeanY[y])) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x][y])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, non-integer number foundstdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here x equal here x equal here y equal p.x meanX, iMeanX: 2 2.5 2 x equal { '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } } 2 2 undefined multi: NaN 3 2 4 2
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log(x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x][y])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('x, y:' x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x][y])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
console.log('here')
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
console.log('here')
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x:', y, x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x][y])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, non-integer number foundstdout:
[ [ { x: 1, y: 3 }, { x: 1, y: 4 } ], [ { x: 1, y: 3 }, { x: 2, y: 1 } ], [ { x: 1, y: 3 }, { x: 2, y: 3 } ], [ { x: 1, y: 3 }, { x: 2, y: 5 } ], [ { x: 1, y: 3 }, { x: 3, y: 3 } ], [ { x: 1, y: 3 }, { x: 3, y: 4 } ], [ { x: 1, y: 4 }, { x: 2, y: 1 } ], [ { x: 1, y: 4 }, { x: 2, y: 3 } ], [ { x: 1, y: 4 }, { x: 2, y: 5 } ], [ { x: 1, y: 4 }, { x: 3, y: 3 } ], [ { x: 1, y: 4 }, { x: 3, y: 4 } ], [ { x: 2, y: 1 }, { x: 2, y: 3 } ], [ { x: 2, y: 1 }, { x: 2, y: 5 } ], [ { x: 2, y: 1 }, { x: 3, y: 3 } ], [ { x: 2, y: 1 }, { x: 3, y: 4 } ], [ { x: 2, y: 3 }, { x: 2, y: 5 } ], [ { x: 2, y: 3 }, { x: 3, y: 3 } ], [ { x: 2, y: 3 }, { x: 3, y: 4 } ], [ { x: 2, y: 5 }, { x: 3, y: 3 } ], [ { x: 2, y: 5 }, { x: 3, y: 4 } ], [ { x: 3, y: 3 }, { x: 3, y: 4 } ] ] x equal y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here y equal p.x meanX, iMeanX: 1 2 2 here x equal here x equal here x equal here y equal p.x meanX, iMeanX: 2 2.5 2 x equal { '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } } y, x: 2 2 undefined multi: NaN y, x: 3 2 y, x: 4 2
[ [ { x: 1, y: 1 }, { x: 2, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 1 } ], [ { x: 1, y: 1 }, { x: 3, y: 2 } ], [ { x: 1, y: 1 }, { x: 2, y: 2 } ], [ { x: 1, y: 1 }, { x: 1, y: 2 } ], [ { x: 2, y: 1 }, { x: 3, y: 1 } ], [ { x: 2, y: 1 }, { x: 3, y: 2 } ], [ { x: 2, y: 1 }, { x: 2, y: 2 } ], [ { x: 2, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 1 }, { x: 3, y: 2 } ], [ { x: 3, y: 1 }, { x: 2, y: 2 } ], [ { x: 3, y: 1 }, { x: 1, y: 2 } ], [ { x: 3, y: 2 }, { x: 2, y: 2 } ], [ { x: 3, y: 2 }, { x: 1, y: 2 } ], [ { x: 2, y: 2 }, { x: 1, y: 2 } ] ] y equal p.x meanX, iMeanX: 1 1.5 1 y equal p.x meanX, iMeanX: 1 2 2 here x equal y equal p.x meanX, iMeanX: 2 2.5 2 x equal x equal y equal p.x meanX, iMeanX: 3 2.5 2 y equal p.x meanX, iMeanX: 3 2 2 here y equal p.x meanX, iMeanX: 2 1.5 1 {} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
console.log(combinations);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x:', y, x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x][y])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x:', y, x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x][y])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, non-integer number foundstdout:
{ '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } } y, x: 2 2 undefined multi: NaN y, x: 3 2 y, x: 4 2
{} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x:', y, x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
Invalid result type, integer expected, non-integer number foundstdout:
{ '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } } y, x: 2 2 { '3': 1, '4': 1 } multi: NaN y, x: 3 2 y, x: 4 2
{} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x:', y, x);
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x:', y, x);
console.log()
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x:', y, x);
console.log(byMeanX.hasOwnProperty(x))
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x byMeanX, byMeanY:', y, x);
console.log(byMeanX.hasOwnProperty(x))
if (byMeanX.hasOwnProperty(x) && byMeanY[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x byMeanX, byMeanY:', y, x);
console.log(byMeanX.hasOwnProperty(x))
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x byMeanX, byMeanXx:', y, x, );
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, );
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
console.log(byMeanX[x])
console.log('multi:', byMeanX[x][y] * byMeanY[y][x])
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
{ '2': { '2': 1 }, '3': { '2': 1 }, '4': { '2': 1 } } { '2': { '3': 1, '4': 1 } } y, x byMeanX, byMeanXx: 2 2 { '2': { '3': 1, '4': 1 } } { '3': 1, '4': 1 } y, x byMeanX, byMeanXx: 3 2 { '2': { '3': 1, '4': 1 } } { '3': 1, '4': 1 } { '3': 1, '4': 1 } multi: 1 y, x byMeanX, byMeanXx: 4 2 { '2': { '3': 1, '4': 1 } } { '3': 1, '4': 1 } { '3': 1, '4': 1 } multi: 1
{} { '2': { '1': 1, '2': 1 } }
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
console.log(byMeanY)
console.log(byMeanX)
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
// console.log('y equal')
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
if (pair[0].y === pair[1].y) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// console.log('p.x meanX, iMeanX:',pair[0].x, meanX, iMeanX)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and not the same
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0; /
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
// check
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
// check the
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
// check there are two
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
// check there are two values
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
// check there is
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// console.log('x equal')
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// calculate the mean of y values
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// calculate the mean of y values
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
// check the mean is an int and is a different value (not same position)
if (meanY !== pair[0].y && meanY === iMeanY) {
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// calculate the mean of y values
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
// check the mean is an int and is a different value (not same position)
if (meanY !== pair[0].y && meanY === iMeanY) {
// store values in byMeanY object of objects
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
// store values in byMeanX object of objects
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// calculate the mean of y values
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
// check the mean is an int and is a different value (not same position)
if (meanY !== pair[0].y && meanY === iMeanY) {
// store values in byMeanY object of objects
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
// store values in byMeanX object of objects
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// calculate the mean of y values
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
// check the mean is an int and is a different value (not same position)
if (meanY !== pair[0].y && meanY === iMeanY) {
// store values in byMeanY object of objects
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
// return all the different combinations of two points
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
// store values in byMeanX object of objects
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// calculate the mean of y values
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
// check the mean is an int and is a different value (not same position)
if (meanY !== pair[0].y && meanY === iMeanY) {
// store values in byMeanY object of objects
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
// return all the different combinations of two points
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
// store values in byMeanX object of objects
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// calculate the mean of y values
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
// check the mean is an int and is a different value (not same position)
if (meanY !== pair[0].y && meanY === iMeanY) {
// store values in byMeanY object of objects
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
// return all the different combinations of two points
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(X, Y) {
// write your code in JavaScript (Node.js 8.9.4)
let points = [];
for (let i = 0; i < X.length; i++) {
points.push({x:X[i], y:Y[i]});
}
let max = Math.max(...X, ...Y);
let byMeanX = {};
let byMeanY = {};
let combinations = combinationsOfTwo(points);
for (let pair of combinations) {
// check if y values are equal
if (pair[0].y === pair[1].y) {
// calculate the mean of x values
let meanX = (pair[0].x + pair[1].x) / 2;
let iMeanX = parseInt(meanX);
// check the mean is an int and is a different value (not same position)
if (meanX !== pair[0].x && meanX === iMeanX) {
// store values in byMeanX object of objects
if (byMeanX[iMeanX] === undefined) {
byMeanX[iMeanX] = {};
}
if (byMeanX[iMeanX][pair[0].y] === undefined) {
byMeanX[iMeanX][pair[0].y] = 1;
} else {
byMeanX[iMeanX][pair[0].y]++;
}
}
// check if x values are equal
} else if (pair[0].x === pair[1].x) {
// calculate the mean of y values
let meanY = (pair[0].y + pair[1].y) / 2;
let iMeanY = parseInt(meanY);
// check the mean is an int and is a different value (not same position)
if (meanY !== pair[0].y && meanY === iMeanY) {
// store values in byMeanY object of objects
if (byMeanY[iMeanY] === undefined) {
byMeanY[iMeanY] = {};
}
if (byMeanY[iMeanY][pair[0].x] === undefined) {
byMeanY[iMeanY][pair[0].x] = 1;
} else {
byMeanY[iMeanY][pair[0].x]++;
}
}
}
}
let diamonds = 0;
for (let y of Object.keys(byMeanY)) {
for (let x of Object.keys(byMeanY[y])) {
// console.log('y, x byMeanX, byMeanXx:', y, x, byMeanX, byMeanX[x]);
if (byMeanX.hasOwnProperty(x) && byMeanX[x].hasOwnProperty(y)) {
diamonds += byMeanX[x][y] * byMeanY[y][x];
}
}
}
return diamonds;
}
// return all the different combinations of two points
function combinationsOfTwo(A) {
let comb = []
for (let i = 0; i < A.length - 1; i++) {
for (let j = i+1; j < A.length; j++) {
comb.push([A[i],A[j]]);
}
}
return comb;
}
The following issues have been detected: timeout errors.
max tests with many points in one line
running time: 0.740 sec., time limit: 0.512 sec.
points arranged in a cross or square
running time: 0.700 sec., time limit: 0.480 sec.
max tests with points in three parallel lines
running time: 0.608 sec., time limit: 0.528 sec.