Prompt:
//It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you a list of GPAs for some students and you have to write
// a function that can output a list of letter grades using the following table:
// GPA       |    Letter grade
// 4.0                A+
// > 3.7                A
// > 3.3                A-
// > 3.0                B+
// > 2.7                B
// > 2.3                B-
// > 2.0                C+
// > 1.7                C
// > 1.3                C-
// > 1.0                D+
// > 0.7                D
// > 0.0                D-
// 0.0                E
// Example:
function numerical_letter_grade(grades){

const assert = require('node:assert');

function test() {
  let candidate = numerical_letter_grade;
  assert.deepEqual(candidate([4.0, 3, 1.7, 2, 3.5]),["A+", "B", "C-", "C", "A-"]);
  assert.deepEqual(candidate([1.2]),["D+"]);
  assert.deepEqual(candidate([0.5]),["D-"]);
  assert.deepEqual(candidate([0.0]),["E"]);
  assert.deepEqual(candidate([1.0, 0.3, 1.5, 2.8, 3.3]),["D", "D-", "C-", "B", "B+"]);
  assert.deepEqual(candidate([0.0, 0.7]),["E", "D-"]);
}

test();


Prompt:
//Write a function that takes a string and returns True if the string
// length is a prime number or False otherwise
// Examples
function prime_length(string){

const assert = require('node:assert');

function test() {
  let candidate = prime_length;
  assert.deepEqual(candidate("Hello"),true);
  assert.deepEqual(candidate("abcdcba"),true);
  assert.deepEqual(candidate("kittens"),true);
  assert.deepEqual(candidate("orange"),false);
  assert.deepEqual(candidate("wow"),true);
  assert.deepEqual(candidate("world"),true);
  assert.deepEqual(candidate("MadaM"),true);
  assert.deepEqual(candidate("Wow"),true);
  assert.deepEqual(candidate(""),false);
  assert.deepEqual(candidate("HI"),true);
  assert.deepEqual(candidate("go"),true);
  assert.deepEqual(candidate("gogo"),false);
  assert.deepEqual(candidate("aaaaaaaaaaaaaaa"),false);
  assert.deepEqual(candidate("Madam"),true);
  assert.deepEqual(candidate("M"),false);
  assert.deepEqual(candidate("0"),false);
}

test();


Prompt:
//Given a positive integer N, return the total sum of its digits in binary.
// Example
// Variables:
// @N integer
// Constraints: 0 ≤ N ≤ 10000.
// Output:
// a string of binary number
function solve(N){

const assert = require('node:assert');

function test() {
  let candidate = solve;
  assert.deepEqual(candidate(1000),"1");
  assert.deepEqual(candidate(150),"110");
  assert.deepEqual(candidate(147),"1100");
  assert.deepEqual(candidate(333),"1001");
  assert.deepEqual(candidate(963),"10010");
}

test();


Prompt:
//Given a non-empty list of integers lst. add the even elements that are at odd indices..
// Examples:
function add(lst){

const assert = require('node:assert');

function test() {
  let candidate = add;
  assert.deepEqual(candidate([4, 88]),88);
  assert.deepEqual(candidate([4, 5, 6, 7, 2, 122]),122);
  assert.deepEqual(candidate([4, 0, 6, 7]),0);
  assert.deepEqual(candidate([4, 4, 6, 8]),12);
}

test();


Prompt:
//Write a function that takes a string and returns an ordered version of it.
// Ordered version of string, is a string where all words (separated by space)
// are replaced by a new word where all the characters arranged in
// ascending order based on ascii value.
// Note: You should keep the order of words and blank spaces in the sentence.
// For example:
function anti_shuffle(s){

const assert = require('node:assert');

function test() {
  let candidate = anti_shuffle;
  assert.deepEqual(candidate("Hi"),"Hi");
  assert.deepEqual(candidate("hello"),"ehllo");
  assert.deepEqual(candidate("number"),"bemnru");
  assert.deepEqual(candidate("abcd"),"abcd");
  assert.deepEqual(candidate("Hello World!!!"),"Hello !!!Wdlor");
  assert.deepEqual(candidate(""),"");
  assert.deepEqual(candidate("Hi. My name is Mister Robot. How are you?"),".Hi My aemn is Meirst .Rboot How aer ?ouy");
}

test();


Prompt:
//You are given a 2 dimensional data, as a nested lists,
// which is similar to matrix, however, unlike matrices,
// each row may contain a different number of columns.
// Given lst, and integer x, find integers x in the list,
// and return list of tuples, [(x1, y1), (x2, y2) ...] such that
// each tuple is a coordinate - (row, columns), starting with 0.
// Sort coordinates initially by rows in ascending order.
// Also, sort coordinates of the row by columns in descending order.
// Examples:
function get_row(lst, x){


Prompt:
//Given an array of non-negative integers, return a copy of the given array after sorting,
// you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
// or sort it in descending order if the sum( first index value, last index value) is even.
// Note:
// * don't change the given array.
// Examples:
function sort_array(array){

const assert = require('node:assert');

function test() {
  let candidate = sort_array;
  assert.deepEqual(candidate([]),[]);
  assert.deepEqual(candidate([5]),[5]);
  assert.deepEqual(candidate([2, 4, 3, 0, 1, 5]),[0, 1, 2, 3, 4, 5]);
  assert.deepEqual(candidate([2, 4, 3, 0, 1, 5, 6]),[6, 5, 4, 3, 2, 1, 0]);
  assert.deepEqual(candidate([2, 1]),[1, 2]);
  assert.deepEqual(candidate([15, 42, 87, 32, 11, 0]),[0, 11, 15, 32, 42, 87]);
  assert.deepEqual(candidate([21, 14, 23, 11]),[23, 21, 14, 11]);
}

test();


Prompt:
//Create a function encrypt that takes a string as an argument and
// returns a string encrypted with the alphabet being rotated.
// The alphabet should be rotated in a manner such that the letters
// shift down by two multiplied to two places.
// For example:
function encrypt(s){

const assert = require('node:assert');

function test() {
  let candidate = encrypt;
  assert.deepEqual(candidate("hi"),"lm");
  assert.deepEqual(candidate("asdfghjkl"),"ewhjklnop");
  assert.deepEqual(candidate("gf"),"kj");
  assert.deepEqual(candidate("et"),"ix");
  assert.deepEqual(candidate("faewfawefaewg"),"jeiajeaijeiak");
  assert.deepEqual(candidate("hellomyfriend"),"lippsqcjvmirh");
  assert.deepEqual(candidate("dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh"),"hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl");
  assert.deepEqual(candidate("a"),"e");
}

test();


Prompt:
//For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
// Empty sum should be equal to 0 and empty product should be equal to 1.
function sum_product(numbers){

const assert = require('node:assert');

function test() {
  let candidate = sum_product;
  assert.deepEqual(candidate([]),[0, 1]);
  assert.deepEqual(candidate([1, 1, 1]),[3, 1]);
  assert.deepEqual(candidate([100, 0]),[100, 0]);
  assert.deepEqual(candidate([3, 5, 7]),[15, 105]);
  assert.deepEqual(candidate([10]),[10, 10]);
}

test();


Prompt:
//You are given a list of integers.
// Write a function next_smallest() that returns the 2nd smallest element of the list.
// Return None if there is no such element.
function next_smallest(lst){

const assert = require('node:assert');

function test() {
  let candidate = next_smallest;
  assert.deepEqual(candidate([1, 2, 3, 4, 5]),2);
  assert.deepEqual(candidate([5, 1, 4, 3, 2]),2);
  assert.deepEqual(candidate([]),undefined);
  assert.deepEqual(candidate([1, 1]),undefined);
  assert.deepEqual(candidate([1, 1, 1, 1, 0]),1);
  assert.deepEqual(candidate([1, 1]),undefined);
  assert.deepEqual(candidate([-35, 34, 12, -45]),-35);
}

test();


Prompt:
//You'll be given a string of words, and your task is to count the number
// of boredoms. A boredom is a sentence that starts with the word "I".
// Sentences are delimited by '.', '?' or '!'.
// For example:
function is_bored(S){

const assert = require('node:assert');

function test() {
  let candidate = is_bored;
  assert.deepEqual(candidate("Hello world"),0);
  assert.deepEqual(candidate("Is the sky blue?"),0);
  assert.deepEqual(candidate("I love It !"),1);
  assert.deepEqual(candidate("bIt"),0);
  assert.deepEqual(candidate("I feel good today. I will be productive. will kill It"),2);
  assert.deepEqual(candidate("You and I are going for a walk"),0);
}

test();


Prompt:
//Create a function that takes 3 numbers.
// Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
// Returns false in any other cases.
// Examples
function any_int(x, y, z){

const assert = require('node:assert');

function test() {
  let candidate = any_int;
  assert.deepEqual(candidate(2, 3, 1),true);
  assert.deepEqual(candidate(2.5, 2, 3),false);
  assert.deepEqual(candidate(1.5, 5, 3.5),false);
  assert.deepEqual(candidate(2, 6, 2),false);
  assert.deepEqual(candidate(4, 2, 2),true);
  assert.deepEqual(candidate(2.2, 2.2, 2.2),false);
  assert.deepEqual(candidate(-4, 6, 2),true);
  assert.deepEqual(candidate(2, 1, 1),true);
  assert.deepEqual(candidate(3, 4, 7),true);
  assert.deepEqual(candidate(3.0, 4, 7),false);
}

test();


Prompt:
//Write a function that takes a message, and encodes in such a
// way that it swaps case of all letters, replaces all vowels in
// the message with the letter that appears 2 places ahead of that
// vowel in the english alphabet.
// Assume only letters.
// Examples:
function encode(message){

const assert = require('node:assert');

function test() {
  let candidate = encode;
  assert.deepEqual(candidate("TEST"),"tgst");
  assert.deepEqual(candidate("Mudasir"),"mWDCSKR");
  assert.deepEqual(candidate("YES"),"ygs");
  assert.deepEqual(candidate("This is a message"),"tHKS KS C MGSSCGG");
  assert.deepEqual(candidate("I DoNt KnOw WhAt tO WrItE"),"k dQnT kNqW wHcT Tq wRkTg");
}

test();


Prompt:
//You are given a list of integers.
// You need to find the largest prime value and return the sum of its digits.
// Examples:
function skjkasdkd(lst){


Prompt:
//Given a dictionary, return True if all keys are strings in lower
// case or all keys are strings in upper case, else return False.
// The function should return False is the given dictionary is empty.
// Examples:
function check_dict_case(dict){

const assert = require('node:assert');

function test() {
  let candidate = check_dict_case;
  assert.deepEqual(candidate({"p": "pineapple", "b": "banana"}),true);
  assert.deepEqual(candidate({"p": "pineapple", "A": "banana", "B": "banana"}),false);
  assert.deepEqual(candidate({"p": "pineapple", "5": "banana", "a": "apple"}),false);
  assert.deepEqual(candidate({"Name": "John", "Age": "36", "City": "Houston"}),false);
  assert.deepEqual(candidate({"STATE": "NC", "ZIP": "12345"}),true);
  assert.deepEqual(candidate({"fruit": "Orange", "taste": "Sweet"}),true);
  assert.deepEqual(candidate({}),false);
}

test();


Prompt:
//Implement a function that takes an non-negative integer and returns an array of the first n
// integers that are prime numbers and less than n.
// for example:
function count_up_to(n){

const assert = require('node:assert');

function test() {
  let candidate = count_up_to;
  assert.deepEqual(candidate(5),[2, 3]);
  assert.deepEqual(candidate(6),[2, 3, 5]);
  assert.deepEqual(candidate(7),[2, 3, 5]);
  assert.deepEqual(candidate(10),[2, 3, 5, 7]);
  assert.deepEqual(candidate(0),[]);
  assert.deepEqual(candidate(22),[2, 3, 5, 7, 11, 13, 17, 19]);
  assert.deepEqual(candidate(1),[]);
  assert.deepEqual(candidate(18),[2, 3, 5, 7, 11, 13, 17]);
  assert.deepEqual(candidate(47),[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]);
  assert.deepEqual(candidate(101),[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]);
}

test();


Prompt:
//Complete the function that takes two integers and returns
// the product of their unit digits.
// Assume the input is always valid.
// Examples:
function multiply(a, b){

const assert = require('node:assert');

function test() {
  let candidate = multiply;
  assert.deepEqual(candidate(148, 412),16);
  assert.deepEqual(candidate(19, 28),72);
  assert.deepEqual(candidate(2020, 1851),0);
  assert.deepEqual(candidate(14, -15),20);
  assert.deepEqual(candidate(76, 67),42);
  assert.deepEqual(candidate(17, 27),49);
  assert.deepEqual(candidate(0, 1),0);
  assert.deepEqual(candidate(0, 0),0);
}

test();


Prompt:
//Given a string s, count the number of uppercase vowels in even indices.
// For example:
function count_upper(s){

const assert = require('node:assert');

function test() {
  let candidate = count_upper;
  assert.deepEqual(candidate("aBCdEf"),1);
  assert.deepEqual(candidate("abcdefg"),0);
  assert.deepEqual(candidate("dBBE"),0);
  assert.deepEqual(candidate("B"),0);
  assert.deepEqual(candidate("U"),1);
  assert.deepEqual(candidate(""),0);
  assert.deepEqual(candidate("EEEE"),2);
}

test();


Prompt:
//Create a function that takes a value (string) representing a number
// and returns the closest integer to it. If the number is equidistant
// from two integers, round it away from zero.
// Examples
// Note:
// Rounding away from zero means that if the given number is equidistant
// from two integers, the one you should return is the one that is the
// farthest from zero. For example closest_integer("14.5") should
// return 15 and closest_integer("-14.5") should return -15.
function closest_integer(value){

const assert = require('node:assert');

function test() {
  let candidate = closest_integer;
  assert.deepEqual(candidate("10"),10);
  assert.deepEqual(candidate("14.5"),15);
  assert.deepEqual(candidate("-15.5"),-16);
  assert.deepEqual(candidate("15.3"),15);
  assert.deepEqual(candidate("0"),0);
}

test();


Prompt:
//From a given list of integers, generate a list of rolling maximum element found until given moment
// in the sequence.
function rolling_max(numbers){

const assert = require('node:assert');

function test() {
  let candidate = rolling_max;
  assert.deepEqual(candidate([]),[]);
  assert.deepEqual(candidate([1, 2, 3, 4]),[1, 2, 3, 4]);
  assert.deepEqual(candidate([4, 3, 2, 1]),[4, 4, 4, 4]);
  assert.deepEqual(candidate([3, 2, 3, 100, 3]),[3, 3, 3, 100, 100]);
}

test();