name stringclasses 161
values | language stringclasses 22
values | prompt stringlengths 40 2.27k | doctests stringclasses 3
values | original stringclasses 956
values | prompt_terminology stringclasses 2
values | tests stringlengths 125 5.35k | stop_tokens listlengths 1 7 |
|---|---|---|---|---|---|---|---|
HumanEval_77_iscube | d | 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) ==... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_77_iscube.py | verbatim | 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(172... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_78_hex_key | d | 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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_78_hex_key.py | verbatim | 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... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_79_decimal_to_binary | d | 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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_79_decimal_to_binary.py | verbatim | unittest
{
alias candidate = decimal_to_binary;
assert(candidate(0L) == "db0db");
assert(candidate(32L) == "db100000db");
assert(candidate(103L) == "db1100111db");
assert(candidate(15L) == "db1111db");
}
void main(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_7_filter_by_substring | d | 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)
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_7_filter_by_substring.py | verbatim | 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", "... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_80_is_happy | d | 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_hap... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_80_is_happy.py | verbatim | 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);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_81_numerical_letter_grade | d | 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 ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_81_numerical_letter_grade.py | verbatim | unittest
{
alias candidate = numerical_letter_grade;
assert(candidate([4.0, 3L, 1.7, 2L, 3.5]) == ["A+", "B", "C-", "C", "A-"]);
assert(candidate([1.2]) == ["D+"]);
assert(candidate([0.5]) == ["D-"]);
assert(candidate([0.0]) == ["E"]);
assert(candidate([1.0, 0.3, 1.5, 2.8, 3.3]) == ["D", "D-", ... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_82_prime_length | d | 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 stri... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_82_prime_length.py | verbatim | 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"... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_83_starts_one_ends | d | 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)
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_83_starts_one_ends.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_84_solve | d | 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 ou... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_84_solve.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_85_add | d | 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)
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_85_add.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_86_anti_shuffle | d | 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 ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_86_anti_shuffle.py | verbatim | 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(c... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_87_get_row | d | 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
e... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_87_get_row.py | verbatim | unittest
{
alias candidate = get_row;
assert(candidate([[1L, 2L, 3L, 4L, 5L, 6L], [1L, 2L, 3L, 4L, 1L, 6L], [1L, 2L, 3L, 4L, 5L, 1L]], 1L) == [tuple(0L, 0L), tuple(1L, 4L), tuple(1L, 0L), tuple(2L, 5L), tuple(2L, 0L)]);
assert(candidate([[1L, 2L, 3L, 4L, 5L, 6L], [1L, 2L, 3L, 4L, 5L, 6L], [1L, 2L, 3L, 4L, ... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_88_sort_array | d | 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 e... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_88_sort_array.py | verbatim | 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]... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_89_encrypt | d | 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'
enc... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_89_encrypt.py | verbatim | 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"... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_8_sum_product | d | 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_produ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_8_sum_product.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_90_next_smallest | d | 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]) ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_90_next_smallest.py | verbatim | 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([]);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_91_is_bored | d | 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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_91_is_bored.py | verbatim | 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(candid... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_92_any_int | d | 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, ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_92_any_int.py | verbatim | 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);
asser... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_93_encode | d | 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'... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_93_encode.py | verbatim | 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");
}... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_94_skjkasdkd | d | 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 ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_94_skjkasdkd.py | verbatim | unittest
{
alias candidate = skjkasdkd;
assert(candidate([0L, 3L, 2L, 1L, 3L, 5L, 7L, 4L, 5L, 5L, 5L, 2L, 181L, 32L, 4L, 32L, 3L, 2L, 32L, 324L, 4L, 3L]) == 10L);
assert(candidate([1L, 0L, 1L, 8L, 2L, 4597L, 2L, 1L, 3L, 40L, 1L, 2L, 1L, 2L, 4L, 2L, 5L, 1L]) == 25L);
assert(candidate([1L, 3L, 1L, 32L, 5... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_95_check_dict_case | d | 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_di... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_95_check_dict_case.py | verbatim | 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(ca... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_96_count_up_to | d | 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_t... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_96_count_up_to.py | verbatim | unittest
{
alias candidate = count_up_to;
assert(candidate(5L) == [2L, 3L]);
assert(candidate(6L) == [2L, 3L, 5L]);
assert(candidate(7L) == [2L, 3L, 5L]);
assert(candidate(10L) == [2L, 3L, 5L, 7L]);
assert(candidate(0L) == []);
assert(candidate(22L) == [2L, 3L, 5L, 7L, 11L, 13L, 17L, 19L]);... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_97_multiply | d | 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 2... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_97_multiply.py | verbatim | 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) =... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_98_count_upper | d | 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)
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_98_count_upper.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_99_closest_integer | d | 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 ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_99_closest_integer.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_9_rolling_max | d | 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)
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_9_rolling_max.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_0_has_close_elements | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_0_has_close_elements.py | verbatim | unittest
{
alias candidate = has_close_elements;
assert(candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3) == true);
assert(candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05) == false);
assert(candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.95) == true);
assert(candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.8) == false);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_100_make_a_pile | d | 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 in... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_100_make_a_pile.py | verbatim | 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]);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_101_words_string | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_101_words_string.py | verbatim | 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(candid... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_102_choose_num | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_102_choose_num.py | verbatim | 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, ... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_104_unique_digits | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_104_unique_digits.py | verbatim | unittest
{
alias candidate = unique_digits;
assert(candidate([15L, 33L, 1422L, 1L]) == [1L, 15L, 33L]);
assert(candidate([152L, 323L, 1422L, 10L]) == []);
assert(candidate([12345L, 2033L, 111L, 151L]) == [111L, 151L]);
assert(candidate([135L, 103L, 31L]) == [31L, 135L]);
}
void main(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_105_by_length | d | 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 arra... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_105_by_length.py | verbatim | 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"]);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_106_f | d | 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 *... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_106_f.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_107_even_odd_palindrome | d | 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:
Ex... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_107_even_odd_palindrome.py | verbatim | 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, ... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_108_count_nums | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_108_count_nums.py | verbatim | 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(candi... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_109_move_one_ball | d | 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 a... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_109_move_one_ball.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_10_make_palindrome | d | 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_p... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_10_make_palindrome.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_110_exchange | d | 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 ... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_110_exchange.py | verbatim | 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(ca... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_111_histogram | d | 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(stri... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_111_histogram.py | verbatim | 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 ... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_112_reverse_delete | d | 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... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_112_reverse_delete.py | verbatim | 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(... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_113_odd_count | d | 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.
... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_113_odd_count.py | verbatim | 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."]);
asser... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_114_minSubArraySum | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_114_minSubArraySum.py | verbatim | unittest
{
alias candidate = minSubArraySum;
assert(candidate([2L, 3L, 4L, 1L, 2L, 4L]) == 1L);
assert(candidate([-1L, -2L, -3L]) == -6L);
assert(candidate([-1L, -2L, -3L, 2L, -10L]) == -14L);
assert(candidate([-9999999999999999L]) == -9999999999999999L);
assert(candidate([0L, 10L, 20L, 1000000... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_115_max_fill | d | 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 b... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_115_max_fill.py | verbatim | unittest
{
alias candidate = max_fill;
assert(candidate([[0L, 0L, 1L, 0L], [0L, 1L, 0L, 0L], [1L, 1L, 1L, 1L]], 1L) == 6L);
assert(candidate([[0L, 0L, 1L, 1L], [0L, 0L, 0L, 0L], [1L, 1L, 1L, 1L], [0L, 1L, 1L, 1L]], 2L) == 5L);
assert(candidate([[0L, 0L, 0L], [0L, 0L, 0L]], 5L) == 0L);
assert(candid... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_116_sort_array | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_116_sort_array.py | verbatim | unittest
{
alias candidate = sort_array;
assert(candidate([1L, 5L, 2L, 3L, 4L]) == [1L, 2L, 4L, 3L, 5L]);
assert(candidate([-2L, -3L, -4L, -5L, -6L]) == [-4L, -2L, -6L, -5L, -3L]);
assert(candidate([1L, 0L, 2L, 3L, 4L]) == [0L, 1L, 2L, 4L, 3L]);
assert(candidate([]) == []);
assert(candidate([2L... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_117_select_words | d | 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 empt... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_117_select_words.py | verbatim | 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("... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_118_get_closest_vowel | d | 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... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_118_get_closest_vowel.py | verbatim | 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");
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_119_match_parens | d | 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 an... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_119_match_parens.py | verbatim | unittest
{
alias candidate = match_parens;
assert(candidate(["()(", ")"]) == "Yes");
assert(candidate([")", ")"]) == "No");
assert(candidate(["(()(())", "())())"]) == "No");
assert(candidate([")())", "(()()("]) == "Yes");
assert(candidate(["(())))", "(()())(("]) == "Yes");
assert(candidate(... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_11_string_xor | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_11_string_xor.py | verbatim | unittest
{
alias candidate = string_xor;
assert(candidate("111000", "101010") == "010010");
assert(candidate("1", "1") == "0");
assert(candidate("0101", "0000") == "0101");
}
void main(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_120_maximum | d | 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 ... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_120_maximum.py | verbatim | unittest
{
alias candidate = maximum;
assert(candidate([-3L, -4L, 5L], 3L) == [-4L, -3L, 5L]);
assert(candidate([4L, -4L, 4L], 2L) == [4L, 4L]);
assert(candidate([-3L, 2L, 1L, 2L, -1L, -2L, 1L], 1L) == [2L]);
assert(candidate([123L, -123L, 20L, 0L, 1L, 2L, -3L], 3L) == [2L, 20L, 123L]);
assert(... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_121_solution | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_121_solution.py | verbatim | 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]) ... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_122_add_elements | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_122_add_elements.py | verbatim | 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... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_123_get_odd_collatz | d | 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... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_123_get_odd_collatz.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_124_valid_date | d | 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... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_124_valid_date.py | verbatim | 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);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_126_is_sorted | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_126_is_sorted.py | verbatim | 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(ca... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_127_intersection | d | 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 ... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_127_intersection.py | verbatim | 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... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_128_prod_signs | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_128_prod_signs.py | verbatim | 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])... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_129_minPath | d | 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 st... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_129_minPath.py | verbatim | unittest
{
alias candidate = minPath;
assert(candidate([[1L, 2L, 3L], [4L, 5L, 6L], [7L, 8L, 9L]], 3L) == [1L, 2L, 1L]);
assert(candidate([[5L, 9L, 3L], [4L, 1L, 6L], [7L, 8L, 2L]], 1L) == [1L]);
assert(candidate([[1L, 2L, 3L, 4L], [5L, 6L, 7L, 8L], [9L, 10L, 11L, 12L], [13L, 14L, 15L, 16L]], 4L) == [1... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_12_longest | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_12_longest.py | verbatim | 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(!r... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_130_tri | d | 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) +... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_130_tri.py | verbatim | 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]);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_131_digits | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_131_digits.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_132_is_nested | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_132_is_nested.py | verbatim | unittest
{
alias candidate = is_nested;
assert(candidate("[[]]") == true);
assert(candidate("[]]]]]]][[[[[]") == false);
assert(candidate("[][]") == false);
assert(candidate("[]") == false);
assert(candidate("[[[[]]]]") == true);
assert(candidate("[]]]]]]]]]]") == false);
assert(candida... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_133_sum_squares | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_133_sum_squares.py | verbatim | unittest
{
alias candidate = sum_squares;
assert(candidate([1.0, 2.0, 3.0]) == 14L);
assert(candidate([1.0, 2.0, 3.0]) == 14L);
assert(candidate([1.0, 3.0, 5.0, 7.0]) == 84L);
assert(candidate([1.4, 4.2, 0.0]) == 29L);
assert(candidate([-2.4, 1.0, 1.0]) == 6L);
assert(candidate([100.0, 1.0,... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_134_check_if_last_char_is_a_letter | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_134_check_if_last_char_is_a_letter.py | verbatim | 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") == fa... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_135_can_arrange | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_135_can_arrange.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_136_largest_smallest_integers | d | 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_... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_136_largest_smallest_integers.py | verbatim | 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);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_138_is_equal_to_sum_even | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_138_is_equal_to_sum_even.py | verbatim | 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(... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_139_special_factorial | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_139_special_factorial.py | verbatim | unittest
{
alias candidate = special_factorial;
assert(candidate(4L) == 288L);
assert(candidate(5L) == 34560L);
assert(candidate(7L) == 125411328000L);
assert(candidate(1L) == 1L);
}
void main(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_13_greatest_common_divisor | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_13_greatest_common_divisor.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_140_fix_spaces | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_140_fix_spaces.py | verbatim | 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(" E... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_141_file_name_check | d | 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 d... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_141_file_name_check.py | verbatim | 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") ... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_142_sum_squares | d | 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 entr... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_142_sum_squares.py | verbatim | unittest
{
alias candidate = sum_squares;
assert(candidate([1L, 2L, 3L]) == 6L);
assert(candidate([1L, 4L, 9L]) == 14L);
assert(candidate([]) == 0L);
assert(candidate([1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L]) == 9L);
assert(candidate([-1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L]) == -3L);
asser... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_143_words_in_sentence | d | 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... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_143_words_in_sentence.py | verbatim | 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(candi... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_144_simplify | d | 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... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_144_simplify.py | verbatim | 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);... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_145_order_by_points | d | 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[] num... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_145_order_by_points.py | verbatim | unittest
{
alias candidate = order_by_points;
assert(candidate([1L, 11L, -1L, -11L, -12L]) == [-1L, -11L, 1L, -12L, 11L]);
assert(candidate([1234L, 423L, 463L, 145L, 2L, 423L, 423L, 53L, 6L, 37L, 3457L, 3L, 56L, 0L, 46L]) == [0L, 2L, 3L, 6L, 53L, 423L, 423L, 423L, 1234L, 145L, 37L, 46L, 56L, 463L, 3457L]);... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_146_specialFilter | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_146_specialFilter.py | verbatim | 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,... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_147_get_max_triples | d | 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... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_147_get_max_triples.py | verbatim | unittest
{
alias candidate = get_max_triples;
assert(candidate(5L) == 1L);
assert(candidate(6L) == 4L);
assert(candidate(10L) == 36L);
assert(candidate(100L) == 53361L);
}
void main(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_149_sorted_list_sum | d | 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 t... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_149_sorted_list_sum.py | verbatim | 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(c... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_14_all_prefixes | d | import std.math;
import std.typecons;
/*
Return list of all prefixes from shortest to longest of the input string
*/
string[] all_prefixes(string string)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_14_all_prefixes.py | verbatim | unittest
{
alias candidate = all_prefixes;
assert(candidate("") == []);
assert(candidate("asdfgh") == ["a", "as", "asd", "asdf", "asdfg", "asdfgh"]);
assert(candidate("WWW") == ["W", "WW", "WWW"]);
}
void main(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_150_x_or_y | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_150_x_or_y.py | verbatim | 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);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_151_double_the_difference | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_151_double_the_difference.py | verbatim | unittest
{
alias candidate = double_the_difference;
assert(candidate([]) == 0L);
assert(candidate([5.0, 4.0]) == 25L);
assert(candidate([0.1, 0.2, 0.3]) == 0L);
assert(candidate([-10.0, -20.0, -30.0]) == 0L);
assert(candidate([-1.0, -2.0, 8.0]) == 0L);
assert(candidate([0.2, 3.0, 5.0]) == 3... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_152_compare | d | 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 ... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_152_compare.py | verbatim | unittest
{
alias candidate = compare;
assert(candidate([1L, 2L, 3L, 4L, 5L, 1L], [1L, 2L, 3L, 4L, 2L, -2L]) == [0L, 0L, 0L, 0L, 3L, 3L]);
assert(candidate([0L, 0L, 0L, 0L, 0L, 0L], [0L, 0L, 0L, 0L, 0L, 0L]) == [0L, 0L, 0L, 0L, 0L, 0L]);
assert(candidate([1L, 2L, 3L], [-1L, -2L, -3L]) == [2L, 4L, 6L]);
... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_153_Strongest_Extension | d | 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 th... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_153_Strongest_Extension.py | verbatim | 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", "N... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_154_cycpattern_check | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_154_cycpattern_check.py | verbatim | 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... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_155_even_odd_count | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_155_even_odd_count.py | verbatim | 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... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_156_int_to_mini_roman | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_156_int_to_mini_roman.py | verbatim | 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");
as... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_157_right_angle_triangle | d | 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) ... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_157_right_angle_triangle.py | verbatim | 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);... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_158_find_max | d | 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_m... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_158_find_max.py | verbatim | 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", "... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_159_eat | d | 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... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_159_eat.py | verbatim | 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... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_15_string_sequence | d | import std.math;
import std.typecons;
/*
Return a string containing space-delimited numbers starting from 0 upto n inclusive.
*/
string string_sequence(long n)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_15_string_sequence.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_161_solve | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_161_solve.py | verbatim | 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... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_162_string_to_md5 | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_162_string_to_md5.py | verbatim | 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(!r... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_163_generate_integers | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_163_generate_integers.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_16_count_distinct_characters | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_16_count_distinct_characters.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_17_parse_music | d | 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, last... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_17_parse_music.py | verbatim | 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|") ... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_18_how_many_times | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_18_how_many_times.py | verbatim | 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(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_19_sort_numbers | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_19_sort_numbers.py | verbatim | 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 th... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_1_separate_paren_groups | d | 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
Ignor... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_1_separate_paren_groups.py | verbatim | unittest
{
alias candidate = separate_paren_groups;
assert(candidate("(()()) ((())) () ((())()())") == ["(()())", "((()))", "()", "((())()())"]);
assert(candidate("() (()) ((())) (((())))") == ["()", "(())", "((()))", "(((())))"]);
assert(candidate("(()(())((())))") == ["(()(())((())))"]);
assert(c... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_20_find_closest_elements | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_20_find_closest_elements.py | verbatim | unittest
{
alias candidate = find_closest_elements;
assert(candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2]) == tuple(3.9, 4.0));
assert(candidate([1.0, 2.0, 5.9, 4.0, 5.0]) == tuple(5.0, 5.9));
assert(candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == tuple(2.0, 2.2));
assert(candidate([1.0, 2.0, 3.0, 4.0, 5.0,... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_21_rescale_to_unit | d | 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)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_21_rescale_to_unit.py | verbatim | unittest
{
alias candidate = rescale_to_unit;
assert(candidate([2.0, 49.9]) == [0.0, 1.0]);
assert(candidate([100.0, 49.9]) == [1.0, 0.0]);
assert(candidate([1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]);
assert(candidate([2.0, 1.0, 5.0, 3.0, 4.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]);
a... | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
HumanEval_23_strlen | d | import std.math;
import std.typecons;
/*
Return length of given string
*/
long strlen(string string)
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_23_strlen.py | verbatim | unittest
{
alias candidate = strlen;
assert(candidate("") == 0L);
assert(candidate("x") == 1L);
assert(candidate("asdasnakj") == 9L);
}
void main(){} | [
"\n\n",
"\nvoid",
"\nbool",
"\nint"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.