Prompt:
import std.math;
/*
 Check if in given list of numbers, are any two numbers closer to each other than
given threshold.
*/
bool has_close_elements(float[] numbers, float threshold)


Prompt:
import std.math;
/*
Given a positive integer n, you have to make a pile of n levels of stones.
The first level has n stones.
The number of stones in the next level is:
    - the next odd number if n is odd.
    - the next even number if n is even.
Return the number of stones in each level in a list, where element at index
i represents the number of stones in the level (i+1).
Examples:
*/
long[] make_a_pile(long n)

unittest
{
    alias candidate = make_a_pile;

    assert(candidate(3L) == [3L, 5L, 7L]);
    assert(candidate(4L) == [4L, 6L, 8L, 10L]);
    assert(candidate(5L) == [5L, 7L, 9L, 11L, 13L]);
    assert(candidate(6L) == [6L, 8L, 10L, 12L, 14L, 16L]);
    assert(candidate(8L) == [8L, 10L, 12L, 14L, 16L, 18L, 20L, 22L]);
}
void main(){}


Prompt:
import std.math;
/*
You will be given a string of words separated by commas or spaces. Your task is
to split the string into words and return an array of the words.
For example:
*/
string[] words_string(string s)

unittest
{
    alias candidate = words_string;

    assert(candidate("Hi, my name is John") == ["Hi", "my", "name", "is", "John"]);
    assert(candidate("One, two, three, four, five, six") == ["One", "two", "three", "four", "five", "six"]);
    assert(candidate("Hi, my name") == ["Hi", "my", "name"]);
    assert(candidate("One,, two, three, four, five, six,") == ["One", "two", "three", "four", "five", "six"]);
    assert(candidate("") == []);
    assert(candidate("ahmed     , gamal") == ["ahmed", "gamal"]);
}
void main(){}


Prompt:
import std.math;
/*
This function takes two positive numbers x and y and returns the
biggest even integer number that is in the range [x, y] inclusive. If
there's no such number, then the function should return -1.
For example:
*/
long choose_num(long x, long y)

unittest
{
    alias candidate = choose_num;

    assert(candidate(12L, 15L) == 14L);
    assert(candidate(13L, 12L) == -1L);
    assert(candidate(33L, 12354L) == 12354L);
    assert(candidate(5234L, 5233L) == -1L);
    assert(candidate(6L, 29L) == 28L);
    assert(candidate(27L, 10L) == -1L);
    assert(candidate(7L, 7L) == -1L);
    assert(candidate(546L, 546L) == 546L);
}
void main(){}


Prompt:
import std.math;
/*
Given a list of positive integers x. return a sorted list of all
elements that hasn't any even digit.
Note: Returned list should be sorted in increasing order.
For example:
*/
long[] unique_digits(long[] x)


Prompt:
import std.math;
/*
Given an array of integers, sort the integers that are between 1 and 9 inclusive,
reverse the resulting array, and then replace each digit by its corresponding name from
"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
For example:
  If the array is empty, return an empty array:
  If the array has any strange number ignore it:
*/
string[] by_length(long[] arr)

unittest
{
    alias candidate = by_length;

    assert(candidate([2L, 1L, 1L, 4L, 5L, 8L, 2L, 3L]) == ["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"]);
    assert(candidate([]) == []);
    assert(candidate([1L, -1L, 55L]) == ["One"]);
    assert(candidate([1L, -1L, 3L, 2L]) == ["Three", "Two", "One"]);
    assert(candidate([9L, 4L, 8L]) == ["Nine", "Eight", "Four"]);
}
void main(){}


Prompt:
import std.math;
/*
 Implement the function f that takes n as a parameter,
and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
or the sum of numbers from 1 to i otherwise.
i starts from 1.
the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
Example:
*/
long[] f(long n)

unittest
{
    alias candidate = f;

    assert(candidate(5L) == [1L, 2L, 6L, 24L, 15L]);
    assert(candidate(7L) == [1L, 2L, 6L, 24L, 15L, 720L, 28L]);
    assert(candidate(1L) == [1L]);
    assert(candidate(3L) == [1L, 2L, 6L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a positive integer n, return a tuple that has the number of even and odd
integer palindromes that fall within the range(1, n), inclusive.
Example 1:
        Explanation:
    Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
Example 2:
        Explanation:
    Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
Note:
    1. 1 <= n <= 10^3
    2. returned tuple has the number of even and odd integer palindromes respectively.
*/
Tuple!(long, long) even_odd_palindrome(long n)

unittest
{
    alias candidate = even_odd_palindrome;

    assert(candidate(123L) == tuple(8L, 13L));
    assert(candidate(12L) == tuple(4L, 6L));
    assert(candidate(3L) == tuple(1L, 2L));
    assert(candidate(63L) == tuple(6L, 8L));
    assert(candidate(25L) == tuple(5L, 6L));
    assert(candidate(19L) == tuple(4L, 6L));
    assert(candidate(9L) == tuple(4L, 5L));
    assert(candidate(1L) == tuple(0L, 1L));
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function count_nums which takes an array of integers and returns
the number of elements which has a sum of digits > 0.
If a number is negative, then its first signed digit will be negative:
e.g. -123 has signed digits -1, 2, and 3.
*/
long count_nums(long[] arr)

unittest
{
    alias candidate = count_nums;

    assert(candidate([]) == 0L);
    assert(candidate([-1L, -2L, 0L]) == 0L);
    assert(candidate([1L, 1L, 2L, -2L, 3L, 4L, 5L]) == 6L);
    assert(candidate([1L, 6L, 9L, -6L, 0L, 1L, 5L]) == 5L);
    assert(candidate([1L, 100L, 98L, -7L, 1L, -1L]) == 4L);
    assert(candidate([12L, 23L, 34L, -45L, -56L, 0L]) == 5L);
    assert(candidate([0L, 1L]) == 1L);
    assert(candidate([1L]) == 1L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
numbers in the array will be randomly ordered. Your task is to determine if
it is possible to get an array sorted in non-decreasing order by performing
the following operation on the given array:
    You are allowed to perform right shift operation any number of times.
One right shift operation means shifting all elements of the array by one
position in the right direction. The last element of the array will be moved to
the starting position in the array i.e. 0th index.
If it is possible to obtain the sorted array by performing the above operation
then return True else return False.
If the given array is empty then return True.
Note: The given list is guaranteed to have unique elements.
For Example:
    Explanation: By performin 2 right shift operations, non-decreasing order can
             be achieved for the given array.
    Explanation:It is not possible to get non-decreasing order for the given
            array by performing any number of right shift operations.
*/
bool move_one_ball(long[] arr)

unittest
{
    alias candidate = move_one_ball;

    assert(candidate([3L, 4L, 5L, 1L, 2L]) == true);
    assert(candidate([3L, 5L, 10L, 1L, 2L]) == true);
    assert(candidate([4L, 3L, 1L, 2L]) == false);
    assert(candidate([3L, 5L, 4L, 1L, 2L]) == false);
    assert(candidate([]) == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Find the shortest palindrome that begins with a supplied string.
Algorithm idea is simple:
- Find the longest postfix of supplied string that is a palindrome.
- Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
*/
string make_palindrome(string string)

unittest
{
    alias candidate = make_palindrome;

    assert(candidate("") == "");
    assert(candidate("x") == "x");
    assert(candidate("xyz") == "xyzyx");
    assert(candidate("xyx") == "xyx");
    assert(candidate("jerry") == "jerryrrej");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
In this problem, you will implement a function that takes two lists of numbers,
and determines whether it is possible to perform an exchange of elements
between them to make lst1 a list of only even numbers.
There is no limit on the number of exchanged elements between lst1 and lst2.
If it is possible to exchange elements between the lst1 and lst2 to make
all the elements of lst1 to be even, return "YES".
Otherwise, return "NO".
For example:
        It is assumed that the input lists will be non-empty.
*/
string exchange(long[] lst1, long[] lst2)

unittest
{
    alias candidate = exchange;

    assert(candidate([1L, 2L, 3L, 4L], [1L, 2L, 3L, 4L]) == "YES");
    assert(candidate([1L, 2L, 3L, 4L], [1L, 5L, 3L, 4L]) == "NO");
    assert(candidate([1L, 2L, 3L, 4L], [2L, 1L, 4L, 3L]) == "YES");
    assert(candidate([5L, 7L, 3L], [2L, 6L, 4L]) == "YES");
    assert(candidate([5L, 7L, 3L], [2L, 6L, 3L]) == "NO");
    assert(candidate([3L, 2L, 6L, 1L, 8L, 9L], [3L, 5L, 5L, 1L, 1L, 1L]) == "NO");
    assert(candidate([100L, 200L], [200L, 200L]) == "YES");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a string representing a space separated lowercase letters, return a dictionary
of the letter with the most repetition and containing the corresponding count.
If several letters have the same occurrence, return all of them.
Example:
*/
Nullable!(long[string]) histogram(string test)

unittest
{
    alias candidate = histogram;

{
        auto result = candidate("a b b a");
        assert(!result.isNull && result.get == ["a": 2L, "b": 2L]);
}

{
        auto result = candidate("a b c a b");
        assert(!result.isNull && result.get == ["a": 2L, "b": 2L]);
}

{
        auto result = candidate("a b c d g");
        assert(!result.isNull && result.get == ["a": 1L, "b": 1L, "c": 1L, "d": 1L, "g": 1L]);
}

{
        auto result = candidate("r t g");
        assert(!result.isNull && result.get == ["r": 1L, "t": 1L, "g": 1L]);
}

{
        auto result = candidate("b b b b a");
        assert(!result.isNull && result.get == ["b": 4L]);
}

{
        auto result = candidate("r t g");
        assert(!result.isNull && result.get == ["r": 1L, "t": 1L, "g": 1L]);
}

{
        auto result = candidate("");
        assert(result.isNull);
}

{
        auto result = candidate("a");
        assert(!result.isNull && result.get == ["a": 1L]);
}

}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Task
We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
then check if the result string is palindrome.
A string is called palindrome if it reads the same backward as forward.
You should return a tuple containing the result string and True/False for the check.
Example
*/
Tuple!(string, bool) reverse_delete(string s, string c)

unittest
{
    alias candidate = reverse_delete;

    assert(candidate("abcde", "ae") == tuple("bcd", false));
    assert(candidate("abcdef", "b") == tuple("acdef", false));
    assert(candidate("abcdedcba", "ab") == tuple("cdedc", true));
    assert(candidate("dwik", "w") == tuple("dik", false));
    assert(candidate("a", "a") == tuple("", true));
    assert(candidate("abcdedcba", "") == tuple("abcdedcba", true));
    assert(candidate("abcdedcba", "v") == tuple("abcdedcba", true));
    assert(candidate("vabba", "v") == tuple("abba", true));
    assert(candidate("mamma", "mia") == tuple("", true));
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a list of strings, where each string consists of only digits, return a list.
Each element i of the output should be "the number of odd elements in the
string i of the input." where all the i's should be replaced by the number
of odd digits in the i'th string of the input.
*/
string[] odd_count(string[] lst)

unittest
{
    alias candidate = odd_count;

    assert(candidate(["1234567"]) == ["the number of odd elements 4n the str4ng 4 of the 4nput."]);
    assert(candidate(["3", "11111111"]) == ["the number of odd elements 1n the str1ng 1 of the 1nput.", "the number of odd elements 8n the str8ng 8 of the 8nput."]);
    assert(candidate(["271", "137", "314"]) == ["the number of odd elements 2n the str2ng 2 of the 2nput.", "the number of odd elements 3n the str3ng 3 of the 3nput.", "the number of odd elements 2n the str2ng 2 of the 2nput."]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given an array of integers nums, find the minimum sum of any non-empty sub-array
of nums.
Example
*/
long minSubArraySum(long[] nums)


Prompt:
import std.math;
import std.typecons;
/*
You are given a rectangular grid of wells. Each row represents a single well,
and each 1 in a row represents a single unit of water.
Each well has a corresponding bucket that can be used to extract water from it,
and all buckets have the same capacity.
Your task is to use the buckets to empty the wells.
Output the number of times you need to lower the buckets.
Example 1:
Example 2:
Example 3:
Constraints:
    * all wells have the same length
    * 1 <= grid.length <= 10^2
    * 1 <= grid[:,1].length <= 10^2
    * grid[i][j] -> 0 | 1
    * 1 <= capacity <= 10
*/
long max_fill(long[][] grid, long capacity)


Prompt:
import std.math;
import std.typecons;
/*
In this Kata, you have to sort an array of non-negative integers according to
number of ones in their binary representation in ascending order.
For similar number of ones, sort based on decimal value.
It must be implemented like this:
*/
long[] sort_array(long[] arr)


Prompt:
import std.math;
import std.typecons;
/*
Given a string s and a natural number n, you have been tasked to implement
a function that returns a list of all words from string s that contain exactly
n consonants, in order these words appear in the string s.
If the string s is empty then the function should return an empty list.
Note: you may assume the input string contains only letters and spaces.
Examples:
*/
string[] select_words(string s, long n)

unittest
{
    alias candidate = select_words;

    assert(candidate("Mary had a little lamb", 4L) == ["little"]);
    assert(candidate("Mary had a little lamb", 3L) == ["Mary", "lamb"]);
    assert(candidate("simple white space", 2L) == []);
    assert(candidate("Hello world", 4L) == ["world"]);
    assert(candidate("Uncle sam", 3L) == ["Uncle"]);
    assert(candidate("", 4L) == []);
    assert(candidate("a b c d e f", 1L) == ["b", "c", "d", "f"]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given a word. Your task is to find the closest vowel that stands between
two consonants from the right side of the word (case sensitive).
Vowels in the beginning and ending doesn't count. Return empty string if you didn't
find any vowel met the above condition.
You may assume that the given string contains English letter only.
Example:
*/
string get_closest_vowel(string word)

unittest
{
    alias candidate = get_closest_vowel;

    assert(candidate("yogurt") == "u");
    assert(candidate("full") == "u");
    assert(candidate("easy") == "");
    assert(candidate("eAsy") == "");
    assert(candidate("ali") == "");
    assert(candidate("bad") == "a");
    assert(candidate("most") == "o");
    assert(candidate("ab") == "");
    assert(candidate("ba") == "");
    assert(candidate("quick") == "");
    assert(candidate("anime") == "i");
    assert(candidate("Asia") == "");
    assert(candidate("Above") == "o");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given a list of two strings, both strings consist of open
parentheses '(' or close parentheses ')' only.
Your job is to check if it is possible to concatenate the two strings in
some order, that the resulting string will be good.
A string S is considered to be good if and only if all parentheses in S
are balanced. For example: the string '(())()' is good, while the string
'())' is not.
Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
Examples:
*/
string match_parens(string[] lst)


Prompt:
import std.math;
import std.typecons;
/*
 Input are two strings a and b consisting only of 1s and 0s.
Perform binary XOR on these inputs and return result also as a string.
*/
string string_xor(string a, string b)

unittest
{
    alias candidate = string_xor;

    assert(candidate("111000", "101010") == "010010");
    assert(candidate("1", "1") == "0");
    assert(candidate("0101", "0000") == "0101");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given an array arr of integers and a positive integer k, return a sorted list
of length k with the maximum k numbers in arr.
Example 1:
Example 2:
Example 3:
Note:
    1. The length of the array will be in the range of [1, 1000].
    2. The elements in the array will be in the range of [-1000, 1000].
    3. 0 <= k <= len(arr)
*/
long[] maximum(long[] arr, long k)


Prompt:
import std.math;
import std.typecons;
/*
Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
Examples
*/
long solution(long[] lst)

unittest
{
    alias candidate = solution;

    assert(candidate([5L, 8L, 7L, 1L]) == 12L);
    assert(candidate([3L, 3L, 3L, 3L, 3L]) == 9L);
    assert(candidate([30L, 13L, 24L, 321L]) == 0L);
    assert(candidate([5L, 9L]) == 5L);
    assert(candidate([2L, 4L, 8L]) == 0L);
    assert(candidate([30L, 13L, 23L, 32L]) == 23L);
    assert(candidate([3L, 13L, 2L, 9L]) == 3L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a non-empty array of integers arr and an integer k, return
the sum of the elements with at most two digits from the first k elements of arr.
Example:
Constraints:
    1. 1 <= len(arr) <= 100
    2. 1 <= k <= len(arr)
*/
long add_elements(long[] arr, long k)

unittest
{
    alias candidate = add_elements;

    assert(candidate([1L, -2L, -3L, 41L, 57L, 76L, 87L, 88L, 99L], 3L) == -4L);
    assert(candidate([111L, 121L, 3L, 4000L, 5L, 6L], 2L) == 0L);
    assert(candidate([11L, 21L, 3L, 90L, 5L, 6L, 7L, 8L, 9L], 4L) == 125L);
    assert(candidate([111L, 21L, 3L, 4000L, 5L, 6L, 7L, 8L, 9L], 4L) == 24L);
    assert(candidate([1L], 1L) == 1L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
as follows: start with any positive integer n. Then each term is obtained from the
previous term as follows: if the previous term is even, the next term is one half of
the previous term. If the previous term is odd, the next term is 3 times the previous
term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
Note:
    1. Collatz(1) is [1].
    2. returned list sorted in increasing order.
For example:
get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
*/
long[] get_odd_collatz(long n)

unittest
{
    alias candidate = get_odd_collatz;

    assert(candidate(14L) == [1L, 5L, 7L, 11L, 13L, 17L]);
    assert(candidate(5L) == [1L, 5L]);
    assert(candidate(12L) == [1L, 3L, 5L]);
    assert(candidate(1L) == [1L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You have to write a function which validates a given date string and
returns True if the date is valid otherwise False.
The date is valid if all of the following rules are satisfied:
1. The date string is not empty.
2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
3. The months should not be less than 1 or higher than 12.
4. The date should be in the format: mm-dd-yyyy
*/
bool valid_date(string date)

unittest
{
    alias candidate = valid_date;

    assert(candidate("03-11-2000") == true);
    assert(candidate("15-01-2012") == false);
    assert(candidate("04-0-2040") == false);
    assert(candidate("06-04-2020") == true);
    assert(candidate("01-01-2007") == true);
    assert(candidate("03-32-2011") == false);
    assert(candidate("") == false);
    assert(candidate("04-31-3000") == false);
    assert(candidate("06-06-2005") == true);
    assert(candidate("21-31-2000") == false);
    assert(candidate("04-12-2003") == true);
    assert(candidate("04122003") == false);
    assert(candidate("20030412") == false);
    assert(candidate("2003-04") == false);
    assert(candidate("2003-04-12") == false);
    assert(candidate("04-2003") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a list of numbers, return whether or not they are sorted
in ascending order. If list has more than 1 duplicate of the same
number, return False. Assume no negative numbers and only integers.
Examples
*/
bool is_sorted(long[] lst)

unittest
{
    alias candidate = is_sorted;

    assert(candidate([5L]) == true);
    assert(candidate([1L, 2L, 3L, 4L, 5L]) == true);
    assert(candidate([1L, 3L, 2L, 4L, 5L]) == false);
    assert(candidate([1L, 2L, 3L, 4L, 5L, 6L]) == true);
    assert(candidate([1L, 2L, 3L, 4L, 5L, 6L, 7L]) == true);
    assert(candidate([1L, 3L, 2L, 4L, 5L, 6L, 7L]) == false);
    assert(candidate([]) == true);
    assert(candidate([1L]) == true);
    assert(candidate([3L, 2L, 1L]) == false);
    assert(candidate([1L, 2L, 2L, 2L, 3L, 4L]) == false);
    assert(candidate([1L, 2L, 3L, 3L, 3L, 4L]) == false);
    assert(candidate([1L, 2L, 2L, 3L, 3L, 4L]) == true);
    assert(candidate([1L, 2L, 3L, 4L]) == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given two intervals,
where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
The given intervals are closed which means that the interval (start, end)
includes both start and end.
For each given interval, it is assumed that its start is less or equal its end.
Your task is to determine whether the length of intersection of these two
intervals is a prime number.
Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)
which its length is 1, which not a prime number.
If the length of the intersection is a prime number, return "YES",
otherwise, return "NO".
If the two intervals don't intersect, return "NO".
[input/output] samples:
*/
string intersection(Tuple!(long, long) interval1, Tuple!(long, long) interval2)

unittest
{
    alias candidate = intersection;

    assert(candidate(tuple(1L, 2L), tuple(2L, 3L)) == "NO");
    assert(candidate(tuple(-1L, 1L), tuple(0L, 4L)) == "NO");
    assert(candidate(tuple(-3L, -1L), tuple(-5L, 5L)) == "YES");
    assert(candidate(tuple(-2L, 2L), tuple(-4L, 0L)) == "YES");
    assert(candidate(tuple(-11L, 2L), tuple(-1L, -1L)) == "NO");
    assert(candidate(tuple(1L, 2L), tuple(3L, 5L)) == "NO");
    assert(candidate(tuple(1L, 2L), tuple(1L, 2L)) == "NO");
    assert(candidate(tuple(-2L, -2L), tuple(-3L, -2L)) == "NO");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given an array arr of integers and you need to return
sum of magnitudes of integers multiplied by product of all signs
of each number in the array, represented by 1, -1 or 0.
Note: return None for empty arr.
Example:
*/
Nullable!(long) prod_signs(long[] arr)

unittest
{
    alias candidate = prod_signs;

{
        auto result = candidate([1L, 2L, 2L, -4L]);
        assert(!result.isNull && result.get == -9L);
}

{
        auto result = candidate([0L, 1L]);
        assert(!result.isNull && result.get == 0L);
}

{
        auto result = candidate([1L, 1L, 1L, 2L, 3L, -1L, 1L]);
        assert(!result.isNull && result.get == -10L);
}

{
        auto result = candidate([]);
        assert(result.isNull);
}

{
        auto result = candidate([2L, 4L, 1L, 2L, -1L, -1L, 9L]);
        assert(!result.isNull && result.get == 20L);
}

{
        auto result = candidate([-1L, 1L, -1L, 1L]);
        assert(!result.isNull && result.get == 4L);
}

{
        auto result = candidate([-1L, 1L, 1L, 1L]);
        assert(!result.isNull && result.get == -4L);
}

{
        auto result = candidate([-1L, 1L, 1L, 0L]);
        assert(!result.isNull && result.get == 0L);
}

}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a grid with N rows and N columns (N >= 2) and a positive integer k,
each cell of the grid contains a value. Every integer in the range [1, N * N]
inclusive appears exactly once on the cells of the grid.
You have to find the minimum path of length k in the grid. You can start
from any cell, and in each step you can move to any of the neighbor cells,
in other words, you can go to cells which share an edge with you current
cell.
Please note that a path of length k means visiting exactly k cells (not
necessarily distinct).
You CANNOT go off the grid.
A path A (of length k) is considered less than a path B (of length k) if
after making the ordered lists of the values on the cells that A and B go
through (let's call them lst_A and lst_B), lst_A is lexicographically less
than lst_B, in other words, there exist an integer index i (1 <= i <= k)
such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
lst_A[j] = lst_B[j].
It is guaranteed that the answer is unique.
Return an ordered list of the values on the cells that the minimum path go through.
Examples:
*/
long[] minPath(long[][] grid, long k)


Prompt:
import std.math;
import std.typecons;
/*
 Out of list of strings, return the longest one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
*/
Nullable!(string) longest(string[] strings)

unittest
{
    alias candidate = longest;

{
        auto result = candidate([]);
        assert(result.isNull);
}

{
        auto result = candidate(["x", "y", "z"]);
        assert(!result.isNull && result.get == "x");
}

{
        auto result = candidate(["x", "yyy", "zzzz", "www", "kkkk", "abc"]);
        assert(!result.isNull && result.get == "zzzz");
}

}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
the last couple centuries. However, what people don't know is Tribonacci sequence.
Tribonacci sequence is defined by the recurrence:
tri(1) = 3
tri(n) = 1 + n / 2, if n is even.
tri(n) =  tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
For example:
tri(2) = 1 + (2 / 2) = 2
tri(4) = 3
tri(3) = tri(2) + tri(1) + tri(4)
       = 2 + 3 + 3 = 8
You are given a non-negative integer number n, you have to a return a list of the
first n + 1 numbers of the Tribonacci sequence.
Examples:
*/
long[] tri(long n)

unittest
{
    alias candidate = tri;

    assert(candidate(3L) == [1L, 3L, 2L, 8L]);
    assert(candidate(4L) == [1L, 3L, 2L, 8L, 3L]);
    assert(candidate(5L) == [1L, 3L, 2L, 8L, 3L, 15L]);
    assert(candidate(6L) == [1L, 3L, 2L, 8L, 3L, 15L, 4L]);
    assert(candidate(7L) == [1L, 3L, 2L, 8L, 3L, 15L, 4L, 24L]);
    assert(candidate(8L) == [1L, 3L, 2L, 8L, 3L, 15L, 4L, 24L, 5L]);
    assert(candidate(9L) == [1L, 3L, 2L, 8L, 3L, 15L, 4L, 24L, 5L, 35L]);
    assert(candidate(20L) == [1L, 3L, 2L, 8L, 3L, 15L, 4L, 24L, 5L, 35L, 6L, 48L, 7L, 63L, 8L, 80L, 9L, 99L, 10L, 120L, 11L]);
    assert(candidate(0L) == [1L]);
    assert(candidate(1L) == [1L, 3L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a positive integer n, return the product of the odd digits.
Return 0 if all digits are even.
For example:
*/
long digits(long n)

unittest
{
    alias candidate = digits;

    assert(candidate(5L) == 5L);
    assert(candidate(54L) == 5L);
    assert(candidate(120L) == 1L);
    assert(candidate(5014L) == 5L);
    assert(candidate(98765L) == 315L);
    assert(candidate(5576543L) == 2625L);
    assert(candidate(2468L) == 0L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Create a function that takes a string as input which contains only square brackets.
The function should return True if and only if there is a valid subsequence of brackets
where at least one bracket in the subsequence is nested.
*/
bool is_nested(string string)

unittest
{
    alias candidate = is_nested;

    assert(candidate("[[]]") == true);
    assert(candidate("[]]]]]]][[[[[]") == false);
    assert(candidate("[][]") == false);
    assert(candidate("[]") == false);
    assert(candidate("[[[[]]]]") == true);
    assert(candidate("[]]]]]]]]]]") == false);
    assert(candidate("[][][[]]") == true);
    assert(candidate("[[]") == false);
    assert(candidate("[]]") == false);
    assert(candidate("[[]][[") == true);
    assert(candidate("[[][]]") == true);
    assert(candidate("") == false);
    assert(candidate("[[[[[[[[") == false);
    assert(candidate("]]]]]]]]") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given a list of numbers.
You need to return the sum of squared numbers in the given list,
round each element in the list to the upper int(Ceiling) first.
Examples:
*/
long sum_squares(float[] lst)


Prompt:
import std.math;
import std.typecons;
/*
Create a function that returns True if the last character
of a given string is an alphabetical character and is not
a part of a word, and False otherwise.
Note: "word" is a group of characters separated by space.
Examples:
*/
bool check_if_last_char_is_a_letter(string txt)

unittest
{
    alias candidate = check_if_last_char_is_a_letter;

    assert(candidate("apple") == false);
    assert(candidate("apple pi e") == true);
    assert(candidate("eeeee") == false);
    assert(candidate("A") == true);
    assert(candidate("Pumpkin pie ") == false);
    assert(candidate("Pumpkin pie 1") == false);
    assert(candidate("") == false);
    assert(candidate("eeeee e ") == false);
    assert(candidate("apple pie") == false);
    assert(candidate("apple pi e ") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Create a function which returns the largest index of an element which
is not greater than or equal to the element immediately preceding it. If
no such element exists then return -1. The given array will not contain
duplicate values.
Examples:
*/
long can_arrange(long[] arr)

unittest
{
    alias candidate = can_arrange;

    assert(candidate([1L, 2L, 4L, 3L, 5L]) == 3L);
    assert(candidate([1L, 2L, 4L, 5L]) == -1L);
    assert(candidate([1L, 4L, 2L, 5L, 6L, 7L, 8L, 9L, 10L]) == 2L);
    assert(candidate([4L, 8L, 5L, 7L, 3L]) == 4L);
    assert(candidate([]) == -1L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Create a function that returns a tuple (a, b), where 'a' is
the largest of negative integers, and 'b' is the smallest
of positive integers in a list.
If there is no negative or positive integers, return them as None.
Examples:
*/
Tuple!(Nullable!(long), Nullable!(long)) largest_smallest_integers(long[] lst)

unittest
{
    alias candidate = largest_smallest_integers;

{
        auto result = candidate([2L, 4L, 1L, 3L, 5L, 7L]);
        assert(result[0].isNull);
        assert(!result[1].isNull && result[1].get == 1L);
}

{
        auto result = candidate([2L, 4L, 1L, 3L, 5L, 7L, 0L]);
        assert(result[0].isNull);
        assert(!result[1].isNull && result[1].get == 1L);
}

{
        auto result = candidate([1L, 3L, 2L, 4L, 5L, 6L, -2L]);
        assert(!result[0].isNull && result[0].get == -2L);
        assert(!result[1].isNull && result[1].get == 1L);
}

{
        auto result = candidate([4L, 5L, 3L, 6L, 2L, 7L, -7L]);
        assert(!result[0].isNull && result[0].get == -7L);
        assert(!result[1].isNull && result[1].get == 2L);
}

{
        auto result = candidate([7L, 3L, 8L, 4L, 9L, 2L, 5L, -9L]);
        assert(!result[0].isNull && result[0].get == -9L);
        assert(!result[1].isNull && result[1].get == 2L);
}

{
        auto result = candidate([]);
        assert(result[0].isNull);
        assert(result[1].isNull);
}

{
        auto result = candidate([0L]);
        assert(result[0].isNull);
        assert(result[1].isNull);
}

{
        auto result = candidate([-1L, -3L, -5L, -6L]);
        assert(!result[0].isNull && result[0].get == -1L);
        assert(result[1].isNull);
}

{
        auto result = candidate([-1L, -3L, -5L, -6L, 0L]);
        assert(!result[0].isNull && result[0].get == -1L);
        assert(result[1].isNull);
}

{
        auto result = candidate([-6L, -4L, -4L, -3L, 1L]);
        assert(!result[0].isNull && result[0].get == -3L);
        assert(!result[1].isNull && result[1].get == 1L);
}

{
        auto result = candidate([-6L, -4L, -4L, -3L, -100L, 1L]);
        assert(!result[0].isNull && result[0].get == -3L);
        assert(!result[1].isNull && result[1].get == 1L);
}

}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
Example
*/
bool is_equal_to_sum_even(long n)

unittest
{
    alias candidate = is_equal_to_sum_even;

    assert(candidate(4L) == false);
    assert(candidate(6L) == false);
    assert(candidate(8L) == true);
    assert(candidate(10L) == true);
    assert(candidate(11L) == false);
    assert(candidate(12L) == true);
    assert(candidate(13L) == false);
    assert(candidate(16L) == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
The Brazilian factorial is defined as:
brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
where n > 0
For example:
The function will receive an integer as input and should return the special
factorial of this integer.
*/
long special_factorial(long n)

unittest
{
    alias candidate = special_factorial;

    assert(candidate(4L) == 288L);
    assert(candidate(5L) == 34560L);
    assert(candidate(7L) == 125411328000L);
    assert(candidate(1L) == 1L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Return a greatest common divisor of two integers a and b
*/
long greatest_common_divisor(long a, long b)

unittest
{
    alias candidate = greatest_common_divisor;

    assert(candidate(3L, 7L) == 1L);
    assert(candidate(10L, 15L) == 5L);
    assert(candidate(49L, 14L) == 7L);
    assert(candidate(144L, 60L) == 12L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a string text, replace all spaces in it with underscores,
and if a string has more than 2 consecutive spaces,
then replace all consecutive spaces with -
*/
string fix_spaces(string text)

unittest
{
    alias candidate = fix_spaces;

    assert(candidate("Example") == "Example");
    assert(candidate("Mudasir Hanif ") == "Mudasir_Hanif_");
    assert(candidate("Yellow Yellow  Dirty  Fellow") == "Yellow_Yellow__Dirty__Fellow");
    assert(candidate("Exa   mple") == "Exa-mple");
    assert(candidate("   Exa 1 2 2 mple") == "-Exa_1_2_2_mple");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Create a function which takes a string representing a file's name, and returns
'Yes' if the the file's name is valid, and returns 'No' otherwise.
A file's name is considered to be valid if and only if all the following conditions
are met:
- There should not be more than three digits ('0'-'9') in the file's name.
- The file's name contains exactly one dot '.'
- The substring before the dot should not be empty, and it starts with a letter from
the latin alphapet ('a'-'z' and 'A'-'Z').
- The substring after the dot should be one of these: ['txt', 'exe', 'dll']
Examples:
*/
string file_name_check(string file_name)

unittest
{
    alias candidate = file_name_check;

    assert(candidate("example.txt") == "Yes");
    assert(candidate("1example.dll") == "No");
    assert(candidate("s1sdf3.asd") == "No");
    assert(candidate("K.dll") == "Yes");
    assert(candidate("MY16FILE3.exe") == "Yes");
    assert(candidate("His12FILE94.exe") == "No");
    assert(candidate("_Y.txt") == "No");
    assert(candidate("?aREYA.exe") == "No");
    assert(candidate("/this_is_valid.dll") == "No");
    assert(candidate("this_is_valid.wow") == "No");
    assert(candidate("this_is_valid.txt") == "Yes");
    assert(candidate("this_is_valid.txtexe") == "No");
    assert(candidate("#this2_i4s_5valid.ten") == "No");
    assert(candidate("@this1_is6_valid.exe") == "No");
    assert(candidate("this_is_12valid.6exe4.txt") == "No");
    assert(candidate("all.exe.txt") == "No");
    assert(candidate("I563_No.exe") == "Yes");
    assert(candidate("Is3youfault.txt") == "Yes");
    assert(candidate("no_one#knows.dll") == "Yes");
    assert(candidate("1I563_Yes3.exe") == "No");
    assert(candidate("I563_Yes3.txtt") == "No");
    assert(candidate("final..txt") == "No");
    assert(candidate("final132") == "No");
    assert(candidate("_f4indsartal132.") == "No");
    assert(candidate(".txt") == "No");
    assert(candidate("s.") == "No");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
"
This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a
multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not
change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries.
Examples:
*/
long sum_squares(long[] lst)


Prompt:
import std.math;
import std.typecons;
/*
You are given a string representing a sentence,
the sentence contains some words separated by a space,
and you have to return a string that contains the words from the original sentence,
whose lengths are prime numbers,
the order of the words in the new string should be the same as the original one.
Example 1:
Example 2:
Constraints:
    * 1 <= len(sentence) <= 100
    * sentence contains only letters
*/
string words_in_sentence(string sentence)

unittest
{
    alias candidate = words_in_sentence;

    assert(candidate("This is a test") == "is");
    assert(candidate("lets go for swimming") == "go for");
    assert(candidate("there is no place available here") == "there is no place");
    assert(candidate("Hi I am Hussein") == "Hi am Hussein");
    assert(candidate("go for it") == "go for it");
    assert(candidate("here") == "");
    assert(candidate("here is") == "is");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Your task is to implement a function that will simplify the expression
x * n. The function returns True if x * n evaluates to a whole number and False
otherwise. Both x and n, are string representation of a fraction, and have the following format,
<numerator>/<denominator> where both numerator and denominator are positive whole numbers.
You can assume that x, and n are valid fractions, and do not have zero as denominator.
*/
bool simplify(string x, string n)

unittest
{
    alias candidate = simplify;

    assert(candidate("1/5", "5/1") == true);
    assert(candidate("1/6", "2/1") == false);
    assert(candidate("5/1", "3/1") == true);
    assert(candidate("7/10", "10/2") == false);
    assert(candidate("2/10", "50/10") == true);
    assert(candidate("7/2", "4/2") == true);
    assert(candidate("11/6", "6/1") == true);
    assert(candidate("2/3", "5/2") == false);
    assert(candidate("5/2", "3/5") == false);
    assert(candidate("2/4", "8/4") == true);
    assert(candidate("2/4", "4/2") == true);
    assert(candidate("1/5", "5/1") == true);
    assert(candidate("1/5", "1/5") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function which sorts the given list of integers
in ascending order according to the sum of their digits.
Note: if there are several items with similar sum of their digits,
order them based on their index in original list.
For example:
*/
long[] order_by_points(long[] nums)


Prompt:
import std.math;
import std.typecons;
/*
Write a function that takes an array of numbers as input and returns
the number of elements in the array that are greater than 10 and both
first and last digits of a number are odd (1, 3, 5, 7, 9).
For example:
*/
long specialFilter(long[] nums)

unittest
{
    alias candidate = specialFilter;

    assert(candidate([5L, -2L, 1L, -5L]) == 0L);
    assert(candidate([15L, -73L, 14L, -15L]) == 1L);
    assert(candidate([33L, -2L, -3L, 45L, 21L, 109L]) == 2L);
    assert(candidate([43L, -12L, 93L, 125L, 121L, 109L]) == 4L);
    assert(candidate([71L, -2L, -33L, 75L, 21L, 19L]) == 3L);
    assert(candidate([1L]) == 0L);
    assert(candidate([]) == 0L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
    You are given a positive integer n. You have to create an integer array a of length n.
For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
    and a[i] + a[j] + a[k] is a multiple of 3.
    Example :
    Explanation:
a = [1, 3, 7, 13, 21]
The only valid triple is (1, 7, 13).
*/
long get_max_triples(long n)

unittest
{
    alias candidate = get_max_triples;

    assert(candidate(5L) == 1L);
    assert(candidate(6L) == 4L);
    assert(candidate(10L) == 36L);
    assert(candidate(100L) == 53361L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function that accepts a list of strings as a parameter,
deletes the strings that have odd lengths from it,
and returns the resulted list with a sorted order,
The list is always a list of strings and never an array of numbers,
and it may contain duplicates.
The order of the list should be ascending by length of each word, and you
should return the list sorted by that rule.
If two words have the same length, sort the list alphabetically.
The function should return a list of strings in sorted order.
You may assume that all words will have the same length.
For example:
*/
string[] sorted_list_sum(string[] lst)

unittest
{
    alias candidate = sorted_list_sum;

    assert(candidate(["aa", "a", "aaa"]) == ["aa"]);
    assert(candidate(["school", "AI", "asdf", "b"]) == ["AI", "asdf", "school"]);
    assert(candidate(["d", "b", "c", "a"]) == []);
    assert(candidate(["d", "dcba", "abcd", "a"]) == ["abcd", "dcba"]);
    assert(candidate(["AI", "ai", "au"]) == ["AI", "ai", "au"]);
    assert(candidate(["a", "b", "b", "c", "c", "a"]) == []);
    assert(candidate(["aaaa", "bbbb", "dd", "cc"]) == ["cc", "dd", "aaaa", "bbbb"]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Return list of all prefixes from shortest to longest of the input string
*/
string[] all_prefixes(string string)

unittest
{
    alias candidate = all_prefixes;

    assert(candidate("") == []);
    assert(candidate("asdfgh") == ["a", "as", "asd", "asdf", "asdfg", "asdfgh"]);
    assert(candidate("WWW") == ["W", "WW", "WWW"]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
A simple program which should return the value of x if n is
a prime number and should return the value of y otherwise.
Examples:
*/
long x_or_y(long n, long x, long y)

unittest
{
    alias candidate = x_or_y;

    assert(candidate(7L, 34L, 12L) == 34L);
    assert(candidate(15L, 8L, 5L) == 5L);
    assert(candidate(3L, 33L, 5212L) == 33L);
    assert(candidate(1259L, 3L, 52L) == 3L);
    assert(candidate(7919L, -1L, 12L) == -1L);
    assert(candidate(3609L, 1245L, 583L) == 583L);
    assert(candidate(91L, 56L, 129L) == 129L);
    assert(candidate(6L, 34L, 1234L) == 1234L);
    assert(candidate(1L, 2L, 0L) == 0L);
    assert(candidate(2L, 2L, 0L) == 2L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a list of numbers, return the sum of squares of the numbers
in the list that are odd. Ignore numbers that are negative or not integers.
If the input list is empty, return 0.
*/
long double_the_difference(float[] lst)


Prompt:
import std.math;
import std.typecons;
/*
I think we all remember that feeling when the result of some long-awaited
event is finally known. The feelings and thoughts you have at that moment are
definitely worth noting down and comparing.
Your task is to determine if a person correctly guessed the results of a number of matches.
You are given two arrays of scores and guesses of equal length, where each index shows a match.
Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
the value is 0, and if not, the value is the absolute difference between the guess and the score.
example:
*/
long[] compare(long[] game, long[] guess)


Prompt:
import std.math;
import std.typecons;
/*
You will be given the name of a class (a string) and a list of extensions.
The extensions are to be used to load additional classes to the class. The
strength of the extension is as follows: Let CAP be the number of the uppercase
letters in the extension's name, and let SM be the number of lowercase letters
in the extension's name, the strength is given by the fraction CAP - SM.
You should find the strongest extension and return a string in this
format: ClassName.StrongestExtensionName.
If there are two or more extensions with the same strength, you should
choose the one that comes first in the list.
For example, if you are given "Slices" as the class and a list of the
extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
(its strength is -1).
Example:
*/
string Strongest_Extension(string class_name, string[] extensions)

unittest
{
    alias candidate = Strongest_Extension;

    assert(candidate("Watashi", ["tEN", "niNE", "eIGHt8OKe"]) == "Watashi.eIGHt8OKe");
    assert(candidate("Boku123", ["nani", "NazeDa", "YEs.WeCaNe", "32145tggg"]) == "Boku123.YEs.WeCaNe");
    assert(candidate("__YESIMHERE", ["t", "eMptY", "nothing", "zeR00", "NuLl__", "123NoooneB321"]) == "__YESIMHERE.NuLl__");
    assert(candidate("K", ["Ta", "TAR", "t234An", "cosSo"]) == "K.TAR");
    assert(candidate("__HAHA", ["Tab", "123", "781345", "-_-"]) == "__HAHA.123");
    assert(candidate("YameRore", ["HhAas", "okIWILL123", "WorkOut", "Fails", "-_-"]) == "YameRore.okIWILL123");
    assert(candidate("finNNalLLly", ["Die", "NowW", "Wow", "WoW"]) == "finNNalLLly.WoW");
    assert(candidate("_", ["Bb", "91245"]) == "_.Bb");
    assert(candidate("Sp", ["671235", "Bb"]) == "Sp.671235");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word
*/
bool cycpattern_check(string a, string b)

unittest
{
    alias candidate = cycpattern_check;

    assert(candidate("xyzw", "xyw") == false);
    assert(candidate("yello", "ell") == true);
    assert(candidate("whattup", "ptut") == false);
    assert(candidate("efef", "fee") == true);
    assert(candidate("abab", "aabb") == false);
    assert(candidate("winemtt", "tinem") == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given an integer. return a tuple that has the number of even and odd digits respectively.
Example:
*/
Tuple!(long, long) even_odd_count(long num)

unittest
{
    alias candidate = even_odd_count;

    assert(candidate(7L) == tuple(0L, 1L));
    assert(candidate(-78L) == tuple(1L, 1L));
    assert(candidate(3452L) == tuple(2L, 2L));
    assert(candidate(346211L) == tuple(3L, 3L));
    assert(candidate(-345821L) == tuple(3L, 3L));
    assert(candidate(-2L) == tuple(1L, 0L));
    assert(candidate(-45347L) == tuple(2L, 3L));
    assert(candidate(0L) == tuple(1L, 0L));
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a positive integer, obtain its roman numeral equivalent as a string,
and return it in lowercase.
Restrictions: 1 <= num <= 1000
Examples:
*/
string int_to_mini_roman(long number)

unittest
{
    alias candidate = int_to_mini_roman;

    assert(candidate(19L) == "xix");
    assert(candidate(152L) == "clii");
    assert(candidate(251L) == "ccli");
    assert(candidate(426L) == "cdxxvi");
    assert(candidate(500L) == "d");
    assert(candidate(1L) == "i");
    assert(candidate(4L) == "iv");
    assert(candidate(43L) == "xliii");
    assert(candidate(90L) == "xc");
    assert(candidate(94L) == "xciv");
    assert(candidate(532L) == "dxxxii");
    assert(candidate(900L) == "cm");
    assert(candidate(994L) == "cmxciv");
    assert(candidate(1000L) == "m");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given the lengths of the three sides of a triangle. Return True if the three
sides form a right-angled triangle, False otherwise.
A right-angled triangle is a triangle in which one angle is right angle or
90 degree.
Example:
*/
bool right_angle_triangle(long a, long b, long c)

unittest
{
    alias candidate = right_angle_triangle;

    assert(candidate(3L, 4L, 5L) == true);
    assert(candidate(1L, 2L, 3L) == false);
    assert(candidate(10L, 6L, 8L) == true);
    assert(candidate(2L, 2L, 2L) == false);
    assert(candidate(7L, 24L, 25L) == true);
    assert(candidate(10L, 5L, 7L) == false);
    assert(candidate(5L, 12L, 13L) == true);
    assert(candidate(15L, 8L, 17L) == true);
    assert(candidate(48L, 55L, 73L) == true);
    assert(candidate(1L, 1L, 1L) == false);
    assert(candidate(2L, 2L, 10L) == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function that accepts a list of strings.
The list contains different words. Return the word with maximum number
of unique characters. If multiple strings have maximum number of unique
characters, return the one which comes first in lexicographical order.
*/
string find_max(string[] words)

unittest
{
    alias candidate = find_max;

    assert(candidate(["name", "of", "string"]) == "string");
    assert(candidate(["name", "enam", "game"]) == "enam");
    assert(candidate(["aaaaaaa", "bb", "cc"]) == "aaaaaaa");
    assert(candidate(["abc", "cba"]) == "abc");
    assert(candidate(["play", "this", "game", "of", "footbott"]) == "footbott");
    assert(candidate(["we", "are", "gonna", "rock"]) == "gonna");
    assert(candidate(["we", "are", "a", "mad", "nation"]) == "nation");
    assert(candidate(["this", "is", "a", "prrk"]) == "this");
    assert(candidate(["b"]) == "b");
    assert(candidate(["play", "play", "play"]) == "play");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You're a hungry rabbit, and you already have eaten a certain number of carrots,
but now you need to eat more carrots to complete the day's meals.
you should return an array of [ total number of eaten carrots after your meals,
                                the number of carrots left after your meals ]
if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
Example:
Variables:
@number : integer
    the number of carrots that you have eaten.
@need : integer
    the number of carrots that you need to eat.
@remaining : integer
    the number of remaining carrots thet exist in stock
Constrain:
* 0 <= number <= 1000
* 0 <= need <= 1000
* 0 <= remaining <= 1000
Have fun :)
*/
long[] eat(long number, long need, long remaining)

unittest
{
    alias candidate = eat;

    assert(candidate(5L, 6L, 10L) == [11L, 4L]);
    assert(candidate(4L, 8L, 9L) == [12L, 1L]);
    assert(candidate(1L, 10L, 10L) == [11L, 0L]);
    assert(candidate(2L, 11L, 5L) == [7L, 0L]);
    assert(candidate(4L, 5L, 7L) == [9L, 2L]);
    assert(candidate(4L, 5L, 1L) == [5L, 0L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Return a string containing space-delimited numbers starting from 0 upto n inclusive.
*/
string string_sequence(long n)

unittest
{
    alias candidate = string_sequence;

    assert(candidate(0L) == "0");
    assert(candidate(3L) == "0 1 2 3");
    assert(candidate(10L) == "0 1 2 3 4 5 6 7 8 9 10");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given a string s.
if s[i] is a letter, reverse its case from lower to upper or vise versa,
otherwise keep it as it is.
If the string contains no letters, reverse the string.
The function should return the resulted string.
Examples
*/
string solve(string s)

unittest
{
    alias candidate = solve;

    assert(candidate("AsDf") == "aSdF");
    assert(candidate("1234") == "4321");
    assert(candidate("ab") == "AB");
    assert(candidate("#a@C") == "#A@c");
    assert(candidate("#AsdfW^45") == "#aSDFw^45");
    assert(candidate("#6@2") == "2@6#");
    assert(candidate("#$a^D") == "#$A^d");
    assert(candidate("#ccc") == "#CCC");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a string 'text', return its md5 hash equivalent string.
If 'text' is an empty string, return None.
*/
Nullable!(string) string_to_md5(string text)

unittest
{
    alias candidate = string_to_md5;

{
        auto result = candidate("Hello world");
        assert(!result.isNull && result.get == "3e25960a79dbc69b674cd4ec67a72c62");
}

{
        auto result = candidate("");
        assert(result.isNull);
}

{
        auto result = candidate("A B C");
        assert(!result.isNull && result.get == "0ef78513b0cb8cef12743f5aeb35f888");
}

{
        auto result = candidate("password");
        assert(!result.isNull && result.get == "5f4dcc3b5aa765d61d8327deb882cf99");
}

}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given two positive integers a and b, return the even digits between a
and b, in ascending order.
For example:
*/
long[] generate_integers(long a, long b)

unittest
{
    alias candidate = generate_integers;

    assert(candidate(2L, 10L) == [2L, 4L, 6L, 8L]);
    assert(candidate(10L, 2L) == [2L, 4L, 6L, 8L]);
    assert(candidate(132L, 2L) == [2L, 4L, 6L, 8L]);
    assert(candidate(17L, 89L) == []);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Given a string, find out how many distinct characters (regardless of case) does it consist of
*/
long count_distinct_characters(string string)

unittest
{
    alias candidate = count_distinct_characters;

    assert(candidate("") == 0L);
    assert(candidate("abcde") == 5L);
    assert(candidate("abcdecadeCADE") == 5L);
    assert(candidate("aaaaAAAAaaaa") == 1L);
    assert(candidate("Jerry jERRY JeRRRY") == 5L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Input to this function is a string representing musical notes in a special ASCII format.
Your task is to parse this string and return list of integers corresponding to how many beats does each
not last.
Here is a legend:
'o' - whole note, lasts four beats
'o|' - half note, lasts two beats
'.|' - quater note, lasts one beat
*/
long[] parse_music(string music_string)

unittest
{
    alias candidate = parse_music;

    assert(candidate("") == []);
    assert(candidate("o o o o") == [4L, 4L, 4L, 4L]);
    assert(candidate(".| .| .| .|") == [1L, 1L, 1L, 1L]);
    assert(candidate("o| o| .| .| o o o o") == [2L, 2L, 1L, 1L, 4L, 4L, 4L, 4L]);
    assert(candidate("o| .| o| .| o o| o o|") == [2L, 1L, 2L, 1L, 4L, 2L, 4L, 2L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Find how many times a given substring can be found in the original string. Count overlaping cases.
*/
long how_many_times(string string, string substring)

unittest
{
    alias candidate = how_many_times;

    assert(candidate("", "x") == 0L);
    assert(candidate("xyxyxyx", "x") == 4L);
    assert(candidate("cacacacac", "cac") == 4L);
    assert(candidate("john doe", "john") == 1L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Input is a space-delimited string of numberals from 'zero' to 'nine'.
Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
Return the string with numbers sorted from smallest to largest
*/
string sort_numbers(string numbers)

unittest
{
    alias candidate = sort_numbers;

    assert(candidate("") == "");
    assert(candidate("three") == "three");
    assert(candidate("three five nine") == "three five nine");
    assert(candidate("five zero four seven nine eight") == "zero four five seven eight nine");
    assert(candidate("six five four three two one zero") == "zero one two three four five six");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly closed) and not nested within each other
Ignore any spaces in the input string.
*/
string[] separate_paren_groups(string paren_string)


Prompt:
import std.math;
import std.typecons;
/*
 From a supplied list of numbers (of length at least two) select and return two that are the closest to each
other and return them in order (smaller number, larger number).
*/
Tuple!(float, float) find_closest_elements(float[] numbers)


Prompt:
import std.math;
import std.typecons;
/*
 Given list of numbers (of at least two elements), apply a linear transform to that list,
such that the smallest number will become 0 and the largest will become 1
*/
float[] rescale_to_unit(float[] numbers)


Prompt:
import std.math;
import std.typecons;
/*
 Return length of given string
*/
long strlen(string string)

unittest
{
    alias candidate = strlen;

    assert(candidate("") == 0L);
    assert(candidate("x") == 1L);
    assert(candidate("asdasnakj") == 9L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 For a given number n, find the largest number that divides n evenly, smaller than n
*/
long largest_divisor(long n)

unittest
{
    alias candidate = largest_divisor;

    assert(candidate(3L) == 1L);
    assert(candidate(7L) == 1L);
    assert(candidate(10L) == 5L);
    assert(candidate(100L) == 50L);
    assert(candidate(49L) == 7L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product of all factors
*/
long[] factorize(long n)

unittest
{
    alias candidate = factorize;

    assert(candidate(2L) == [2L]);
    assert(candidate(4L) == [2L, 2L]);
    assert(candidate(8L) == [2L, 2L, 2L]);
    assert(candidate(57L) == [3L, 19L]);
    assert(candidate(3249L) == [3L, 3L, 19L, 19L]);
    assert(candidate(185193L) == [3L, 3L, 3L, 19L, 19L, 19L]);
    assert(candidate(20577L) == [3L, 19L, 19L, 19L]);
    assert(candidate(18L) == [2L, 3L, 3L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
*/
long[] remove_duplicates(long[] numbers)

unittest
{
    alias candidate = remove_duplicates;

    assert(candidate([]) == []);
    assert(candidate([1L, 2L, 3L, 4L]) == [1L, 2L, 3L, 4L]);
    assert(candidate([1L, 2L, 3L, 2L, 4L, 3L, 5L]) == [1L, 4L, 5L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
*/
string flip_case(string string)

unittest
{
    alias candidate = flip_case;

    assert(candidate("") == "");
    assert(candidate("Hello!") == "hELLO!");
    assert(candidate("These violent delights have violent ends") == "tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Concatenate list of strings into a single string
*/
string concatenate(string[] strings)

unittest
{
    alias candidate = concatenate;

    assert(candidate([]) == "");
    assert(candidate(["x", "y", "z"]) == "xyz");
    assert(candidate(["x", "y", "z", "w", "k"]) == "xyzwk");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Filter an input list of strings only for ones that start with a given prefix.
*/
string[] filter_by_prefix(string[] strings, string prefix)

unittest
{
    alias candidate = filter_by_prefix;

    assert(candidate([], "john") == []);
    assert(candidate(["xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx"], "xxx") == ["xxx", "xxxAAA", "xxx"]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Given a positive floating point number, it can be decomposed into
and integer part (largest integer smaller than given number) and decimals
(leftover part always smaller than 1).
Return the decimal part of the number.
*/
float truncate_number(float number)

unittest
{
    alias candidate = truncate_number;

    assert(candidate(3.5) == 0.5);
    assert(candidate(1.25) == 0.25);
    assert(candidate(123.0) == 0.0);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return only positive numbers in the list.
*/
long[] get_positive(long[] l)

unittest
{
    alias candidate = get_positive;

    assert(candidate([-1L, -2L, 4L, 5L, 6L]) == [4L, 5L, 6L]);
    assert(candidate([5L, 3L, -5L, 2L, 3L, 3L, 9L, 0L, 123L, 1L, -10L]) == [5L, 3L, 2L, 3L, 3L, 9L, 123L, 1L]);
    assert(candidate([-1L, -2L]) == []);
    assert(candidate([]) == []);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return true if a given number is prime, and false otherwise.
*/
bool is_prime(long n)

unittest
{
    alias candidate = is_prime;

    assert(candidate(6L) == false);
    assert(candidate(101L) == true);
    assert(candidate(11L) == true);
    assert(candidate(13441L) == true);
    assert(candidate(61L) == true);
    assert(candidate(4L) == false);
    assert(candidate(1L) == false);
    assert(candidate(5L) == true);
    assert(candidate(11L) == true);
    assert(candidate(17L) == true);
    assert(candidate(85L) == false);
    assert(candidate(77L) == false);
    assert(candidate(255379L) == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
This function takes a list l and returns a list l' such that
l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
to the values of the corresponding indicies of l, but sorted.
*/
long[] sort_third(long[] l)


Prompt:
import std.math;
import std.typecons;
/*
Return sorted unique elements in a list
*/
long[] unique(long[] l)

unittest
{
    alias candidate = unique;

    assert(candidate([5L, 3L, 5L, 2L, 3L, 3L, 9L, 0L, 123L]) == [0L, 2L, 3L, 5L, 9L, 123L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return maximum element in the list.
*/
long max_element(long[] l)

unittest
{
    alias candidate = max_element;

    assert(candidate([1L, 2L, 3L]) == 3L);
    assert(candidate([5L, 3L, -5L, 2L, -3L, 3L, 9L, 0L, 124L, 1L, -10L]) == 124L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
*/
long fizz_buzz(long n)

unittest
{
    alias candidate = fizz_buzz;

    assert(candidate(50L) == 0L);
    assert(candidate(78L) == 2L);
    assert(candidate(79L) == 3L);
    assert(candidate(100L) == 3L);
    assert(candidate(200L) == 6L);
    assert(candidate(4000L) == 192L);
    assert(candidate(10000L) == 639L);
    assert(candidate(100000L) == 8026L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
This function takes a list l and returns a list l' such that
l' is identical to l in the odd indicies, while its values at the even indicies are equal
to the values of the even indicies of l, but sorted.
*/
long[] sort_even(long[] l)


Prompt:
import std.math;
import std.typecons;
/*
    prime_fib returns n-th number that is a Fibonacci number and it's also prime.
*/
long prime_fib(long n)

unittest
{
    alias candidate = prime_fib;

    assert(candidate(1L) == 2L);
    assert(candidate(2L) == 3L);
    assert(candidate(3L) == 5L);
    assert(candidate(4L) == 13L);
    assert(candidate(5L) == 89L);
    assert(candidate(6L) == 233L);
    assert(candidate(7L) == 1597L);
    assert(candidate(8L) == 28657L);
    assert(candidate(9L) == 514229L);
    assert(candidate(10L) == 433494437L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 You're given a list of deposit and withdrawal operations on a bank account that starts with
zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
at that point function should return True. Otherwise it should return False.
*/
bool below_zero(long[] operations)

unittest
{
    alias candidate = below_zero;

    assert(candidate([]) == false);
    assert(candidate([1L, 2L, -3L, 1L, 2L, -3L]) == false);
    assert(candidate([1L, 2L, -4L, 5L, 6L]) == true);
    assert(candidate([1L, -1L, 2L, -2L, 5L, -5L, 4L, -4L]) == false);
    assert(candidate([1L, -1L, 2L, -2L, 5L, -5L, 4L, -5L]) == true);
    assert(candidate([1L, -2L, 2L, -2L, 5L, -5L, 4L, -4L]) == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
triples_sum_to_zero takes a list of integers as an input.
it returns True if there are three distinct elements in the list that
sum to zero, and False otherwise.
*/
bool triples_sum_to_zero(long[] l)

unittest
{
    alias candidate = triples_sum_to_zero;

    assert(candidate([1L, 3L, 5L, 0L]) == false);
    assert(candidate([1L, 3L, 5L, -1L]) == false);
    assert(candidate([1L, 3L, -2L, 1L]) == true);
    assert(candidate([1L, 2L, 3L, 7L]) == false);
    assert(candidate([1L, 2L, 5L, 7L]) == false);
    assert(candidate([2L, 4L, -5L, 3L, 9L, 7L]) == true);
    assert(candidate([1L]) == false);
    assert(candidate([1L, 3L, 5L, -100L]) == false);
    assert(candidate([100L, 3L, 5L, -100L]) == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return list with elements incremented by 1.
*/
long[] incr_list(long[] l)

unittest
{
    alias candidate = incr_list;

    assert(candidate([]) == []);
    assert(candidate([3L, 2L, 1L]) == [4L, 3L, 2L]);
    assert(candidate([5L, 2L, 5L, 2L, 3L, 3L, 9L, 0L, 123L]) == [6L, 3L, 6L, 3L, 4L, 4L, 10L, 1L, 124L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
pairs_sum_to_zero takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
sum to zero, and False otherwise.
*/
bool pairs_sum_to_zero(long[] l)

unittest
{
    alias candidate = pairs_sum_to_zero;

    assert(candidate([1L, 3L, 5L, 0L]) == false);
    assert(candidate([1L, 3L, -2L, 1L]) == false);
    assert(candidate([1L, 2L, 3L, 7L]) == false);
    assert(candidate([2L, 4L, -5L, 3L, 5L, 7L]) == true);
    assert(candidate([1L]) == false);
    assert(candidate([-3L, 9L, -1L, 3L, 2L, 30L]) == true);
    assert(candidate([-3L, 9L, -1L, 3L, 2L, 31L]) == true);
    assert(candidate([-3L, 9L, -1L, 4L, 2L, 30L]) == false);
    assert(candidate([-3L, 9L, -1L, 4L, 2L, 31L]) == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Change numerical base of input number x to base.
return string representation after the conversion.
base numbers are less than 10.
*/
string change_base(long x, long base)

unittest
{
    alias candidate = change_base;

    assert(candidate(8L, 3L) == "22");
    assert(candidate(9L, 3L) == "100");
    assert(candidate(234L, 2L) == "11101010");
    assert(candidate(16L, 2L) == "10000");
    assert(candidate(8L, 2L) == "1000");
    assert(candidate(7L, 2L) == "111");
    assert(candidate(2L, 3L) == "2");
    assert(candidate(3L, 4L) == "3");
    assert(candidate(4L, 5L) == "4");
    assert(candidate(5L, 6L) == "5");
    assert(candidate(6L, 7L) == "6");
    assert(candidate(7L, 8L) == "7");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given length of a side and high return area for a triangle.
*/
float triangle_area(long a, long h)

unittest
{
    alias candidate = triangle_area;

    assert(candidate(5L, 3L) == 7.5);
    assert(candidate(2L, 2L) == 2.0);
    assert(candidate(10L, 8L) == 40.0);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fib4(0) -> 0
fib4(1) -> 0
fib4(2) -> 2
fib4(3) -> 0
fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
*/
long fib4(long n)

unittest
{
    alias candidate = fib4;

    assert(candidate(5L) == 4L);
    assert(candidate(8L) == 28L);
    assert(candidate(10L) == 104L);
    assert(candidate(12L) == 386L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return median of elements in the list l.
*/
float median(long[] l)

unittest
{
    alias candidate = median;

    assert(candidate([3L, 1L, 2L, 4L, 5L]) == 3L);
    assert(candidate([-10L, 4L, 6L, 1000L, 10L, 20L]) == 8.0);
    assert(candidate([5L]) == 5L);
    assert(candidate([6L, 5L]) == 5.5);
    assert(candidate([8L, 1L, 3L, 9L, 9L, 2L, 7L]) == 7L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
    Checks if given string is a palindrome
*/
bool is_palindrome(string text)

unittest
{
    alias candidate = is_palindrome;

    assert(candidate("") == true);
    assert(candidate("aba") == true);
    assert(candidate("aaaaa") == true);
    assert(candidate("zbcd") == false);
    assert(candidate("xywyx") == true);
    assert(candidate("xywyz") == false);
    assert(candidate("xywzx") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return 2^n modulo p (be aware of numerics).
*/
long modp(long n, long p)

unittest
{
    alias candidate = modp;

    assert(candidate(3L, 5L) == 3L);
    assert(candidate(1101L, 101L) == 2L);
    assert(candidate(0L, 101L) == 1L);
    assert(candidate(3L, 11L) == 8L);
    assert(candidate(100L, 101L) == 1L);
    assert(candidate(30L, 5L) == 4L);
    assert(candidate(31L, 5L) == 3L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 For a given list of input numbers, calculate Mean Absolute Deviation
around the mean of this dataset.
Mean Absolute Deviation is the average absolute difference between each
element and a centerpoint (mean in this case):
MAD = average | x - x_mean |
*/
float mean_absolute_deviation(float[] numbers)

unittest
{
    alias candidate = mean_absolute_deviation;

    assert(candidate([1.0, 2.0]) == 0.5);
    assert(candidate([1.0, 2.0, 3.0, 4.0]) == 1.0);
    assert(candidate([1.0, 2.0, 3.0, 4.0, 5.0]) == 1.2);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
    remove_vowels is a function that takes string and returns string without vowels.
*/
string remove_vowels(string text)

unittest
{
    alias candidate = remove_vowels;

    assert(candidate("") == "");
    assert(candidate("abcdef
ghijklm") == "bcdf
ghjklm");
    assert(candidate("fedcba") == "fdcb");
    assert(candidate("eeeee") == "");
    assert(candidate("acBAA") == "cB");
    assert(candidate("EcBOO") == "cB");
    assert(candidate("ybcd") == "ybcd");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return True if all numbers in the list l are below threshold t.
*/
bool below_threshold(long[] l, long t)

unittest
{
    alias candidate = below_threshold;

    assert(candidate([1L, 2L, 4L, 10L], 100L) == true);
    assert(candidate([1L, 20L, 4L, 10L], 5L) == false);
    assert(candidate([1L, 20L, 4L, 10L], 21L) == true);
    assert(candidate([1L, 20L, 4L, 10L], 22L) == true);
    assert(candidate([1L, 8L, 4L, 10L], 11L) == true);
    assert(candidate([1L, 8L, 4L, 10L], 10L) == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Add two numbers x and y
*/
long add(long x, long y)

unittest
{
    alias candidate = add;

    assert(candidate(0L, 1L) == 1L);
    assert(candidate(1L, 0L) == 1L);
    assert(candidate(2L, 3L) == 5L);
    assert(candidate(5L, 7L) == 12L);
    assert(candidate(7L, 5L) == 12L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
    Check if two words have the same characters.
*/
bool same_chars(string s0, string s1)

unittest
{
    alias candidate = same_chars;

    assert(candidate("eabcdzzzz", "dddzzzzzzzddeddabc") == true);
    assert(candidate("abcd", "dddddddabc") == true);
    assert(candidate("dddddddabc", "abcd") == true);
    assert(candidate("eabcd", "dddddddabc") == false);
    assert(candidate("abcd", "dddddddabcf") == false);
    assert(candidate("eabcdzzzz", "dddzzzzzzzddddabc") == false);
    assert(candidate("aabb", "aaccc") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return n-th Fibonacci number.
*/
long fib(long n)

unittest
{
    alias candidate = fib;

    assert(candidate(10L) == 55L);
    assert(candidate(1L) == 1L);
    assert(candidate(8L) == 21L);
    assert(candidate(11L) == 89L);
    assert(candidate(12L) == 144L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 brackets is a string of "<" and ">".
return True if every opening bracket has a corresponding closing bracket.
*/
bool correct_bracketing(string brackets)

unittest
{
    alias candidate = correct_bracketing;

    assert(candidate("<>") == true);
    assert(candidate("<<><>>") == true);
    assert(candidate("<><><<><>><>") == true);
    assert(candidate("<><><<<><><>><>><<><><<>>>") == true);
    assert(candidate("<<<><>>>>") == false);
    assert(candidate("><<>") == false);
    assert(candidate("<") == false);
    assert(candidate("<<<<") == false);
    assert(candidate(">") == false);
    assert(candidate("<<>") == false);
    assert(candidate("<><><<><>><>><<>") == false);
    assert(candidate("<><><<><>><>>><>") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return True is list elements are monotonically increasing or decreasing.
*/
bool monotonic(long[] l)

unittest
{
    alias candidate = monotonic;

    assert(candidate([1L, 2L, 4L, 10L]) == true);
    assert(candidate([1L, 2L, 4L, 20L]) == true);
    assert(candidate([1L, 20L, 4L, 10L]) == false);
    assert(candidate([4L, 1L, 0L, -10L]) == true);
    assert(candidate([4L, 1L, 1L, 0L]) == true);
    assert(candidate([1L, 2L, 3L, 2L, 5L, 60L]) == false);
    assert(candidate([1L, 2L, 3L, 4L, 5L, 60L]) == true);
    assert(candidate([9L, 9L, 9L, 9L]) == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Return sorted unique common elements for two lists.
*/
long[] common(long[] l1, long[] l2)


Prompt:
import std.math;
import std.typecons;
/*
Return the largest prime factor of n. Assume n > 1 and is not a prime.
*/
long largest_prime_factor(long n)

unittest
{
    alias candidate = largest_prime_factor;

    assert(candidate(15L) == 5L);
    assert(candidate(27L) == 3L);
    assert(candidate(63L) == 7L);
    assert(candidate(330L) == 11L);
    assert(candidate(13195L) == 29L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
*/
long[] intersperse(long[] numbers, long delimeter)

unittest
{
    alias candidate = intersperse;

    assert(candidate([], 7L) == []);
    assert(candidate([5L, 6L, 3L, 2L], 8L) == [5L, 8L, 6L, 8L, 3L, 8L, 2L]);
    assert(candidate([2L, 2L, 2L], 2L) == [2L, 2L, 2L, 2L, 2L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
sum_to_n is a function that sums numbers from 1 to n.
*/
long sum_to_n(long n)

unittest
{
    alias candidate = sum_to_n;

    assert(candidate(1L) == 1L);
    assert(candidate(6L) == 21L);
    assert(candidate(11L) == 66L);
    assert(candidate(30L) == 465L);
    assert(candidate(100L) == 5050L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 brackets is a string of "(" and ")".
return True if every opening bracket has a corresponding closing bracket.
*/
bool correct_bracketing(string brackets)

unittest
{
    alias candidate = correct_bracketing;

    assert(candidate("()") == true);
    assert(candidate("(()())") == true);
    assert(candidate("()()(()())()") == true);
    assert(candidate("()()((()()())())(()()(()))") == true);
    assert(candidate("((()())))") == false);
    assert(candidate(")(()") == false);
    assert(candidate("(") == false);
    assert(candidate("((((") == false);
    assert(candidate(")") == false);
    assert(candidate("(()") == false);
    assert(candidate("()()(()())())(()") == false);
    assert(candidate("()()(()())()))()") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
 Return derivative of this polynomial in the same form.
*/
long[] derivative(long[] xs)

unittest
{
    alias candidate = derivative;

    assert(candidate([3L, 1L, 2L, 4L, 5L]) == [1L, 4L, 12L, 20L]);
    assert(candidate([1L, 2L, 3L]) == [2L, 6L]);
    assert(candidate([3L, 2L, 1L]) == [2L, 2L]);
    assert(candidate([3L, 2L, 1L, 0L, 4L]) == [2L, 2L, 0L, 16L]);
    assert(candidate([1L]) == []);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute the n-th element of the fibfib number sequence.
*/
long fibfib(long n)

unittest
{
    alias candidate = fibfib;

    assert(candidate(2L) == 1L);
    assert(candidate(1L) == 0L);
    assert(candidate(5L) == 4L);
    assert(candidate(8L) == 24L);
    assert(candidate(10L) == 81L);
    assert(candidate(12L) == 274L);
    assert(candidate(14L) == 927L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function vowels_count which takes a string representing
a word as input and returns the number of vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the given word.
Example:
*/
long vowels_count(string s)

unittest
{
    alias candidate = vowels_count;

    assert(candidate("abcde") == 2L);
    assert(candidate("Alone") == 3L);
    assert(candidate("key") == 2L);
    assert(candidate("bye") == 1L);
    assert(candidate("keY") == 2L);
    assert(candidate("bYe") == 1L);
    assert(candidate("ACEDY") == 3L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Circular shift the digits of the integer x, shift the digits right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
*/
string circular_shift(long x, long shift)

unittest
{
    alias candidate = circular_shift;

    assert(candidate(100L, 2L) == "001");
    assert(candidate(12L, 2L) == "12");
    assert(candidate(97L, 8L) == "79");
    assert(candidate(12L, 1L) == "21");
    assert(candidate(11L, 101L) == "11");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Task
Write a function that takes a string as input and returns the sum of the upper characters only'
ASCII codes.
Examples:
*/
long digitSum(string s)

unittest
{
    alias candidate = digitSum;

    assert(candidate("") == 0L);
    assert(candidate("abAB") == 131L);
    assert(candidate("abcCd") == 67L);
    assert(candidate("helloE") == 69L);
    assert(candidate("woArBld") == 131L);
    assert(candidate("aAaaaXa") == 153L);
    assert(candidate(" How are yOu?") == 151L);
    assert(candidate("You arE Very Smart") == 327L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples and an integer that represent the total number of the fruits
in the basket return the number of the mango fruits in the basket.
for examble:
*/
long fruit_distribution(string s, long n)

unittest
{
    alias candidate = fruit_distribution;

    assert(candidate("5 apples and 6 oranges", 19L) == 8L);
    assert(candidate("5 apples and 6 oranges", 21L) == 10L);
    assert(candidate("0 apples and 1 oranges", 3L) == 2L);
    assert(candidate("1 apples and 0 oranges", 3L) == 2L);
    assert(candidate("2 apples and 3 oranges", 100L) == 95L);
    assert(candidate("2 apples and 3 oranges", 5L) == 0L);
    assert(candidate("1 apples and 100 oranges", 120L) == 19L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the smallest even value.
If multiple nodes with the same smallest even value are found return the node that has smallest index.
The plucked node should be returned in a list, [ smalest_value, its index ],
If there are no even values or the given array is empty, return [].
Example 1:
    Explanation: 2 has the smallest even value, and 2 has the smallest index.
Example 2:
    Explanation: 2 has the smallest even value, and 2 has the smallest index.
Example 3:
Example 4:
    Explanation: 0 is the smallest value, but  there are two zeros,
             so we will choose the first zero, which has the smallest index.
Constraints:
    * 1 <= nodes.length <= 10000
    * 0 <= node.value
*/
long[] pluck(long[] arr)

unittest
{
    alias candidate = pluck;

    assert(candidate([4L, 2L, 3L]) == [2L, 1L]);
    assert(candidate([1L, 2L, 3L]) == [2L, 1L]);
    assert(candidate([]) == []);
    assert(candidate([5L, 0L, 3L, 0L, 4L, 2L]) == [0L, 1L]);
    assert(candidate([1L, 2L, 3L, 0L, 5L, 3L]) == [0L, 3L]);
    assert(candidate([5L, 4L, 8L, 4L, 8L]) == [4L, 1L]);
    assert(candidate([7L, 6L, 7L, 1L]) == [6L, 1L]);
    assert(candidate([7L, 9L, 7L, 1L]) == []);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency greater than or equal to the value of the integer itself.
The frequency of an integer is the number of times it appears in the list.
If no such a value exist, return -1.
Examples:
*/
long search(long[] lst)


Prompt:
import std.math;
import std.typecons;
/*
 Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
*/
long[] parse_nested_parens(string paren_string)


Prompt:
import std.math;
import std.typecons;
/*
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
*/
long[] strange_sort_list(long[] lst)


Prompt:
import std.math;
import std.typecons;
/*
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
*/
float triangle_area(long a, long b, long c)

unittest
{
    alias candidate = triangle_area;

    assert(candidate(3L, 4L, 5L) == 6.0);
    assert(candidate(1L, 2L, 10L) == -1L);
    assert(candidate(4L, 8L, 5L) == 8.18);
    assert(candidate(2L, 2L, 2L) == 1.73);
    assert(candidate(1L, 2L, 3L) == -1L);
    assert(candidate(10L, 5L, 7L) == 16.25);
    assert(candidate(2L, 6L, 3L) == -1L);
    assert(candidate(1L, 1L, 1L) == 0.43);
    assert(candidate(2L, 2L, 10L) == -1L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.
Example:
    # 1+2 is less than the maximum possible weight, but it's unbalanced.
    # it's balanced, but 3+2+3 is more than the maximum possible weight.
    # 3+2+3 is less than the maximum possible weight, and it's balanced.
    # 3 is less than the maximum possible weight, and it's balanced.
*/
bool will_it_fly(long[] q, long w)

unittest
{
    alias candidate = will_it_fly;

    assert(candidate([3L, 2L, 3L], 9L) == true);
    assert(candidate([1L, 2L], 5L) == false);
    assert(candidate([3L], 5L) == true);
    assert(candidate([3L, 2L, 3L], 1L) == false);
    assert(candidate([1L, 2L, 3L], 6L) == false);
    assert(candidate([5L], 5L) == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given an array arr of integers, find the minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change one element to any other element.
For example:
*/
long smallest_change(long[] arr)

unittest
{
    alias candidate = smallest_change;

    assert(candidate([1L, 2L, 3L, 5L, 4L, 7L, 9L, 6L]) == 4L);
    assert(candidate([1L, 2L, 3L, 4L, 3L, 2L, 2L]) == 1L);
    assert(candidate([1L, 4L, 2L]) == 1L);
    assert(candidate([1L, 4L, 4L, 2L]) == 1L);
    assert(candidate([1L, 2L, 3L, 2L, 1L]) == 0L);
    assert(candidate([3L, 1L, 1L, 3L]) == 0L);
    assert(candidate([1L]) == 0L);
    assert(candidate([0L, 1L]) == 1L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list less than the other list.
if the two lists have the same number of chars, return the first list.
Examples
*/
string[] total_match(string[] lst1, string[] lst2)

unittest
{
    alias candidate = total_match;

    assert(candidate([], []) == []);
    assert(candidate(["hi", "admin"], ["hi", "hi"]) == ["hi", "hi"]);
    assert(candidate(["hi", "admin"], ["hi", "hi", "admin", "project"]) == ["hi", "admin"]);
    assert(candidate(["4"], ["1", "2", "3", "4", "5"]) == ["4"]);
    assert(candidate(["hi", "admin"], ["hI", "Hi"]) == ["hI", "Hi"]);
    assert(candidate(["hi", "admin"], ["hI", "hi", "hi"]) == ["hI", "hi", "hi"]);
    assert(candidate(["hi", "admin"], ["hI", "hi", "hii"]) == ["hi", "admin"]);
    assert(candidate([], ["this"]) == []);
    assert(candidate(["this"], []) == []);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
    30 = 2 * 3 * 5
*/
bool is_multiply_prime(long a)

unittest
{
    alias candidate = is_multiply_prime;

    assert(candidate(5L) == false);
    assert(candidate(30L) == true);
    assert(candidate(8L) == true);
    assert(candidate(10L) == false);
    assert(candidate(125L) == true);
    assert(candidate(105L) == true);
    assert(candidate(126L) == false);
    assert(candidate(729L) == false);
    assert(candidate(891L) == false);
    assert(candidate(1001L) == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if n**int=x
For example:
*/
bool is_simple_power(long x, long n)

unittest
{
    alias candidate = is_simple_power;

    assert(candidate(16L, 2L) == true);
    assert(candidate(143214L, 16L) == false);
    assert(candidate(4L, 2L) == true);
    assert(candidate(9L, 3L) == true);
    assert(candidate(16L, 4L) == true);
    assert(candidate(24L, 2L) == false);
    assert(candidate(128L, 4L) == false);
    assert(candidate(12L, 6L) == false);
    assert(candidate(1L, 1L) == true);
    assert(candidate(1L, 12L) == true);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function that takes an integer a and returns True
if this ingeger is a cube of some integer number.
Note: you may assume the input is always valid.
Examples:
*/
bool iscube(long a)

unittest
{
    alias candidate = iscube;

    assert(candidate(1L) == true);
    assert(candidate(2L) == false);
    assert(candidate(-1L) == true);
    assert(candidate(64L) == true);
    assert(candidate(180L) == false);
    assert(candidate(1000L) == true);
    assert(candidate(0L) == true);
    assert(candidate(1729L) == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You have been tasked to write a function that receives
a hexadecimal number as a string and counts the number of hexadecimal
digits that are primes (prime number, or a prime, is a natural number
greater than 1 that is not a product of two smaller natural numbers).
Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
So you have to determine a number of the following digits: 2, 3, 5, 7,
B (=decimal 11), D (=decimal 13).
Note: you may assume the input is always correct or empty string,
and symbols A,B,C,D,E,F are always uppercase.
Examples:
*/
long hex_key(string num)

unittest
{
    alias candidate = hex_key;

    assert(candidate("AB") == 1L);
    assert(candidate("1077E") == 2L);
    assert(candidate("ABED1A33") == 4L);
    assert(candidate("2020") == 2L);
    assert(candidate("123456789ABCDEF0") == 6L);
    assert(candidate("112233445566778899AABBCCDDEEFF00") == 12L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1'.
There will be an extra couple of characters 'db' at the beginning and at the end of the string.
The extra characters are there to help with the format.
Examples:
*/
string decimal_to_binary(long decimal)

unittest
{
    alias candidate = decimal_to_binary;

    assert(candidate(0L) == "db0db");
    assert(candidate(32L) == "db100000db");
    assert(candidate(103L) == "db1100111db");
    assert(candidate(15L) == "db1111db");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 Filter an input list of strings only for ones that contain given substring
*/
string[] filter_by_substring(string[] strings, string substring)

unittest
{
    alias candidate = filter_by_substring;

    assert(candidate([], "john") == []);
    assert(candidate(["xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx"], "xxx") == ["xxx", "xxxAAA", "xxx"]);
    assert(candidate(["xxx", "asd", "aaaxxy", "john doe", "xxxAAA", "xxx"], "xx") == ["xxx", "aaaxxy", "xxxAAA", "xxx"]);
    assert(candidate(["grunt", "trumpet", "prune", "gruesome"], "run") == ["grunt", "prune"]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example:
*/
bool is_happy(string s)

unittest
{
    alias candidate = is_happy;

    assert(candidate("a") == false);
    assert(candidate("aa") == false);
    assert(candidate("abcd") == true);
    assert(candidate("aabb") == false);
    assert(candidate("adb") == true);
    assert(candidate("xyy") == false);
    assert(candidate("iopaxpoi") == true);
    assert(candidate("iopaxioi") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
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:
*/
string[] numerical_letter_grade(float[] grades)


Prompt:
import std.math;
import std.typecons;
/*
Write a function that takes a string and returns True if the string
length is a prime number or False otherwise
Examples
*/
bool prime_length(string string)

unittest
{
    alias candidate = prime_length;

    assert(candidate("Hello") == true);
    assert(candidate("abcdcba") == true);
    assert(candidate("kittens") == true);
    assert(candidate("orange") == false);
    assert(candidate("wow") == true);
    assert(candidate("world") == true);
    assert(candidate("MadaM") == true);
    assert(candidate("Wow") == true);
    assert(candidate("") == false);
    assert(candidate("HI") == true);
    assert(candidate("go") == true);
    assert(candidate("gogo") == false);
    assert(candidate("aaaaaaaaaaaaaaa") == false);
    assert(candidate("Madam") == true);
    assert(candidate("M") == false);
    assert(candidate("0") == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
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
*/
string solve(long N)

unittest
{
    alias candidate = solve;

    assert(candidate(1000L) == "1");
    assert(candidate(150L) == "110");
    assert(candidate(147L) == "1100");
    assert(candidate(333L) == "1001");
    assert(candidate(963L) == "10010");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
*/
long add(long[] lst)

unittest
{
    alias candidate = add;

    assert(candidate([4L, 88L]) == 88L);
    assert(candidate([4L, 5L, 6L, 7L, 2L, 122L]) == 122L);
    assert(candidate([4L, 0L, 6L, 7L]) == 0L);
    assert(candidate([4L, 4L, 6L, 8L]) == 12L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
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:
*/
string anti_shuffle(string s)

unittest
{
    alias candidate = anti_shuffle;

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


Prompt:
import std.math;
import std.typecons;
/*
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:
*/
Tuple!(long, long)[] get_row(long[][] lst, long x)


Prompt:
import std.math;
import std.typecons;
/*
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:
*/
long[] sort_array(long[] array)

unittest
{
    alias candidate = sort_array;

    assert(candidate([]) == []);
    assert(candidate([5L]) == [5L]);
    assert(candidate([2L, 4L, 3L, 0L, 1L, 5L]) == [0L, 1L, 2L, 3L, 4L, 5L]);
    assert(candidate([2L, 4L, 3L, 0L, 1L, 5L, 6L]) == [6L, 5L, 4L, 3L, 2L, 1L, 0L]);
    assert(candidate([2L, 1L]) == [1L, 2L]);
    assert(candidate([15L, 42L, 87L, 32L, 11L, 0L]) == [0L, 11L, 15L, 32L, 42L, 87L]);
    assert(candidate([21L, 14L, 23L, 11L]) == [23L, 21L, 14L, 11L]);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
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:
*/
string encrypt(string s)

unittest
{
    alias candidate = encrypt;

    assert(candidate("hi") == "lm");
    assert(candidate("asdfghjkl") == "ewhjklnop");
    assert(candidate("gf") == "kj");
    assert(candidate("et") == "ix");
    assert(candidate("faewfawefaewg") == "jeiajeaijeiak");
    assert(candidate("hellomyfriend") == "lippsqcjvmirh");
    assert(candidate("dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh") == "hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl");
    assert(candidate("a") == "e");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 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.
*/
Tuple!(long, long) sum_product(long[] numbers)

unittest
{
    alias candidate = sum_product;

    assert(candidate([]) == tuple(0L, 1L));
    assert(candidate([1L, 1L, 1L]) == tuple(3L, 1L));
    assert(candidate([100L, 0L]) == tuple(100L, 0L));
    assert(candidate([3L, 5L, 7L]) == tuple(15L, 105L));
    assert(candidate([10L]) == tuple(10L, 10L));
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
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.
*/
Nullable!(long) next_smallest(long[] lst)

unittest
{
    alias candidate = next_smallest;

{
        auto result = candidate([1L, 2L, 3L, 4L, 5L]);
        assert(!result.isNull && result.get == 2L);
}

{
        auto result = candidate([5L, 1L, 4L, 3L, 2L]);
        assert(!result.isNull && result.get == 2L);
}

{
        auto result = candidate([]);
        assert(result.isNull);
}

{
        auto result = candidate([1L, 1L]);
        assert(result.isNull);
}

{
        auto result = candidate([1L, 1L, 1L, 1L, 0L]);
        assert(!result.isNull && result.get == 1L);
}

{
        auto result = candidate([1L, 1L]);
        assert(result.isNull);
}

{
        auto result = candidate([-35L, 34L, 12L, -45L]);
        assert(!result.isNull && result.get == -35L);
}

}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
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:
*/
long is_bored(string S)

unittest
{
    alias candidate = is_bored;

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