Check if a string starts with a specified string?

Inputs

  • String
  • Starts with

Outputs

  • Starts with

Neuron type

Best algorithm has been found - locked

Patterns

Pattern Input Output
1.
String: Abcd
Starts with: Ab
Starts with: 1
2.
String: Bcda
Starts with: a
Starts with: 0
3.
String: Blue
Starts with: lue
Starts with: 0
4.
String: 123
Starts with: Car
Starts with: 0

Applicable neurons

  • 0
  • 1
  • Substring (from start to position)
  • Substring (from position to end)
  • Get after substring
  • Get before substring
  • Get after last substring
  • Get first letter
  • Get first word
  • Get last character
  • Get the last XY characters
  • constant x.x
  • circle - Perimeter (by radius)
  • Sine (sinus) - degrees
  • right angled triangle, find Hypotenuse c, given a, b
  • tag title
  • Price without VAT
  • character space " "
  • a ≤ b
  • 10000

Algorithm

Test

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

/**
 * Length of string: 
 *
 * @param x1 String
 * @return {Array}
 */
function neuron528(x1)
{
return[x1.toString().length];
}

/**
 * PositionLast: Search last occurrence
 *
 * @param x1 MyString
 * @param x2 FindMe
 * @return {Array}
 */
function neuron581(x1, x2)
{
return [x1.toString().lastIndexOf(x2)];
}

/**
 * Plus (x + y): The addition of two whole numbers is the total amount of those quantities combined.
 *
 * @param x1 first number
 * @param x2 second number
 * @return {Array}
 */
function neuron1(x1, x2)
{
math.config({number: 'BigNumber', precision: 64}); return [math.eval(Number(x1) + '+'+Number(x2)).toString()];
}

/**
 * Length of string: 
 *
 * @param x1 String
 * @return {Array}
 */
function neuron528(x1)
{
return[x1.toString().length];
}

/**
 * Substring (startPosition, endPosition): Get substring from string - from position - to pos
 *
 * @param x1 MyString
 * @param x2 start position
 * @param x3 end position
 * @return {Array}
 */
function neuron525(x1, x2, x3)
{
return[x1.toString().substring(x2, x3)];
}

/**
 * Substring (from position to end): 
 * 
 * @param x1 MyString
 * @param x2 start position
 * @return {Array}
 */
function neuron529(x1, x2)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;

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

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

  return[outputs[3]];
}


/**
 * Get after last substring: 
 * 
 * @param x1 MyString
 * @param x2 Substring
 * @return {Array}
 */
function neuron618(x1, x2)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;

  arr = neuron528(outputs[1]);
  outputs[2] = arr[0];

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

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

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

  return[outputs[5]];
}


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

/**
 * Position: Search position substring of string
 *
 * @param x1 MyString
 * @param x2 FindMe
 * @return {Array}
 */
function neuron523(x1, x2)
{
return [x1.toString().indexOf(x2.toString())];
}

/**
 * a > b: IF a>b THEN 1 ELSE 0;
 *
 * @param x1 a
 * @param x2 b
 * @return {Array}
 */
function neuron589(x1, x2)
{
return [(Number(x1) > Number(x2)) ? 1 : 0];
}

/**
 * Contains string substring?: 
 * 
 * @param x1 String
 * @param x2 Searched substring
 * @return {Array}
 */
function neuron824(x1, x2)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;

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

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

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

  return[outputs[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];
}

/**
 * Check if a string ends with a specified string: 
 * 
 * @param x1 String
 * @param x2 ends with
 * @return {Array}
 */
function neuron916(x1, x2)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;

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

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

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

  return[outputs[4]];
}


/**
 * Check if a string starts with a specified string?: 
 * 
 * @param x1 String
 * @param x2 Starts with
 * @return {Array}
 */
function neuron915(x1, x2)
{
  var outputs = [];
  outputs[0] = x1;
  outputs[1] = x2;

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

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

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

  return[outputs[4]];
}


Code made by AI:

Create your family tree for free