Best algorithm has been found - locked
Pattern | Input | Output | ||||||
---|---|---|---|---|---|---|---|---|
1. |
|
|
||||||
2. |
|
|
||||||
3. |
|
|
||||||
4. |
|
|
/** * a = b: IF a=b THEN 1 ELSE 0; * * @param x1 a * @param x2 b * @return {Array} */ function neuron591(x1, x2) { return [(x1 == x2) ? 1 : 0]; } /** * 1: * * @return {Array} */ function neuron501() { return [1]; } /** * Minus (x - y): * * @param x1 Number X * @param x2 Number Y * @return {Array} */ function neuron2(x1, x2) { math.config({number: 'BigNumber', precision: 64}); return [math.eval(Number(x1) + '-'+Number(x2)).toString()]; } /** * NOT: * * @param x1 1/0 * @return {Array} */ function neuron567(x1) { var outputs = []; outputs[0] = x1; arr = neuron501(); outputs[1] = arr[0]; arr = neuron2(outputs[1], outputs[0]); outputs[2] = arr[0]; return[outputs[2]]; } /** * a is not b: * * @param x1 a * @param x2 b * @return {Array} */ function neuron704(x1, x2) { var outputs = []; outputs[0] = x1; outputs[1] = x2; arr = neuron591(outputs[0], outputs[1]); outputs[2] = arr[0]; arr = neuron567(outputs[2]); outputs[3] = arr[0]; return[outputs[3]]; }