Contains string word A or B?

Description

return 1/0

Inputs

  • main string
  • A
  • B

Outputs

  • 1/0

Neuron type

Best algorithm has been found - locked

Patterns

Pattern Input Output
1.
main string: red apple
A: red
B: green
1/0: 1
2.
main string: green apple
A: red
B: green
1/0: 1
3.
main string: yellow apple
A: red
B: green
1/0: 0
4.
main string: abc
A: 1
B: 2
1/0: 0

Applicable neurons

  • RegExp.test
  • (x|y)
  • empty string
  • name into start tag
  • empty string change into zero

Algorithm

Test

Code made by AI:
/**
 * 0: 
 *
 * @return {Array}
 */
function neuron500()
{
return [0];
}

/**
 * 1: 
 *
 * @return {Array}
 */
function neuron501()
{
return [1];
}

/**
 * 4: 
 *
 * @return {Array}
 */
function neuron504()
{
return [4];
}

/**
 * Connect - two inputs: 
 *
 * @param x1 Variable A
 * @param x2 Variable B
 * @return {Array}
 */
function neuron520(x1, x2)
{
return [x1.toString()+x2.toString()];
}

/**
 * Connect - three inputs: Connect stringA + stringB + stringC
 * 
 * @param x1 string A
 * @param x2 string B
 * @param x3 string C
 * @return {Array}
 */
function neuron564(x1, x2, x3)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;

  arr = neuron520(outputs[1], outputs[2]);
  outputs[3] = arr[0];

  arr = neuron520(outputs[0], outputs[3]);
  outputs[4] = arr[0];

  return[outputs[4]];
}


/**
 * Ascii code into character: 
 *
 * @param x1 ascii code
 * @return {Array}
 */
function neuron585(x1)
{
return [String.fromCharCode(x1)];
}

/**
 * 3 digits of ascii code into character: connect 3 digits to one ascii number and change it to character
 * 
 * @param x1 1. digit
 * @param x2 2. digit
 * @param x3 3. digit
 * @return {Array}
 */
function neuron638(x1, x2, x3)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;

  arr = neuron564(outputs[0], outputs[1], outputs[2]);
  outputs[3] = arr[0];

  arr = neuron585(outputs[3]);
  outputs[4] = arr[0];

  return[outputs[4]];
}


/**
 * character ): 
 * 
 * @return {Array}
 */
function neuron687()
{
  var outputs = [];

  arr = neuron500();
  outputs[0] = arr[0];

  arr = neuron501();
  outputs[1] = arr[0];

  arr = neuron504();
  outputs[2] = arr[0];

  arr = neuron638(outputs[0], outputs[2], outputs[1]);
  outputs[3] = arr[0];

  return[outputs[3]];
}


/**
 * 4: 
 *
 * @return {Array}
 */
function neuron504()
{
return [4];
}

/**
 * 0: 
 *
 * @return {Array}
 */
function neuron500()
{
return [0];
}

/**
 * Connect - two inputs: 
 *
 * @param x1 Variable A
 * @param x2 Variable B
 * @return {Array}
 */
function neuron520(x1, x2)
{
return [x1.toString()+x2.toString()];
}

/**
 * Connect - three inputs: Connect stringA + stringB + stringC
 * 
 * @param x1 string A
 * @param x2 string B
 * @param x3 string C
 * @return {Array}
 */
function neuron564(x1, x2, x3)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;

  arr = neuron520(outputs[1], outputs[2]);
  outputs[3] = arr[0];

  arr = neuron520(outputs[0], outputs[3]);
  outputs[4] = arr[0];

  return[outputs[4]];
}


/**
 * Ascii code into character: 
 *
 * @param x1 ascii code
 * @return {Array}
 */
function neuron585(x1)
{
return [String.fromCharCode(x1)];
}

/**
 * 3 digits of ascii code into character: connect 3 digits to one ascii number and change it to character
 * 
 * @param x1 1. digit
 * @param x2 2. digit
 * @param x3 3. digit
 * @return {Array}
 */
function neuron638(x1, x2, x3)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;

  arr = neuron564(outputs[0], outputs[1], outputs[2]);
  outputs[3] = arr[0];

  arr = neuron585(outputs[3]);
  outputs[4] = arr[0];

  return[outputs[4]];
}


/**
 * character (: 
 * 
 * @return {Array}
 */
function neuron686()
{
  var outputs = [];

  arr = neuron504();
  outputs[0] = arr[0];

  arr = neuron500();
  outputs[1] = arr[0];

  arr = neuron638(outputs[1], outputs[0], outputs[1]);
  outputs[2] = arr[0];

  return[outputs[2]];
}


/**
 * 1: 
 *
 * @return {Array}
 */
function neuron501()
{
return [1];
}

/**
 * 4: 
 *
 * @return {Array}
 */
function neuron504()
{
return [4];
}

/**
 * 2: 
 *
 * @return {Array}
 */
function neuron502()
{
return [2];
}

/**
 * Connect - two inputs: 
 *
 * @param x1 Variable A
 * @param x2 Variable B
 * @return {Array}
 */
function neuron520(x1, x2)
{
return [x1.toString()+x2.toString()];
}

/**
 * Connect - three inputs: Connect stringA + stringB + stringC
 * 
 * @param x1 string A
 * @param x2 string B
 * @param x3 string C
 * @return {Array}
 */
function neuron564(x1, x2, x3)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;

  arr = neuron520(outputs[1], outputs[2]);
  outputs[3] = arr[0];

  arr = neuron520(outputs[0], outputs[3]);
  outputs[4] = arr[0];

  return[outputs[4]];
}


/**
 * Ascii code into character: 
 *
 * @param x1 ascii code
 * @return {Array}
 */
function neuron585(x1)
{
return [String.fromCharCode(x1)];
}

/**
 * 3 digits of ascii code into character: connect 3 digits to one ascii number and change it to character
 * 
 * @param x1 1. digit
 * @param x2 2. digit
 * @param x3 3. digit
 * @return {Array}
 */
function neuron638(x1, x2, x3)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;

  arr = neuron564(outputs[0], outputs[1], outputs[2]);
  outputs[3] = arr[0];

  arr = neuron585(outputs[3]);
  outputs[4] = arr[0];

  return[outputs[4]];
}


/**
 * character |: 
 * 
 * @return {Array}
 */
function neuron752()
{
  var outputs = [];

  arr = neuron501();
  outputs[0] = arr[0];

  arr = neuron504();
  outputs[1] = arr[0];

  arr = neuron502();
  outputs[2] = arr[0];

  arr = neuron638(outputs[0], outputs[2], outputs[1]);
  outputs[3] = arr[0];

  return[outputs[3]];
}


/**
 * Connect - two inputs: 
 *
 * @param x1 Variable A
 * @param x2 Variable B
 * @return {Array}
 */
function neuron520(x1, x2)
{
return [x1.toString()+x2.toString()];
}

/**
 * Connect - four inputs: 
 * 
 * @param x1 string A
 * @param x2 string B
 * @param x3 string C
 * @param x4 string D
 * @return {Array}
 */
function neuron565(x1, x2, x3, x4)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;
  outputs[3] = x4;

  arr = neuron520(outputs[2], outputs[3]);
  outputs[4] = arr[0];

  arr = neuron520(outputs[1], outputs[4]);
  outputs[5] = arr[0];

  arr = neuron520(outputs[0], outputs[5]);
  outputs[6] = arr[0];

  return[outputs[6]];
}


/**
 * Connect - two inputs: 
 *
 * @param x1 Variable A
 * @param x2 Variable B
 * @return {Array}
 */
function neuron520(x1, x2)
{
return [x1.toString()+x2.toString()];
}

/**
 * Connect - five inputs: 
 * 
 * @param x1 1
 * @param x2 2
 * @param x3 3
 * @param x4 4
 * @param x5 5
 * @return {Array}
 */
function neuron651(x1, x2, x3, x4, x5)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;
  outputs[3] = x4;
  outputs[4] = x5;

  arr = neuron565(outputs[1], outputs[2], outputs[3], outputs[4]);
  outputs[5] = arr[0];

  arr = neuron520(outputs[0], outputs[5]);
  outputs[6] = arr[0];

  return[outputs[6]];
}


/**
 * (x|y): Bracket (x|y). Find any of the alternatives specified
 * 
 * @param x1 x
 * @param x2 y
 * @return {Array}
 */
function neuron753(x1, x2)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;

  arr = neuron687();
  outputs[2] = arr[0];

  arr = neuron686();
  outputs[3] = arr[0];

  arr = neuron752();
  outputs[4] = arr[0];

  arr = neuron651(outputs[3], outputs[0], outputs[4], outputs[1], outputs[2]);
  outputs[5] = arr[0];

  return[outputs[5]];
}


/**
 * empty string: 
 *
 * @return {Array}
 */
function neuron755()
{
return ['']
}

/**
 * RegExp.test: Tests for a match in a string of the regular expression. Returns 1/0.
 *
 * @param x1 pattern
 * @param x2 flags
 * @param x3 string
 * @return {Array}
 */
function neuron751(x1, x2, x3)
{
var pattern = x1; var flags = x2; var string = x3; var r = new RegExp(pattern, flags); return (r.test(string)) ? [1] : [0];
}

/**
 * Contains string word A or B?: return 1/0
 * 
 * @param x1 main string
 * @param x2 A
 * @param x3 B
 * @return {Array}
 */
function neuron756(x1, x2, x3)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;
  outputs[2] = x3;

  arr = neuron753(outputs[2], outputs[1]);
  outputs[3] = arr[0];

  arr = neuron755();
  outputs[4] = arr[0];

  arr = neuron751(outputs[3], outputs[4], outputs[0]);
  outputs[5] = arr[0];

  return[outputs[5]];
}


Code made by AI:

Create your family tree for free