prompt:
为以下代码写单测：
```
function hasCloseElements(numbers, threshold) {
  for (let i = 0; i < numbers.length; i++) {
    for (let j = 0; j < numbers.length; j++) {
      if (i != j) {
        let distance = Math.abs(numbers[i] - numbers[j]);
        if (distance < threshold) {
          return true;
        }
      }
    }
  }
  return false;
}
```


prompt:
为以下代码写单测：
```
function separateParenGroups(paren_string) {
  var result = [];
  var current_string = [];
  var current_depth = 0;

  for (const c of paren_string) {
    if (c == '(') {
      current_depth += 1;
      current_string.push(c);
    } else if (c == ')') {
      current_depth -= 1;
      current_string.push(c);
      if (current_depth == 0) {
        result.push(current_string.join(''));
        current_string = [];
      }
    }
  }

  return result;
}
```


prompt:
为以下代码写单测：
```
function truncateNumber(number) {
  return number % 1.0;
}
```


prompt:
为以下代码写单测：
```
function belowZero(operations) {
  var balance = 0;
  for (const op of operations) {
    balance += op;
    if (balance < 0) {
      return true;
    }
  }
  return false;
}
```


prompt:
为以下代码写单测：
```
function meanAbsoluteDeviation(numbers) {
  var mean = numbers.reduce((prev, item) => {
    return prev + item;
  }, 0) / numbers.length;
  return numbers.reduce((prev, item) => {
    return prev + Math.abs(item - mean);
  }, 0) / numbers.length;

}
```


prompt:
为以下代码写单测：
```
function intersperse(numbers, delimeter) {
  if (!Array.isArray(numbers) || numbers.length == 0)
    return [];
  var result = [];
  for (const n of numbers) {
    result.push(n, delimeter);
  }
  result.pop();
  return result;
}
```


prompt:
为以下代码写单测：
```
function parseNestedParens(paren_string) {
  var parseParenGroup = function (s) {
    let depth = 0, max_depth = 0;
    for (const c of s) {
      if (c == '(') {
        depth += 1;
        max_depth = Math.max(max_depth, depth);
      } else {
        depth -= 1;
      }
    }
    return max_depth;
  }
  return paren_string.split(' ')
          .filter(x => x != '')
          .map(x => parseParenGroup(x));
}
```


prompt:
为以下代码写单测：
```
function filterBySubstring(strings, substring) {
  return strings.filter(x => x.indexOf(substring) != -1);
}
```


prompt:
为以下代码写单测：
```
function sumProduct(numbers, int) {
  var sum_value = 0, prod_value = 1;
  for (const n of numbers) {
    sum_value += n;
    prod_value *= n;
  }
  return [sum_value, prod_value];
}
```


prompt:
为以下代码写单测：
```
function rollingMax(numbers) {
  var running_max, result = [];
  for (const n of numbers) {
    if (running_max == undefined)
      running_max = n;
    else
      running_max = Math.max(running_max, n);
    result.push(running_max);
  }
  return result;
}
```


prompt:
为以下代码写单测：
```
function isPalindrome(string) {
  if (string == '')
    return '';
  var beginning_of_suffix = 0;
  while (!isPalindrome(string.slice(beginning_of_suffix)))
    beginning_of_suffix += 1;
  return string + string.slice(0, beginning_of_suffix).split('').reverse().join('');
}
```


prompt:
为以下代码写单测：
```
function stringXor(a, b) {
  var xor = function (i, j) {
    if (i == j)
      return '0';
    else
      return '1';
  }
  return a.split('').map((item, index) => xor(item, b[index])).join('');
}
```


prompt:
为以下代码写单测：
```
function longest(strings) {
  if (!Array.isArray(strings) || strings.length == 0)
    return null;
  var maxlen = Math.max(...strings.map(x => x.length));
  for (const s of strings) {
    if (s.length == maxlen) {
      return s;
    }
  }
}
```


prompt:
为以下代码写单测：
```
function greatestCommonDivisor(a, b) {
  while (b != 0) {
    let temp = a;
    a = b;
    b = temp % b;
  }
  return a;
}
```


prompt:
为以下代码写单测：
```
function allPrefixes(string) {
  var result = [];
  for (let i = 0; i < string.length; i++) {
    result.push(string.slice(0, i+1));
  }
  return result;
}
```


prompt:
为以下代码写单测：
```
function stringSequence(n) {
  return [...Array(n).keys(), n].join(' ')
}
```


prompt:
为以下代码写单测：
```
function countDistinctCharacters(string) {
  return (new Set(string.toLowerCase())).size;

}
```


prompt:
为以下代码写单测：
```
function parseMusic(music_string) {
  const note_map = {'o': 4, 'o|': 2, '.|': 1};
  return music_string.split(' ').filter(x => x != '').map(x => note_map[x]);
}
```


prompt:
为以下代码写单测：
```
function howManyTimes(string, substring) {
  var times = 0;
  for (let i = 0; i < string.length - substring.length + 1; i++) {
    if (string.slice(i, i+substring.length) == substring) {
      times += 1;
    }
  }
  return times;
}
```


prompt:
为以下代码写单测：
```
function sortNumbers(numbers) {
  const value_map = {
    'zero': 0,
    'one': 1,
    'two': 2,
    'three': 3,
    'four': 4,
    'five': 5,
    'six': 6,
    'seven': 7,
    'eight': 8,
    'nine': 9
  };
  return numbers.split(' ')
          .filter(x => x != '')
          .sort((a, b) => value_map[a] - value_map[b])
          .join(' ');
}
```


prompt:
为以下代码写单测：
```
function findClosestElements(numbers) {
  var closest_pair, distance;
  for (let i = 0; i < numbers.length; i++)
    for (let j = 0; j < numbers.length; j++)
      if (i != j) {
        let a = numbers[i], b = numbers[j];
        if (distance == null) {
          distance = Math.abs(a - b);
          closest_pair = [Math.min(a, b), Math.max(a, b)];
        } else {
          let new_distance = Math.abs(a - b);
          if (new_distance < distance) {
            distance = new_distance;
            closest_pair = [Math.min(a, b), Math.max(a, b)];
          }
        }
      }
  return closest_pair;
}
```


prompt:
为以下代码写单测：
```
function rescaleToUnit(numbers) {
  var min_number = Math.min(...numbers);
  var max_number = Math.max(...numbers);
  return numbers.map(x => (x - min_number) / (max_number - min_number));
}
```


prompt:
为以下代码写单测：
```
function filterIntegers(values) {
  return values.filter(x => Number.isInteger(x));
}
```


prompt:
为以下代码写单测：
```
function strlen(string) {
  return string.length;
}
```


prompt:
为以下代码写单测：
```
function largestDivisor(n) {
  for (let i = n - 1; i >= 0; i--)
    if (n % i == 0)
      return i;
}
```


prompt:
为以下代码写单测：
```
function factorize(n) {
  var fact = [], i = 2;
  while (i <= Math.sqrt(n) + 1) {
    if (n % i == 0) {
      fact.push(i);
      n = n / i;
    } else {
      i += 1;
    }
  }

  if (n > 1)
    fact.push(n);
  return fact;
}
```


prompt:
为以下代码写单测：
```
function removeDuplicates(numbers) {
  var dict = new Object();
  for (const num of numbers) {
    if (num in dict) {
      dict[num] += 1;
    } else {
      dict[num] = 1;
    }
  }
  return numbers.filter(x => dict[x] <= 1);
}
```


prompt:
为以下代码写单测：
```
function flipCase(string) {
  return string.split('')
          .map(x => (x.toUpperCase() == x ? x.toLowerCase() : x.toUpperCase()))
          .join('');
}
```


prompt:
为以下代码写单测：
```
function concatenate(strings) {
  return strings.join('');
}
```


prompt:
为以下代码写单测：
```
function filterByPrefix(strings, prefix) {
  return strings.filter(x => x.startsWith(prefix));
}
```


prompt:
为以下代码写单测：
```
function getPositive(l) {
  return l.filter(e => e > 0);
}
```


prompt:
为以下代码写单测：
```
function isPrime(n) {
  if (n < 2)
    return false;
  for (let k = 2; k < n - 1; k++)
    if (n % k == 0)
      return false;
  return true;
}
```


prompt:
为以下代码写单测：
```
function poly(xs, x) {
  var begin = -1.0, end = 1.0;
  while (poly(xs, begin) * poly(xs, end) > 0) {
    begin *= 2.0;
    end *= 2.0;
  }
  while (end - begin > 1e-10) {
    let center = (begin + end) / 2.0;
    if (poly(xs, center) * poly(xs, begin) > 0)
      begin = center;
    else
      end = center;
  }
  return begin;
}
```


prompt:
为以下代码写单测：
```
function sortThird(l) {
  var three = l.filter((item, index) => index % 3 == 0);
  three.sort((a, b) => (a - b));
  return l.map((item, index) => (index % 3 == 0 ? three[index / 3] : item));
}
```


prompt:
为以下代码写单测：
```
function unique(l) {
  return Array.from(new Set(l)).sort((a, b) => (a - b));
}
```


prompt:
为以下代码写单测：
```
function maxElement(l) {
  return Math.max(...l);
}
```


prompt:
为以下代码写单测：
```
function fizzBuzz(n) {
  var ns = [], ans = 0;
  for (let i = 0; i < n; i++)
    if (i % 11 == 0 || i % 13 == 0)
      ns.push(i);
  var s = ns.map(x => x.toString()).join('');
  for (const c of s)
    ans += (c == '7');
  return ans;
}
```


prompt:
为以下代码写单测：
```
function sortEven(l) {
  var even = l.filter((item, index) => index % 2 == 0);
  even.sort((a, b) => (a - b));
  return l.map((item, index) => (index % 2 == 0 ? even[index / 2] : item));
}
```


prompt:
为以下代码写单测：
```
function encodeCyclic(s) {
  return encodeCyclic(encodeCyclic(s));
}
```


prompt:
为以下代码写单测：
```
function primeFib(n) {
  var isPrime = function (p) {
    if (p < 2)
      return false;
    for (let k = 2; k < Math.min(Math.floor(Math.sqrt(p)) + 1, p - 1); k++) {
      if (p % k == 0)
        return false;
    }
    return true;
  }

  var f = [0, 1];
  while (true) {
    f.push(f.at(-1) + f.at(-2));
    if (isPrime(f.at(-1)))
      n -= 1;
    if (n == 0)
      return f.at(-1);
  }
}
```


prompt:
为以下代码写单测：
```
function triplesSumToZero(l) {
  for (let i = 0; i < l.length; i++)
    for (let j = i + 1; j < l.length; j++)
      for (let k = j + 1; k < l.length; k++)
        if (l[i] + l[j] + l[k] == 0)
          return true;
  return false;
}
```


prompt:
为以下代码写单测：
```
function carRaceCollision(n) {
  return Math.pow(n, 2);
}
```


prompt:
为以下代码写单测：
```
function incrList(l) {
  return l.map(e => e + 1);
}
```


prompt:
为以下代码写单测：
```
function pairsSumToZero(l) {
  for (let i = 0; i < l.length; i++)
    for (let j = i + 1; j < l.length; j++)
      if (l[i] + l[j] == 0)
        return true;
  return false;
}
```


prompt:
为以下代码写单测：
```
function changeBase(x, base) {
  var ret = "";
  while (x > 0) {
    ret = (x % base).toString() + ret;
    x = Math.floor(x / base);
  }
  return ret;
}
```


prompt:
为以下代码写单测：
```
function triangleArea(a, h) {
  return a * h / 2.0;
}
```


prompt:
为以下代码写单测：
```
function fib4(n) {
  var results = [0, 0, 2, 0];
  if (n < 4)
    return results[n];
  for (let i = 4; i < n + 1; i++) {
    results.push(results.at(-1) + results.at(-2) +
                results.at(-3) + results.at(-4));
    results.shift();
  }
  return results.pop();
}
```


prompt:
为以下代码写单测：
```
function median(l) {
  l.sort((a, b) => a - b);
  var len = l.length;
  if (l.length % 2 == 1)
    return l[Math.floor(len / 2)];
  else
    return (l[len / 2 - 1] + l[len / 2]) / 2.0;
}
```


prompt:
为以下代码写单测：
```
function isPalindrome(text) {
  for (let i = 0; i < text.length; i++)
    if (text[i] != text.at(-i-1))
      return false;
  return true;
}
```


prompt:
为以下代码写单测：
```
function modp(n, p) {
  var ret = 1;
  for (let i = 0; i < n; i++)
    ret = (2 * ret) % p;
  return ret;
}
```


prompt:
为以下代码写单测：
```
function encodeShift(s) {
  return s.split("").map(ch => String.fromCharCode(
    ((ch.charCodeAt(0) - 5 + 26 - "a".charCodeAt(0)) % 26) + "a".charCodeAt(0)
  )).join("");
}
```


prompt:
为以下代码写单测：
```
function removeVowels(text) {
  return text.split("")
             .filter(s => !["a", "e", "i", "o", "u"]
                      .includes(s.toLowerCase())
                    )
             .join("")
}
```


prompt:
为以下代码写单测：
```
function belowThreshold(l, t) {
  for (const e of l)
    if (e >= t)
      return false;
  return true;
}
```


prompt:
为以下代码写单测：
```
function add(x, y) {
  return x + y;
}
```


prompt:
为以下代码写单测：
```
function sameChars(s0, s1) {
  return JSON.stringify([...new Set(s0)].sort()) === JSON.stringify([...new Set(s1)].sort());
}
```


prompt:
为以下代码写单测：
```
function fib(n) {
  if (n == 0)
    return 0;
  if (n == 1)
    return 1;
  return fib(n - 1) + fib(n - 2);
}
```


prompt:
为以下代码写单测：
```
function correctBracketing(brackets) {
  var depth = 0;
  for (const b of brackets) {
    if (b == "<")
      depth += 1;
    else
      depth -= 1;
    if (depth < 0)
      return false;
  }
  return depth == 0;
}
```


prompt:
为以下代码写单测：
```
function monotonic(l) {
  var sort1 = [...l].sort((a, b) => a - b);
  var sort2 = [...l].sort((a, b) => b - a);
  if (JSON.stringify(l) === JSON.stringify(sort1) ||
      JSON.stringify(l) === JSON.stringify(sort2))
    return true;
  return false;
}
```


prompt:
为以下代码写单测：
```
function common(l1, l2) {
  var ret = new Set();
  for (const e1 of l1)
    for (const e2 of l2)
      if (e1 == e2)
        ret.add(e1);
  return [...ret].sort();
}
```


prompt:
为以下代码写单测：
```
function largestPrimeFactor(n) {
  var isPrime = function (k) {
    if (k < 2)
      return false;
    for (let i = 2; i < k - 1; i++)
      if (k % i == 0)
        return false;
    return true;
  }

  var largest = 1;
  for (let j = 2; j < n + 1; j++)
    if (n % j == 0 && isPrime(j))
      largest = Math.max(largest, j);
  return largest;
}
```


prompt:
为以下代码写单测：
```
function sumToN(n) {
  return n * (n + 1) / 2;
}
```


prompt:
为以下代码写单测：
```
function correctBracketing(brackets) {
  var depth = 0;
  for (const b of brackets) {
    if (b == "(")
      depth += 1;
    else
      depth -= 1;
    if (depth < 0)
      return false;
  }
  return depth == 0;
}
```


prompt:
为以下代码写单测：
```
function derivative(xs) {
  return xs.map((x, i) => x * i).slice(1);
}
```


prompt:
为以下代码写单测：
```
function fibfib(n) {
  if (n == 0 || n == 1)
    return 0;
  if (n == 2)
    return 1;
  return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3);
}
```


prompt:
为以下代码写单测：
```
function vowelsCount(s) {
  var vowels = "aeiouAEIOU";
  var n_vowels = s.split('').reduce((prev, item) => {
    return prev + (vowels.includes(item));
  }, 0);
  if (s.at(-1) == 'y' || s.at(-1) == 'Y')
    n_vowels += 1;
  return n_vowels;
}
```


prompt:
为以下代码写单测：
```
function circularShift(x, shift) {
  s = x.toString();
  if (shift > s.length)
    return s.split('').reverse().join('');
  else
    return s.slice(-shift) + s.slice(0, -shift);
}
```


prompt:
为以下代码写单测：
```
function digitSum(s) {
  if (s == '') return 0;
  return s.split('').reduce((prev, char) => {
    let ord_char = char.charCodeAt(0)
    return prev + (ord_char > 64 && ord_char < 91 ? ord_char : 0);
  }, 0);
}
```


prompt:
为以下代码写单测：
```
function fruitDistribution(s, n) {
  var lis = [];
  for (const i of s.split(" "))
    if (!isNaN(i))
      lis.push(Number(i))
  return n - lis.reduce(((prev, item) => prev + item), 0);
}
```


prompt:
为以下代码写单测：
```
function pluck(arr) {
  if (arr.length == 0) return [];
  var evens = arr.filter(x => x % 2 == 0);
  if (evens.length == 0) return [];
  return [Math.min(...evens), arr.indexOf(Math.min(...evens))];
}
```


prompt:
为以下代码写单测：
```
function search(lst) {
  var frq = new Array(Math.max(...lst) + 1).fill(0);
  for (const i of lst)
    frq[i] += 1;
  var ans = -1;
  for (let i = 1; i < frq.length; i++)
    if (frq[i] >= i)
      ans = i;
  return ans;
}
```


prompt:
为以下代码写单测：
```
function strangeSortList(lst) {
  var res = [], sw = true;
  while (lst.length) {
    res.push(sw ? Math.min(...lst) : Math.max(...lst));
    lst.splice(lst.indexOf(res.at(-1)), 1);
    sw = !sw;
  }
  return res;
}
```


prompt:
为以下代码写单测：
```
function triangleArea(a, b, c) {
  if (a + b <= c || a + c <= b || b + c <= a)
    return -1;
  var s = (a + b + c) / 2;
  var area = Math.pow(s * (s - a) * (s - b) * (s - c), 0.5);
  area = area.toFixed(2);
  return area;
}
```


prompt:
为以下代码写单测：
```
function willItFly(q, w) {
  if (q.reduce(((prev, item) => prev + item), 0) > w)
    return false;
  var i = 0, j = q.length - 1;
  while (i < j) {
    if (q[i] != q[j])
      return false;
    i++;
    j--;
  }
  return true;
}
```


prompt:
为以下代码写单测：
```
function smallestChange(arr) {
  var ans = 0;
  for (let i = 0; i < Math.floor(arr.length / 2); i++)
    if (arr[i] != arr.at(-i - 1))
      ans++;
  return ans;
}
```


prompt:
为以下代码写单测：
```
function totalMatch(lst1, lst2) {
  var l1 = lst1.reduce(((prev, item) => prev + item.length), 0);
  var l2 = lst2.reduce(((prev, item) => prev + item.length), 0);
  if (l1 <= l2)
    return lst1;
  else
    return lst2;
}
```


prompt:
为以下代码写单测：
```
function isMultiplyPrime(a) {
  var isPrime = function (n) {
    for (let j = 2; j < n; j++)
      if (n % j == 0)
        return false;
    return true;
  }

  for (let i = 2; i < 101; i++) {
    if (!isPrime(i)) continue;
    for (let j = 2; j < 101; j++) {
      if (!isPrime(j)) continue;
      for (let k = 2; k < 101; k++) {
        if (!isPrime(k)) continue;
        if (i*j*k == a)
          return true;
      }
    }
  }
  return false;
}
```


prompt:
为以下代码写单测：
```
function isSimplePower(x, n) {
  if (n == 1)
    return (x == 1);
  var power = 1;
  while (power < x)
    power = power * n;
  return (power == x);
}
```


prompt:
为以下代码写单测：
```
function iscube(a) {
  a = Math.abs(a);
  return (Math.pow(Math.round(Math.pow(a, 1.0 / 3.0)), 3) == a);
}
```


prompt:
为以下代码写单测：
```
function hexKey(num) {
  var primes = "2357BD",
      total = 0;
  for (let i = 0; i < num.length; i++)
    if (primes.includes(num[i]))
      total++;
  return total;
}
```


prompt:
为以下代码写单测：
```
function decimalToBinary(decimal) {
  return "db" + decimal.toString(2) + "db";
}
```


prompt:
为以下代码写单测：
```
function isHappy(s) {
  if (s.length < 3)
    return false;
  for (let i = 0; i < s.length - 2; i++)
    if (s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2])
      return false;
  return true;
}
```


prompt:
为以下代码写单测：
```
function numericalLetterGrade(grades) {
  let letter_grade = []
  for (let i = 0, len = grades.length; i < len; i++) {
    let gpa = grades[i]
    if (gpa == 4.0) {
      letter_grade.push('A+')
    } else if (gpa > 3.7) {
      letter_grade.push('A')
    } else if (gpa > 3.3) {
      letter_grade.push('A-')
    } else if (gpa > 3.0) {
      letter_grade.push('B+')
    } else if (gpa > 2.7) {
      letter_grade.push('B')
    } else if (gpa > 2.3) {
      letter_grade.push('B-')
    } else if (gpa > 2.0) {
      letter_grade.push('C+')
    } else if (gpa > 1.7) {
      letter_grade.push('C')
    } else if (gpa > 1.3) {
      letter_grade.push('C-')
    } else if (gpa > 1.0) {
      letter_grade.push('D+')
    } else if (gpa > 0.7) {
      letter_grade.push('D')
    } else if (gpa > 0.0) {
      letter_grade.push('D-')
    } else {
      letter_grade.push('E')
    }
  }
  return letter_grade
}
```


prompt:
为以下代码写单测：
```
function primeLength(string) {
  let len = string.length
  if (len == 1 || len == 0) { return false }
  for (let i = 2; i * i <= len; i++) {
    if (len % i == 0) { return false }
  }
  return true
}
```


prompt:
为以下代码写单测：
```
function startsOneEnds(n) {
  if (n == 1) { return 1 }
  let t = 18
  for (let i = 2; i < n; i++) {
    t = t * 10
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function solve(N) {
  let t = 0
  while (N > 0) {
    t += N % 10
    N = (N - N % 10) / 10
  }
  return t.toString(2)
}
```


prompt:
为以下代码写单测：
```
function add(lst) {
  let t = 0
  for (let i = 1; i < lst.length; i += 2) {
    if (lst[i] % 2 == 0) {
      t += lst[i]
    }
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function antiShuffle(s) {
  let arr = s.split(/\s/)
  for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr[i].length; j++) {
      let ind = j
      for (let k = j + 1; k < arr[i].length; k++) {
        if (arr[i][k].charCodeAt() < arr[i][ind].charCodeAt()) {
          ind = k
        }
      }
      if (ind > j) {
        arr[i] = arr[i].slice(0, j) + arr[i][ind] + arr[i].slice(j + 1, ind) + arr[i][j] + arr[i].slice(ind + 1, arr[i].length)
      }
    }
  }
  let t = ''
  for (let i = 0; i < arr.length; i++) {
    if (i > 0) {
      t = t + ' '
    }
    t = t + arr[i]
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function getRow(lst, x) {
  let t = []
  for (let i = 0; i < lst.length; i++) {
    for (let j = lst[i].length - 1; j >= 0; j--) {
      if (lst[i][j] == x) {
        t.push((i, j))
      }
    }
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function sortArray(array) {
  let arr = array
  let tot = arr[0] + arr[arr.length-1]
  for (let j = 0; j < arr.length; j++) {
    let ind = j
    for (let k = j + 1; k < arr.length; k++) {
      if ((tot % 2 == 1 && arr[k] < arr[ind]) || (tot % 2 == 0 && arr[k] > arr[ind])) {
        ind = k
      }
    }
    let tmp = arr[j]
    arr[j] = arr[ind]
    arr[ind] = tmp
  }
  return arr
}
```


prompt:
为以下代码写单测：
```
function encrypt(s) {
  let t = ''
  for (let i = 0; i < s.length; i++) {
    let p = s[i].charCodeAt() + 4
    if (p > 122) { p -= 26 }
    t += String.fromCharCode(p)
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function nextSmallest(lst) {
  let arr = lst
  for (let j = 0; j < arr.length; j++) {
    let ind = j
    for (let k = j + 1; k < arr.length; k++) {
      if (arr[k] < arr[ind]) {
        ind = k
      }
    }
    let tmp = arr[j]
    arr[j] = arr[ind]
    arr[ind] = tmp
  }
  let smallest = arr[0]
  let pt = 1
  while(pt<arr.length){
    if(arr[pt]>smallest){
      return arr[pt]
    }
    pt++
  }
  return null
}
```


prompt:
为以下代码写单测：
```
function isBored(S) {
  let t = 0
  if (S[0] == 'I' && S[1] == ' ') { t = 1 }
  for (let i = 0; i < S.length; i++) {
    if (S[i] == '.' || S[i] == '!' || S[i] == '?') {
      if (S[i + 1] == ' ' && S[i + 2] == 'I' && S[i + 3] == ' ') {
        t++
      }
    }
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function anyInt(x, y, z) {
  if (x % 1 === 0 && y % 1 === 0 && z % 1 === 0 && (x + y === z || x + z === y || x === y + z)) {
    return true
  }
  return false
}
```


prompt:
为以下代码写单测：
```
function encode(message) {
  let t = ''
  for (let i = 0; i < message.length; i++) {
    let p = message[i].charCodeAt()
    if (p > 96) { p -= 32 }
    else if (p!=32 && p < 96) { p += 32 }
    if (p == 65 || p == 97 || p == 69 || p == 101 || p == 73 || p == 105 || p == 79 || p == 111 || p == 85 || p == 117) { p += 2 }
    t += String.fromCharCode(p)
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function skjkasdkd(lst) {
  let t = 0
  for (let i = 0; i < lst.length; i++) {
    let p = 1
    for (let j = 2; j * j <= lst[i]; j++) {
      if (lst[i] % j == 0) { p = 0; break }
    }
    if (p == 1 && lst[i] > t) { t = lst[i] }
  }
  let k = 0
  while (t != 0) {
    k += t % 10
    t = (t - t % 10) / 10
  }
  return k
}
```


prompt:
为以下代码写单测：
```
function checkDictCase(dict) {
  let c = 0
  let lo = 1
  let hi = 1
  for (let key in dict) {
    c++
    for (let i = 0; i < key.length; i++) {
      if (key[i].charCodeAt() < 65 || key[i].charCodeAt() > 90) { hi = 0 }
      if (key[i].charCodeAt() < 97 || key[i].charCodeAt() > 122) { lo = 0 }
    }
  }
  if ((lo == 0 && hi == 0) || c == 0) { return false }
  return true
}
```


prompt:
为以下代码写单测：
```
function countUpTo(n) {
  let t = []
  for (let i = 2; i < n; i++) {
    let p = 1
    for (let j = 2; j * j <= i; j++) {
      if (i % j == 0) { p = 0; break }
    }
    if (p == 1) { t.push(i) }
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function multiply(a, b) {
  if (a < 0) { a = -a }
  if (b < 0) { b = -b }
  return (a % 10) * (b % 10)
}
```


prompt:
为以下代码写单测：
```
function countUpper(s) {
  let p = 0
  for (let i = 0; i < s.length; i += 2) {
    if (s[i] == 'A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O' || s[i] == 'U') { p++ }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function closestInteger(value) {
  value = Number(value)
  let t = value % 1
  if (t < 0.5 && t > -0.5) { value -= t }
  else { value += t }
  return value
}
```


prompt:
为以下代码写单测：
```
function makeAPile(n) {
  let t = []
  for (let i = n; i < n * 3; i += 2) {
    t.push(i)
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function wordsString(s) {
  let t = ''
  let p = []
  let k = 0
  for (let i = 0; i < s.length; i++) {
    if (s[i] == ' ' || s[i] == ',') {
      if (k == 0) {
        k = 1;
        p.push(t);
        t = '';
      }
    }
    else {
      k = 0;
      t += s[i]
    }
  }
  if (t != '') {
    p.push(t);
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function chooseNum(x, y) {
  for (let i = y; i >= x; i--) {
    if (i % 2 == 0) {return i }
  }
  return -1
}
```


prompt:
为以下代码写单测：
```
function roundedAvg(n, m) {
  if (n > m) { return -1 }
  let k = (n + m) / 2
  if (k % 1 != 0) { k = (n + m + 1) / 2 }
  return '0b' + k.toString(2)
}
```


prompt:
为以下代码写单测：
```
function uniqueDigits(x) {
  let p = []
  for (let i = 0; i < x.length; i++) {
    let h = x[i]
    let boo = 1
    while (h > 0) {
      let r = h % 10
      if (r % 2 == 0) {
        boo = 0;
        break;
      }
      h = (h - r) / 10
    }
    if (boo) {
      p.push(x[i])
    }
  }
  for (let j = 0; j < p.length; j++) {
    let ind = j
    for (let k = j + 1; k < p.length; k++) {
      if (p[k] < p[ind]) {
        ind = k
      }
    }
    if (ind > j) {
      let tmp = p[j]
      p[j] = p[ind]
      p[ind] = tmp
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function byLength(arr) {
  p = []
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] > 0 && arr[i] < 10) { p.push(arr[i]) }
  }
  for (let j = 0; j < p.length; j++) {
    let ind = j
    for (let k = j + 1; k < p.length; k++) {
      if (p[k] > p[ind]) {
        ind = k
      }
    }
    if (ind > j) {
      let tmp = p[j]
      p[j] = p[ind]
      p[ind] = tmp
    }
  }
  let l = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine']
  let t = []
  for (let j = 0; j < p.length; j++) {
    t.push(l[p[j]-1])
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function f(n) {
  let f = 1
  let p = 0
  let k = []
  for (let i = 1; i <= n; i++) {
    p += i;
    f *= i;
    if (i % 2 == 0) { k.push(f) }
    else { k.push(p) }
  }
  return k
}
```


prompt:
为以下代码写单测：
```
function evenOddPalindrome(n) {
  let e = 0
  let o = 0
  for (let i = 1; i <= n; i++) {
    let k = i.toString()
    let p = 1
    for (let j = 0; j < k.length; j++) {
      if (k[j] != k[k.length - j - 1]) {
        p = 0;
        break;
      }
    }
    if (p == 1) {
      if (k % 2 == 0) { e++ }
      else { o++ }
    }
  }
  return (e, o)
}
```


prompt:
为以下代码写单测：
```
function countNums(arr) {
  let p = 0
  for (let i = 0; i < arr.length; i++) {
    let h = arr[i]
    if (h > 0) {
      p++;
      continue;
    }
    let k = 0
    h = -h
    while (h >= 10) {
      k += h % 10;
      h = (h - h % 10) / 10;
    }
    k -= h;
    if (k > 0) { p++ }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function moveOneBall(arr) {
  if (arr.length == 0) { return true }
  let k = 0
  let len = arr.length
  for (let i = 0; i < len; i++) {
    let t = 1;
    for (let j = 1; j < len; j++) {
      if (arr[j] < arr[j - 1]) {
        t = 0;
        break;
      }
    }
    if (t == 1) {
      k = 1;
      break;
    }
    arr.push(arr[0]);
    arr.shift()
  }
  if (k == 1) { return true }
  return false
}
```


prompt:
为以下代码写单测：
```
function exchange(lst1, lst2) {
  let k = lst1.length
  let t = 0
  for (let i = 0; i < lst1.length; i++) {
    if (lst1[i] % 2 == 0) { t++ }
  }
  for (let i = 0; i < lst2.length; i++) {
    if (lst2[i] % 2 == 0) { t++ }
  }
  if (t >= k) { return 'YES' }
  return 'NO'
}
```


prompt:
为以下代码写单测：
```
function histogram(test) {
  let d = {}
  let t = test.split(/\s/)
  if (test == '') { t = [] }
  for (m in t) {
    if (t[m] in d) {
      d[t[m]]++
    }
    else {
      d[t[m]] = 1
    }
  }
  s = Object.keys(d).sort(function (a, b) { return - d[a] + d[b]; });
  if (s.length == 0) { return {} }
  let g = d[s[0]]
  let l = {}
  for (let ss=0; ss<s.length; ss++) {
    if (d[s[ss]] == g) {
      l[s[ss]] = d[s[ss]]
    }
  }
  return l
}
```


prompt:
为以下代码写单测：
```
function reverseDelete(s, c) {
  let t = ''
  for (let i = 0; i < s.length; i++) {
    let y = 1
    for (let j = 0; j < c.length; j++) {
      if (s[i] == c[j]) {
        y = 0
      }
    }
    if (y == 1) {
      t += s[i]
    }
  }
  let z = 1
  for (let i = 0; i < t.length; i++) {
    if (t[i] != t[t.length - i - 1]) {
      z = 0
    }
  }
  if (z == 0) {
    return (z, false)
  }
  return (z, true)
}
```


prompt:
为以下代码写单测：
```
function oddCount(lst) {
  let d = []
  for (let i = 0; i < lst.length; i++) {
    let p = 0;
    let h = lst[i].length
    for (let j = 0; j < h; j++) {
      if (lst[i][j].charCodeAt() % 2 == 1) { p++ }
    }
    p = p.toString()
    d.push('the number of odd elements ' + p + 'n the str' + p + 'ng ' + p + ' of the ' + p + 'nput.')
  }
  return d
}
```


prompt:
为以下代码写单测：
```
function minSubArraySum(nums) {
  let min = nums[0]
  for (let i = 0; i < nums.length; i++) {
    for (let j = i + 1; j <= nums.length; j++) {
      let s = 0;
      for (let k = i; k < j; k++) {
        s += nums[k]
      }
      if (s < min) { min = s }
    }
  }
  return min
}
```


prompt:
为以下代码写单测：
```
function maxFill(grid, capacity) {
  let p = 0
  for (let i = 0; i < grid.length; i++) {
    let m = 0
    for (let j = 0; j < grid[i].length; j++) {
      if (grid[i][j] == 1) { m++ }
    }
    while (m > 0) {
      m -= capacity;
      p++;
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function sortArray(arr) {
  let p = arr
  for (let j = 0; j < p.length; j++) {
    let ind = j
    for (let k = j + 1; k < p.length; k++) {
      let w1 = p[ind].toString(2)
      let f1 = 0
      for (let u = 0; u < w1.length; u++) {
        if (w1[u] == '1') { f1++ }
      }
      let w2 = p[k].toString(2)
      let f2 = 0
      for (let u = 0; u < w2.length; u++) {
        if (w2[u] == '1') { f2++ }
      }
      if (f2 < f1 || (f1 == f2 && p[k] < p[ind])) {
        ind = k
      }
    }
    if (ind > j) {
      let tmp = p[j]
      p[j] = p[ind]
      p[ind] = tmp
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function selectWords(s, n) {
  let t = s.split(/\s/)
  if (s == '') { return [] }
  let k = []
  for (let i = 0; i < t.length; i++) {
    let l = 0
    for (let j = 0; j < t[i].length; j++) {
      if (t[i][j] != 'a' && t[i][j] != 'e' && t[i][j] != 'i' && t[i][j] != 'o' && t[i][j] != 'u' && t[i][j] != 'A' &&
        t[i][j] != 'U' && t[i][j] != 'O' && t[i][j] != 'I' && t[i][j] != 'E') {
        l++
      }
    }
    if (l == n) { k.push(t[i]) }
  }
  return k
}
```


prompt:
为以下代码写单测：
```
function getClosestVowel(word) {
  for (let i = word.length - 2; i > 0; i--) {
    if (
      !(word[i] != 'a' && word[i] != 'e' && word[i] != 'i' && word[i] != 'o' && word[i] != 'u' && word[i] != 'A' &&
        word[i] != 'U' && word[i] != 'O' && word[i] != 'I' && word[i] != 'E')
      &&
      (word[i + 1] != 'a' && word[i + 1] != 'e' && word[i + 1] != 'i' && word[i + 1] != 'o' && word[i + 1] != 'u' && word[i + 1] != 'A' &&
        word[i + 1] != 'U' && word[i + 1] != 'O' && word[i + 1] != 'I' && word[i + 1] != 'E')
      &&
      (word[i - 1] != 'a' && word[i - 1] != 'e' && word[i - 1] != 'i' && word[i - 1] != 'o' && word[i - 1] != 'u' && word[i - 1] != 'A' &&
        word[i - 1] != 'U' && word[i - 1] != 'O' && word[i - 1] != 'I' && word[i - 1] != 'E')
    ) {
      return word[i]
    }
  }
  return ''
}
```


prompt:
为以下代码写单测：
```
function matchParens(lst) {
  let w1 = lst[0] + lst[1]
  let y = 0
  let u = 1
  for (let i = 0; i < w1.length; i++) {
    if (w1[i] == '(') { y++ }
    else { y-- }
    if (y < 0) {
      u = 0;
      break;
    }
  }
  if (u == 1 && y == 0) { return 'Yes' }
  w1 = lst[1] + lst[0]
  y = 0
  u = 1
  for (let i = 0; i < w1.length; i++) {
    if (w1[i] == '(') { y++ }
    else { y-- }
    if (y < 0) {
      u = 0;
      break;
    }
  }
  if (u == 1 && y == 0) { return 'Yes' }
  return 'No'
}
```


prompt:
为以下代码写单测：
```
function maximum(arr, k) {
  let p = arr
  for (let j = 0; j < p.length; j++) {
    let ind = j
    for (let k = j + 1; k < p.length; k++) {
      if (p[k] < p[ind]) {
        ind = k
      }
    }
    if (ind > j) {
      let tmp = p[j]
      p[j] = p[ind]
      p[ind] = tmp
    }
  }
  if (k == 0) { return [] }
  return p.slice(-k)
}
```


prompt:
为以下代码写单测：
```
function solution(lst) {
  let p = 0
  for (let i = 0; i < lst.length; i += 2) {
    if (lst[i] % 2 == 1) {
      p += lst[i]
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function addElements(arr, k) {
  let p = 0
  for (let i = 0; i < k; i++) {
    if (arr[i] < 100 && arr[i] > -100) { p += arr[i] }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function getOddCollatz(n) {
  let p = []
  let t = n
  while (1) {
    let u = 0
    for (let i = 0; i < p.length; i++) {
      if (t == p[i]) {
        u = 1
        break;
      }
    }
    if (u == 1) { break }
    if (t % 2 == 1) { p.push(t); t = 3 * t + 1 }
    else { t = t / 2 }
  }
  for (let j = 0; j < p.length; j++) {
    let ind = j
    for (let k = j + 1; k < p.length; k++) {
      if (p[k] < p[ind]) {
        ind = k
      }
    }
    if (ind > j) {
      let tmp = p[j]
      p[j] = p[ind]
      p[ind] = tmp
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function validDate(date) {
  let t = date.split(/-/)
  if (t.length != 3) { return false }
  if (t[0] < 1 || t[0] > 12 || t[1] < 1) { return false }
  if (t[0] == 2 && t[1] > 29) { return false }
  if ((t[0] == 1 || t[0] == 3 || t[0] == 5 || t[0] == 7 || t[0] == 8 || t[0] == 10 || t[0] == 12) && t[1] > 31) { return false }
  if ((t[0] == 4 || t[0] == 6 || t[0] == 9 || t[0] == 11) && t[1] > 30) { return false }
  return true
}
```


prompt:
为以下代码写单测：
```
function splitWords(txt) {
  let t = txt.split(/\s/)
  if (t.length > 1) {
    return t
  } else {
    t = txt.split(/,/)
    if (t.length > 1) {
      return t
    } else {
      let p = 0
      for (let i = 0; i < txt.length; i++) {
        let m = txt[i].charCodeAt()
        if (m >= 97 && m <= 122 && m % 2 == 0) {
          p++
        }
      }
      return p
    }
  }
}
```


prompt:
为以下代码写单测：
```
function isSorted(lst) {
  if (lst.length == 0) { return true }
  let dup = 1
  let pre = lst[0]
  for (let i = 1; i < lst.length; i++) {
    if (lst[i] < pre) { return false }
    if (lst[i] == pre) {
      dup += 1;
      if (dup == 3) { return false }
    } else {
      pre = lst[i]
      dup = 1
    }
  }
  return true
}
```


prompt:
为以下代码写单测：
```
function intersection(interval1, interval2) {
  let lo = interval1[0]
  if (interval2[0] > lo) { lo = interval2[0] }
  let hi = interval1[1]
  if (interval2[1] < hi) { hi = interval2[1] }
  let len = 0
  if (hi > lo) { len = hi - lo }
  if (len == 1 || len == 0) { return 'NO' }
  for (let i = 2; i * i <= len; i++) {
    if (len % i == 0) { return 'NO' }
  }
  return 'YES'
}
```


prompt:
为以下代码写单测：
```
function prodSigns(arr) {
  if (arr.length == 0) { return null }
  let n = 1
  let s = 0
  for (let i = 0; i < arr.length; i++) {
    s += arr[i]
    if (arr[i] == 0) { return 0 }
    if (arr[i] < 0) { n = -n; s -= 2 * arr[i] }
  }
  return s * n
}
```


prompt:
为以下代码写单测：
```
function minPath(grid, k) {
  let m = 0
  let n = 0
  for (let i = 0; i < grid.length; i++) {
    for (let j = 0; j < grid.length; j++) {
      if (grid[i][j] == 1) {
        m = i;
        n = j;
        break;
      }
    }
  }
  let min = grid.length * grid.length
  if (m > 0 && grid[m - 1][n] < min) { min = grid[m - 1][n] }
  if (n > 0 && grid[m][n - 1] < min) { min = grid[m][n - 1] }
  if (m < grid.length - 1 && grid[m + 1][n] < min) { min = grid[m + 1][n] }
  if (n < grid.length - 1 && grid[m][n + 1] < min) { min = grid[m][n + 1] }
  let p = []
  for (let i = 0; i < k; i++) {
    if (i % 2 == 0) { p.push(1) }
    else { p.push(min) }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function tri(n) {
  if (n == 0) { return [1] }
  if (n == 1) { return [1, 3] }
  let p = [1, 3]
  for (let i = 2; i <= n; i++) {
    if (i % 2 == 0) {
      p.push(1 + i / 2)
    }
    else {
      p.push(p[i - 2] + p[i - 1] + 1 + (i + 1) / 2)
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function digits(n) {
  let p = 1
  let k = 1
  while (n > 0) {
    let y = n % 10
    if (y % 2 == 1) {
      p *= y; k = 0;
    }
    n = (n - n % 10) / 10
  }
  if (k == 0) { return p }
  return 0
}
```


prompt:
为以下代码写单测：
```
function isNested(string) {
  let opening_bracket_index = []
  let closing_bracket_index1 = []
  for (let i = 0; i < string.length; i++) {
    if (string[i] == '[') {
      opening_bracket_index.push(i)
    }
    else {
      closing_bracket_index1.push(i)
    }
  }
  let closing_bracket_index = []
  for (let i = 0; i < closing_bracket_index1.length; i++) {
    closing_bracket_index.push(closing_bracket_index1[closing_bracket_index1.length - i - 1])
  }
  let cnt = 0
  let i = 0
  let l = closing_bracket_index.length
  for (let k = 0; k < opening_bracket_index.length; k++) {
    if (i < l && opening_bracket_index[k] < closing_bracket_index[i]) {
      cnt += 1;
      i += 1;
    }
  }
  return cnt >= 2
}
```


prompt:
为以下代码写单测：
```
function sumSquares(lst) {
  let p = 0
  for (let i = 0; i < lst.length; i++) {
    let y = lst[i]
    if (y % 1 != 0) {
      if (y > 0) { y = y - y % 1 + 1 }
      else { y = -y; y = y - y % 1 }
    }
    p += y * y
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function checkIfLastCharIsALetter(txt) {
  let len = txt.length
  if (len == 0) { return false }
  let y = txt[len - 1].charCodeAt()
  if (len == 1) {
    if ((y >= 65 && y <= 90) || (y >= 97 && y <= 122)) { return true }
    return false
  }
  if (txt[len - 2] == ' ' && ((y >= 65 && y <= 90) || (y >= 97 && y <= 122))) { return true }
  return false
}
```


prompt:
为以下代码写单测：
```
function canArrange(arr) {
  if (arr.length == 0) { return -1 }
  for (let i = arr.length - 1; i > 0; i--) {
    if (arr[i] < arr[i - 1]) { return i }
  }
  return -1
}
```


prompt:
为以下代码写单测：
```
function largestSmallestIntegers(lst) {
  let a = Infinity
  let b = -Infinity
  for (let i = 0; i < lst.length; i++) {
    if (lst[i] > 0 && lst[i] < a) { a = lst[i] }
    if (lst[i] < 0 && lst[i] > b) { b = lst[i] }
  }
  if (a == Infinity) { a = null }
  if (b == -Infinity) { b = null }
  return (b, a)
}
```


prompt:
为以下代码写单测：
```
function compareOne(a, b) {
  let aa = Number(a)
  if (typeof a == 'string') { aa = Number(a.replace(',', '.')) }
  let bb = Number(b)
  if (typeof b == 'string') { bb = Number(b.replace(',', '.')) }
  if (aa > bb) { return a }
  if (aa < bb) { return b }
  return null
}
```


prompt:
为以下代码写单测：
```
function isEqualToSumEven(n) {
  return (n >= 8 && n % 2 == 0)
}
```


prompt:
为以下代码写单测：
```
function specialFactorial(n) {
  let p = 1;
  let t = 1;
  while (n > 1) {
    let y = p;
    while (y > 0) {
      y--;
      t *= n;
    }
    p++;
    n--;
  }
  return t
}
```


prompt:
为以下代码写单测：
```
function fixSpaces(text) {
  let t = ''
  let c = 0
  for (let i = 0; i < text.length; i++) {
    if (text[i] == ' ') { c++ }
    else if (c > 0) {
      if (c == 1) { t += '_' }
      if (c == 2) { t += '__' }
      if (c > 2) { t += '-' }
      t += text[i]
      c = 0;
    } else {
      t += text[i]
    }
  }
  if (c == 1) { t += '_' }
  if (c == 2) { t += '__' }
  if (c > 2) { t += '-' }
  return t
}
```


prompt:
为以下代码写单测：
```
function fileNameCheck(file_name) {
  let t = file_name.split(/\./)
  if (t.length != 2) { return 'No' }
  if (t[1] != 'txt' && t[1] != 'dll' && t[1] != 'exe') { return 'No' }
  if (t[0] == '') { return 'No' }
  let a = t[0][0].charCodeAt()
  if (!((a >= 65 && a <= 90) || (a >= 97 && a <= 122))) { return 'No' }
  let y = 0
  for (let i = 1; i < t[0].length; i++) {
    if (t[0][i].charCodeAt() >= 48 && t[0][i].charCodeAt() <= 57) { y++ }
    if (y > 3) { return 'No' }
  }
  return 'Yes'
}
```


prompt:
为以下代码写单测：
```
function sumSquares(lst) {
  let y = 0
  for (let i = 0; i < lst.length; i++) {
    if (i % 3 == 0) { y += lst[i] * lst[i] }
    else if (i % 4 == 0) { y += lst[i] * lst[i] * lst[i] }
    else { y += lst[i] }
  }
  return y
}
```


prompt:
为以下代码写单测：
```
function wordsInSentence(sentence) {
  let t = sentence.split(/\s/)
  let p = ''
  for (let j = 0; j < t.length; j++) {
    let len = t[j].length;
    let u = 1
    if (len == 1 || len == 0) { continue }
    for (let i = 2; i * i <= len; i++) {
      if (len % i == 0) { u = 0 }
    }
    if (u == 0) { continue }
    if (p == '') { p += t[j] }
    else { p = p + ' ' + t[j] }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function simplify(x, n) {
  let a = x.split(/\//)
  let b = n.split(/\//)
  let m = Number(a[0]) * Number(b[0])
  let r = Number(a[1]) * Number(b[1])
  return m % r == 0
}
```


prompt:
为以下代码写单测：
```
function orderByPoints(nums) {
  let p = nums
  for (let j = p.length - 2; j >= 0; j--) {
    for (let k = 0; k <= j; k++) {
      let m = 0
      let n = 0
      let h = p[k]
      let d = p[k + 1]
      let y = 1
      let u = 1
      if (h < 0) { y = -1; h = -h; }
      if (d < 0) { u = -1; d = -d; }
      while (h >= 10) {
        m += h % 10;
        h = (h - h % 10) / 10;
      }
      m += y * h
      while (d >= 10) {
        n += d % 10;
        d = (d - d % 10) / 10;
      }
      n += u * d
      if (m > n) {
        let tmp = p[k]
        p[k] = p[k + 1]
        p[k + 1] = tmp
      }
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function specialFilter(nums) {
  let p = 0
  for (let i = 0; i < nums.length; i++) {
    if (nums[i] < 10) { continue }
    let y = nums[i].toString()
    if (Number(y[0]) % 2 == 1 && Number(y[y.length - 1]) % 2 == 1) {
      p++
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function getMaxTriples(n) {
  let y = []
  for (let i = 1; i <= n; i++) {
    y.push(i * i - i + 1)
  }
  let u = 0
  for (let i = 0; i < n - 2; i++) {
    for (let j = i + 1; j < n - 1; j++) {
      for (let k = j + 1; k < n; k++) {
        if ((y[i] + y[j] + y[k]) % 3 == 0) { u++ }
      }
    }
  }
  return u
}
```


prompt:
为以下代码写单测：
```
function bf(planet1, planet2) {
  let y = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']
  let u = []
  let lo = -1
  let hi = -1
  for (let i = 0; i < 8; i++) {
    if (y[i] == planet1) { lo = i }
  }
  for (let i = 0; i < 8; i++) {
    if (y[i] == planet2) { hi = i }
  }
  if (lo == -1 || hi == -1 || lo == hi) { return [] }
  if (lo > hi) {
    let tmp = lo;
    lo = hi;
    hi = tmp;
  }
  for (let i = lo + 1; i < hi; i++) {
    u.push(y[i])
  }
  return u
}
```


prompt:
为以下代码写单测：
```
function sortedListSum(lst) {
  let p = []
  for (let i = 0; i < lst.length; i++) {
    if (lst[i].length % 2 == 0) {
      p.push(lst[i])
    }
  }
  for (let j = p.length - 2; j >= 0; j--) {
    for (let k = 0; k <= j; k++) {
      let f = 0
      if (p[k].length > p[k + 1].length) { f = 1 }
      if (p[k].length == p[k + 1].length) {
        let r = p[k].length
        for (let l = 0; l < r; l++) {
          if (p[k][l].charCodeAt() > p[k + 1][l].charCodeAt()) {
            f = 1;
            break;
          }
          if (p[k][l].charCodeAt() < p[k + 1][l].charCodeAt()) {
            break;
          }
        }
      }
      if (f == 1) {
        let tmp = p[k]
        p[k] = p[k + 1]
        p[k + 1] = tmp
      }
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function xOrY(n, x, y) {
  let len = n
  if (len == 1 || len == 0) { return y }
  for (let i = 2; i * i <= len; i++) {
    if (len % i == 0) { return y }
  }
  return x
}
```


prompt:
为以下代码写单测：
```
function doubleTheDifference(lst) {
  let p = 0
  for (let i = 0; i < lst.length; i++) {
    if (lst[i] % 2 == 1 && lst[i] > 0) {
      p += lst[i] * lst[i]
    }
  }
  return p
}
```


prompt:
为以下代码写单测：
```
function compare(game, guess) {
  for (let i = 0; i < guess.length; i++) {
    game[i] -= guess[i]
 if (game[i]<0)
 game[i]=-game[i];  }
  return game
}
```


prompt:
为以下代码写单测：
```
function strongestExtension(class_name, extensions) {
  let u = 0
  let s = -Infinity
  for (let i = extensions.length - 1; i >= 0; i--) {
    let y = 0
    for (let j = 0; j < extensions[i].length; j++) {
      let k = extensions[i][j].charCodeAt()
      if (k >= 65 && k <= 90) { y += 1 }
      if (k >= 97 && k <= 122) { y -= 1 }
    }
    if (y >= s) {
      s = y;
      u = i;
    }
  }
  return class_name + '.' + extensions[u]
}
```


prompt:
为以下代码写单测：
```
function cycpatternCheck(a, b) {
  let l = b.length
  let pat = b + b
  for (let i = 0; i < a.length - l + 1; i++) {
    for (let j = 0; j < l + 1; j++) {
      let y = 1
      for (let k = 0; k < l; k++) {
        if (a[i + k] != pat[j + k]) { y = 0 }
      }
      if (y == 1) {
        return true
      }
    }
  }
  return false
}
```


prompt:
为以下代码写单测：
```
function evenOddCount(num) {
  let o = 0
  let e = 0
  if (num < 0) { num = -num }
  while (num > 0) {
    if (num % 2 == 0) { e++ }
    else { o++ }
    num = (num - num % 10) / 10
  }
  return (e, o)
}
```


prompt:
为以下代码写单测：
```
function intToMiniRoman(number) {
  let num = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
  let sym = ['i', 'iv', 'v', 'ix', 'x', 'xl', 'l', 'xc', 'c', 'cd', 'd', 'cm', 'm']
  let i = 12
  let res = ''
  while (number) {
    let div = (number - number % num[i]) / num[i]
    number = number % num[i]
    while (div) {
      res += sym[i]
      div -= 1
    }
    i -= 1
  }
  return res
}
```


prompt:
为以下代码写单测：
```
function rightAngleTriangle(a, b, c) {
  return (a * a + b * b == c * c || a * a == b * b + c * c || b * b == a * a + c * c)
}
```


prompt:
为以下代码写单测：
```
function findMax(words) {
  let s = -1
  let u = -1
  if (words.length == 0) { return '' }
  for (let i = 0; i < words.length; i++) {
    let p = 0
    for (let j = 0; j < words[i].length; j++) {
      let y = 1
      for (let k = 0; k < j; k++) {
        if (words[i][j] == words[i][k]) { y = 0 }
      }
      if (y == 1) { p++ }
    }
    if (p > s || (p == s && words[i] < words[u])) {
      u = i;
      s = p;
    }
  }
  return words[u]
}
```


prompt:
为以下代码写单测：
```
function eat(number, need, remaining) {
  if (need <= remaining) {
    return [need + number, remaining - need]
  }
  return [remaining + number, 0]
}
```


prompt:
为以下代码写单测：
```
function doAlgebra(operator, operand) {
  while (operator.length > 0) {
    let y = 0
    for (let i = operator.length - 1; i >= 0; i--) {
      if (operator[i] == '**') {
        let u = operand[i]
        while (operand[i + 1] > 1) {
          operand[i + 1]--;
          operand[i] *= u;
        }
        operand.splice(i + 1, 1)
        operator.splice(i, 1)
        y = 1;
        break;
      }
    }
    if (y == 1) { continue }
    for (let i = 0; i < operator.length; i++) {
      if (operator[i] == '*') {
        operand[i] *= operand[i + 1]
        operand.splice(i + 1, 1)
        operator.splice(i, 1)
        y = 1;
        break;
      }
      else if (operator[i] == '//') {
        operand[i] = (operand[i] - operand[i] % operand[i + 1]) / operand[i + 1]
        operand.splice(i + 1, 1)
        operator.splice(i, 1)
        y = 1;
        break;
      }
    }
    if (y == 1) { continue }
    for (let i = 0; i < operator.length; i++) {
      if (operator[i] == '+') {
        operand[i] += operand[i + 1]
        operand.splice(i + 1, 1)
        operator.splice(i, 1)
        y = 1;
        break;
      }
      else if (operator[i] == '-') {
        operand[i] -= operand[i + 1]
        operand.splice(i + 1, 1)
        operator.splice(i, 1)
        y = 1;
        break;
      }
    }
    if (y == 1) { continue }
  }
  return operand[0]
}
```


prompt:
为以下代码写单测：
```
function solve(s) {
  let t = 0
  let p = ''
  for (let i = 0; i < s.length; i++) {
    let y = s[i].charCodeAt()
    if (y >= 65 && y <= 90) {
      y += 32;
      t = 1;
    } else if (y >= 97 && y <= 122) {
      y -= 32;
      t = 1;
    }
    p += String.fromCharCode(y)
  }
  if (t == 1) { return p }
  let u = ''
  for (let i = 0; i < p.length; i++) {
    u += p[p.length - i - 1]
  }
  return u
}
```


prompt:
为以下代码写单测：
```
function stringToMd5(text) {
  if (text == '') { return null }
  var md5 = require('js-md5')
  return md5(text)
}
```


prompt:
为以下代码写单测：
```
function generateIntegers(a, b) {
  if (a > b) {
    let tmp = a;
    a = b;
    b = tmp;
  }
  let y = []
  for (let i = a; i <= b; i++) {
    if (i == 2 || i == 4 || i == 6 || i == 8) { y.push(i) }
  }
  return y
}
```