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:
smallest_change([1,2,3,5,4,7,9,6]) == 4
smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
smallest_change([1, 2, 3, 2, 1]) == 0
*/
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
total_match([], []) ➞ []
total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
*/
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:
is_multiply_prime(30) == True
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:
is_simple_power(1, 4) => true
is_simple_power(2, 2) => true
is_simple_power(8, 2) => true
is_simple_power(3, 2) => false
is_simple_power(3, 1) => false
is_simple_power(5, 3) => false
*/
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:
iscube(1) ==> True
iscube(2) ==> False
iscube(-1) ==> True
iscube(64) ==> True
iscube(0) ==> True
iscube(180) ==> False
*/
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:
For num = "AB" the output should be 1.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 4.
For num = "123456789ABCDEF0" the output should be 6.
For num = "2020" the output should be 2.
*/
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:
decimal_to_binary(15)   # returns "db1111db"
decimal_to_binary(32)   # returns "db100000db"
*/
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
>>> filter_by_substring([], 'a')
[]
>>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
['abc', 'bacd', 'array']
*/
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:
is_happy(a) => False
is_happy(aa) => False
is_happy(abcd) => True
is_happy(aabb) => False
is_happy(adb) => True
is_happy(xyy) => False
*/
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:
grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
*/
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
prime_length('Hello') == True
prime_length('abcdcba') == True
prime_length('kittens') == True
prime_length('orange') == False
*/
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 count of the numbers of n-digit
positive integers that start or end with 1.
*/
long starts_one_ends(long n)

unittest
{
    alias candidate = starts_one_ends;

    assert(candidate(1L) == 1L);
    assert(candidate(2L) == 18L);
    assert(candidate(3L) == 180L);
    assert(candidate(4L) == 1800L);
    assert(candidate(5L) == 18000L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a positive integer N, return the total sum of its digits in binary.
Example
    For N = 1000, the sum of digits will be 1 the output should be "1".
    For N = 150, the sum of digits will be 6 the output should be "110".
    For N = 147, the sum of digits will be 12 the output should be "1100".
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:
    add([4, 2, 6, 7]) ==> 2
*/
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:
anti_shuffle('Hi') returns 'Hi'
anti_shuffle('hello') returns 'ehllo'
anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
*/
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:
get_row([
  [1,2,3,4,5,6],
  [1,2,3,4,1,6],
  [1,2,3,4,5,1]
], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
get_row([], 1) == []
get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
*/
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:
* sort_array([]) => []
* sort_array([5]) => [5]
* sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
* sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
*/
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:
encrypt('hi') returns 'lm'
encrypt('asdfghjkl') returns 'ewhjklnop'
encrypt('gf') returns 'kj'
encrypt('et') returns 'ix'
*/
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.
>>> sum_product([])
(0, 1)
>>> sum_product([1, 2, 3, 4])
(10, 24)
*/
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.
next_smallest([1, 2, 3, 4, 5]) == 2
next_smallest([5, 1, 4, 3, 2]) == 2
next_smallest([]) == None
next_smallest([1, 1]) == None
*/
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:
>>> is_bored("Hello world")
0
>>> is_bored("The sky is blue. The sun is shining. I love this weather")
1
*/
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(){}


Prompt:
import std.math;
import std.typecons;
/*
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
Returns false in any other cases.
Examples
any_int(5, 2, 7) ➞ True
any_int(3, 2, 2) ➞ False
any_int(3, -2, 1) ➞ True
any_int(3.6, -2.2, 2) ➞ False
*/
bool any_int(float x, float y, float z)

unittest
{
    alias candidate = any_int;

    assert(candidate(2L, 3L, 1L) == true);
    assert(candidate(2.5, 2L, 3L) == false);
    assert(candidate(1.5, 5L, 3.5) == false);
    assert(candidate(2L, 6L, 2L) == false);
    assert(candidate(4L, 2L, 2L) == true);
    assert(candidate(2.2, 2.2, 2.2) == false);
    assert(candidate(-4L, 6L, 2L) == true);
    assert(candidate(2L, 1L, 1L) == true);
    assert(candidate(3L, 4L, 7L) == true);
    assert(candidate(3.0, 4L, 7L) == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears 2 places ahead of that
vowel in the english alphabet.
Assume only letters.
Examples:
>>> encode('test')
'TGST'
>>> encode('This is a message')
'tHKS KS C MGSSCGG'
*/
string encode(string message)

unittest
{
    alias candidate = encode;

    assert(candidate("TEST") == "tgst");
    assert(candidate("Mudasir") == "mWDCSKR");
    assert(candidate("YES") == "ygs");
    assert(candidate("This is a message") == "tHKS KS C MGSSCGG");
    assert(candidate("I DoNt KnOw WhAt tO WrItE") == "k dQnT kNqW wHcT Tq wRkTg");
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
You are given a list of integers.
You need to find the largest prime value and return the sum of its digits.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
For lst = [0,81,12,3,1,21] the output should be 3
For lst = [0,8,1,2,1,7] the output should be 7
*/
long skjkasdkd(long[] lst)


Prompt:
import std.math;
import std.typecons;
/*
Given a dictionary, return True if all keys are strings in lower
case or all keys are strings in upper case, else return False.
The function should return False is the given dictionary is empty.
Examples:
check_dict_case({"a":"apple", "b":"banana"}) should return True.
check_dict_case({"a":"apple", "A":"banana", "B":"banana"}) should return False.
check_dict_case({"a":"apple", "8":"banana", "a":"apple"}) should return False.
check_dict_case({"Name":"John", "Age":"36", "City":"Houston"}) should return False.
check_dict_case({"STATE":"NC", "ZIP":"12345" }) should return True.
*/
bool check_dict_case(Nullable!(string[string]) dict)

unittest
{
    alias candidate = check_dict_case;

    assert(candidate(["p": "pineapple", "b": "banana"].nullable) == true);
    assert(candidate(["p": "pineapple", "A": "banana", "B": "banana"].nullable) == false);
    assert(candidate(["p": "pineapple", "5": "banana", "a": "apple"].nullable) == false);
    assert(candidate(["Name": "John", "Age": "36", "City": "Houston"].nullable) == false);
    assert(candidate(["STATE": "NC", "ZIP": "12345"].nullable) == true);
    assert(candidate(["fruit": "Orange", "taste": "Sweet"].nullable) == true);
    assert(candidate(Nullable!(string[string]).init) == false);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and less than n.
for example:
count_up_to(5) => [2,3]
count_up_to(11) => [2,3,5,7]
count_up_to(0) => []
count_up_to(20) => [2,3,5,7,11,13,17,19]
count_up_to(1) => []
count_up_to(18) => [2,3,5,7,11,13,17]
*/
long[] count_up_to(long n)


Prompt:
import std.math;
import std.typecons;
/*
Complete the function that takes two integers and returns
the product of their unit digits.
Assume the input is always valid.
Examples:
multiply(148, 412) should return 16.
multiply(19, 28) should return 72.
multiply(2020, 1851) should return 0.
multiply(14,-15) should return 20.
*/
long multiply(long a, long b)

unittest
{
    alias candidate = multiply;

    assert(candidate(148L, 412L) == 16L);
    assert(candidate(19L, 28L) == 72L);
    assert(candidate(2020L, 1851L) == 0L);
    assert(candidate(14L, -15L) == 20L);
    assert(candidate(76L, 67L) == 42L);
    assert(candidate(17L, 27L) == 49L);
    assert(candidate(0L, 1L) == 0L);
    assert(candidate(0L, 0L) == 0L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
Given a string s, count the number of uppercase vowels in even indices.
For example:
count_upper('aBCdEf') returns 1
count_upper('abcdefg') returns 0
count_upper('dBBE') returns 0
*/
long count_upper(string s)

unittest
{
    alias candidate = count_upper;

    assert(candidate("aBCdEf") == 1L);
    assert(candidate("abcdefg") == 0L);
    assert(candidate("dBBE") == 0L);
    assert(candidate("B") == 0L);
    assert(candidate("U") == 1L);
    assert(candidate("") == 0L);
    assert(candidate("EEEE") == 2L);
}
void main(){}


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

unittest
{
    alias candidate = closest_integer;

    assert(candidate("10") == 10L);
    assert(candidate("14.5") == 15L);
    assert(candidate("-15.5") == -16L);
    assert(candidate("15.3") == 15L);
    assert(candidate("0") == 0L);
}
void main(){}


Prompt:
import std.math;
import std.typecons;
/*
 From a given list of integers, generate a list of rolling maximum element found until given moment
in the sequence.
>>> rolling_max([1, 2, 3, 2, 3, 4, 2])
[1, 2, 3, 3, 3, 4, 4]
*/
long[] rolling_max(long[] numbers)

unittest
{
    alias candidate = rolling_max;

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