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_81_numerical_letter_grade | swift |
/// 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 th... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_81_numerical_letter_grade.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(numerical_letter_grade(grades: [4.0, 3, 1.7, 2, 3.5]) == ["... | [
"\n}"
] |
HumanEval_82_prime_length | swift |
/// 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
func prime_length(string: String) -> Bool {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_82_prime_length.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(prime_length(string: "Hello") == true)
assert(prime_length(... | [
"\n}"
] |
HumanEval_83_starts_one_ends | swift |
/// Given a positive integer n, return the count of the numbers of n-digit
/// positive integers that start or end with 1.
func starts_one_ends(n: Int) -> Int {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_83_starts_one_ends.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(starts_one_ends(n: 1) == 1)
assert(starts_one_ends(n: 2) ==... | [
"\n}"
] |
HumanEval_84_solve | swift |
/// 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".
/// Varia... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_84_solve.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(solve(N: 1000) == "1")
assert(solve(N: 150) == "110")
asser... | [
"\n}"
] |
HumanEval_85_add | swift |
/// Given a non-empty list of integers lst. add the even elements that are at odd indices..
/// Examples:
/// add([4, 2, 6, 7]) ==> 2
func add(lst: [Int]) -> Int {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_85_add.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(add(lst: [4, 88]) == 88)
assert(add(lst: [4, 5, 6, 7, 2, 12... | [
"\n}"
] |
HumanEval_86_anti_shuffle | swift |
/// 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 b... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_86_anti_shuffle.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(anti_shuffle(s: "Hi") == "Hi")
assert(anti_shuffle(s: "hell... | [
"\n}"
] |
HumanEval_87_get_row | swift |
/// 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 c... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_87_get_row.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(get_row(lst: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2... | [
"\n}"
] |
HumanEval_88_sort_array | swift |
/// 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 c... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_88_sort_array.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sort_array(array: [] as [Int]) == [] as [Int])
assert(sort_... | [
"\n}"
] |
HumanEval_89_encrypt | swift |
/// 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('asdfgh... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_89_encrypt.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(encrypt(s: "hi") == "lm")
assert(encrypt(s: "asdfghjkl") ==... | [
"\n}"
] |
HumanEval_8_sum_product | swift |
/// 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)
func sum_product(numbers: [Int]) -> (Int, Int) {... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_8_sum_product.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sum_product(numbers: [] as [Int]) == (0, 1))
assert(sum_pro... | [
"\n}"
] |
HumanEval_90_next_smallest | swift |
/// 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
func... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_90_next_smallest.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(next_smallest(lst: [1, 2, 3, 4, 5]) == 2)
assert(next_small... | [
"\n}"
] |
HumanEval_91_is_bored | swift |
/// 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 w... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_91_is_bored.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_bored(S: "Hello world") == 0)
assert(is_bored(S: "Is the... | [
"\n}"
] |
HumanEval_92_any_int | swift |
/// 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) ➞ Fal... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_92_any_int.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(any_int(x: 2, y: 3, z: 1) == true)
assert(any_int(x: 2.5, y... | [
"\n}"
] |
HumanEval_93_encode | swift |
/// 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 | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(encode(message: "TEST") == "tgst")
assert(encode(message: "... | [
"\n}"
] |
HumanEval_94_skjkasdkd | swift |
/// 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,... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_94_skjkasdkd.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(skjkasdkd(lst: [0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32... | [
"\n}"
] |
HumanEval_95_check_dict_case | swift |
/// 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":"ap... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_95_check_dict_case.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(check_dict_case(dict: ["p" : "pineapple", "b" : "banana"]) ... | [
"\n}"
] |
HumanEval_96_count_up_to | swift |
/// 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) => ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_96_count_up_to.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(count_up_to(n: 5) == [2, 3])
assert(count_up_to(n: 6) == [2... | [
"\n}"
] |
HumanEval_97_multiply | swift |
/// 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.
func ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_97_multiply.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(multiply(a: 148, b: 412) == 16)
assert(multiply(a: 19, b: 2... | [
"\n}"
] |
HumanEval_98_count_upper | swift |
/// 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
func count_upper(s: String) -> Int {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_98_count_upper.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(count_upper(s: "aBCdEf") == 1)
assert(count_upper(s: "abcde... | [
"\n}"
] |
HumanEval_99_closest_integer | swift |
/// 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 | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(closest_integer(value: "10") == 10)
assert(closest_integer(... | [
"\n}"
] |
HumanEval_9_rolling_max | swift |
/// 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]
func rolling_max(numbers: [Int]) -> [Int] {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_9_rolling_max.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(rolling_max(numbers: [] as [Int]) == [] as [Int])
assert(ro... | [
"\n}"
] |
HumanEval_0_has_close_elements | swift |
/// Check if in given list of numbers, are any two numbers closer to each other than
/// given threshold.
func has_close_elements(numbers: [Double], threshold: Double) -> Bool {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_0_has_close_elements.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(has_close_elements(numbers: [1.0, 2.0, 3.9, 4.0, 5.0, 2.2],... | [
"\n}"
] |
HumanEval_100_make_a_pile | swift |
/// Given a positive integer n, you have to make a pile of n levels of stones.
/// The first level has n stones.
/// The number of stones in the next level is:
/// - the next odd number if n is odd.
/// - the next even number if n is even.
/// Return the number of stones in each level in a list, where element at index... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_100_make_a_pile.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(make_a_pile(n: 3) == [3, 5, 7])
assert(make_a_pile(n: 4) ==... | [
"\n}"
] |
HumanEval_101_words_string | swift |
/// 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:
func words_string(s: String) -> [String] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_101_words_string.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(words_string(s: "Hi, my name is John") == ["Hi", "my", "nam... | [
"\n}"
] |
HumanEval_102_choose_num | swift |
/// 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:
func choose_num(x: Int, y: Int) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_102_choose_num.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(choose_num(x: 12, y: 15) == 14)
assert(choose_num(x: 13, y:... | [
"\n}"
] |
HumanEval_103_rounded_avg | swift |
extension Int: Error {}
/// You are given two positive integers n and m, and your task is to compute the
/// average of the integers from n through m (including n and m).
/// Round the answer to the nearest integer and convert that to binary.
/// If n is greater than m, return -1.
/// Example:
func rounded_a... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_103_rounded_avg.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(rounded_avg(n: 1, m: 5) == .success("0b11"))
assert(rounded... | [
"\n}"
] |
HumanEval_104_unique_digits | swift |
/// 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:
func unique_digits(x: [Int]) -> [Int] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_104_unique_digits.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(unique_digits(x: [15, 33, 1422, 1]) == [1, 15, 33])
assert(... | [
"\n}"
] |
HumanEval_105_by_length | swift |
/// Given an array of integers, sort the integers that are between 1 and 9 inclusive,
/// reverse the resulting array, and then replace each digit by its corresponding name from
/// "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
/// For example:
/// If the array is empty, return an empty array... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_105_by_length.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(by_length(arr: [2, 1, 1, 4, 5, 8, 2, 3]) == ["Eight", "Five... | [
"\n}"
] |
HumanEval_106_f | swift |
/// 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 | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(f(n: 5) == [1, 2, 6, 24, 15])
assert(f(n: 7) == [1, 2, 6, 2... | [
"\n}"
] |
HumanEval_107_even_odd_palindrome | swift |
/// Given a positive integer n, return a tuple that has the number of even and odd
/// integer palindromes that fall within the range(1, n), inclusive.
/// Example 1:
/// Explanation:
/// Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
/// Example 2:
/// Explanation:
/// Integer palindrom... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_107_even_odd_palindrome.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(even_odd_palindrome(n: 123) == (8, 13))
assert(even_odd_pal... | [
"\n}"
] |
HumanEval_108_count_nums | swift |
/// 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.
func count_nums(arr: [Int]) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_108_count_nums.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(count_nums(arr: [] as [Int]) == 0)
assert(count_nums(arr: [... | [
"\n}"
] |
HumanEval_109_move_one_ball | swift |
/// We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
/// numbers in the array will be randomly ordered. Your task is to determine if
/// it is possible to get an array sorted in non-decreasing order by performing
/// the following operation on the given array:
/// You are allowed to perform right ... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_109_move_one_ball.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(move_one_ball(arr: [3, 4, 5, 1, 2]) == true)
assert(move_on... | [
"\n}"
] |
HumanEval_10_make_palindrome | swift |
/// 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.
func make_palindrome(string: String) -> S... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_10_make_palindrome.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(make_palindrome(string: "") == "")
assert(make_palindrome(s... | [
"\n}"
] |
HumanEval_110_exchange | swift |
/// In this problem, you will implement a function that takes two lists of numbers,
/// and determines whether it is possible to perform an exchange of elements
/// between them to make lst1 a list of only even numbers.
/// There is no limit on the number of exchanged elements between lst1 and lst2.
/// If it is possi... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_110_exchange.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(exchange(lst1: [1, 2, 3, 4], lst2: [1, 2, 3, 4]) == "YES")
... | [
"\n}"
] |
HumanEval_111_histogram | swift |
/// 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:
func histogram(test: String) -> [String : Int] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_111_histogram.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(histogram(test: "a b b a") == ["a" : 2, "b" : 2])
assert(hi... | [
"\n}"
] |
HumanEval_112_reverse_delete | swift |
/// Task
/// We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
/// then check if the result string is palindrome.
/// A string is called palindrome if it reads the same backward as forward.
/// You should return a tuple containing the result string and T... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_112_reverse_delete.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(reverse_delete(s: "abcde", c: "ae") == ("bcd", false))
asse... | [
"\n}"
] |
HumanEval_113_odd_count | swift |
/// 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.
func odd_count(lst: [Str... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_113_odd_count.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(odd_count(lst: ["1234567"]) == ["the number of odd elements... | [
"\n}"
] |
HumanEval_114_minSubArraySum | swift |
/// Given an array of integers nums, find the minimum sum of any non-empty sub-array
/// of nums.
/// Example
func minSubArraySum(nums: [Int]) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_114_minSubArraySum.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(minSubArraySum(nums: [2, 3, 4, 1, 2, 4]) == 1)
assert(minSu... | [
"\n}"
] |
HumanEval_115_max_fill | swift |
/// You are given a rectangular grid of wells. Each row represents a single well,
/// and each 1 in a row represents a single unit of water.
/// Each well has a corresponding bucket that can be used to extract water from it,
/// and all buckets have the same capacity.
/// Your task is to use the buckets to empty the ... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_115_max_fill.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(max_fill(grid: [[0, 0, 1, 0], [0, 1, 0, 0], [1, 1, 1, 1]], ... | [
"\n}"
] |
HumanEval_116_sort_array | swift |
/// 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:
func sort_array(arr: [Int]) -> [Int] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_116_sort_array.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sort_array(arr: [1, 5, 2, 3, 4]) == [1, 2, 4, 3, 5])
assert... | [
"\n}"
] |
HumanEval_117_select_words | swift |
/// Given a string s and a natural number n, you have been tasked to implement
/// a function that returns a list of all words from string s that contain exactly
/// n consonants, in order these words appear in the string s.
/// If the string s is empty then the function should return an empty list.
/// Note: you ma... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_117_select_words.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(select_words(s: "Mary had a little lamb", n: 4) == ["little... | [
"\n}"
] |
HumanEval_118_get_closest_vowel | swift |
/// You are given a word. Your task is to find the closest vowel that stands between
/// two consonants from the right side of the word (case sensitive).
/// Vowels in the beginning and ending doesn't count. Return empty string if you didn't
/// find any vowel met the above condition.
/// You may assume that the giv... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_118_get_closest_vowel.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(get_closest_vowel(word: "yogurt") == "u")
assert(get_closes... | [
"\n}"
] |
HumanEval_119_match_parens | swift |
/// You are given a list of two strings, both strings consist of open
/// parentheses '(' or close parentheses ')' only.
/// Your job is to check if it is possible to concatenate the two strings in
/// some order, that the resulting string will be good.
/// A string S is considered to be good if and only if all parent... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_119_match_parens.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(match_parens(lst: ["()(", ")"]) == "Yes")
assert(match_pare... | [
"\n}"
] |
HumanEval_11_string_xor | swift |
/// 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.
func string_xor(a: String, b: String) -> String {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_11_string_xor.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(string_xor(a: "111000", b: "101010") == "010010")
assert(st... | [
"\n}"
] |
HumanEval_120_maximum | swift |
/// Given an array arr of integers and a positive integer k, return a sorted list
/// of length k with the maximum k numbers in arr.
/// Example 1:
/// Example 2:
/// Example 3:
/// Note:
/// 1. The length of the array will be in the range of [1, 1000].
/// 2. The elements in the array will be in the range of [-1000,... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_120_maximum.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(maximum(arr: [-3, -4, 5], k: 3) == [-4, -3, 5])
assert(maxi... | [
"\n}"
] |
HumanEval_121_solution | swift |
/// Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
/// Examples
func solution(lst: [Int]) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_121_solution.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(solution(lst: [5, 8, 7, 1]) == 12)
assert(solution(lst: [3,... | [
"\n}"
] |
HumanEval_122_add_elements | swift |
/// 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)
func add_elements(arr: [Int], k: Int) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_122_add_elements.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(add_elements(arr: [1, -2, -3, 41, 57, 76, 87, 88, 99], k: 3... | [
"\n}"
] |
HumanEval_123_get_odd_collatz | swift |
/// Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
/// The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
/// as follows: start with any positive integer n. Then each term is obtained from the
/// previous term as follows: if the prev... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_123_get_odd_collatz.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(get_odd_collatz(n: 14) == [1, 5, 7, 11, 13, 17])
assert(get... | [
"\n}"
] |
HumanEval_124_valid_date | swift |
/// You have to write a function which validates a given date string and
/// returns True if the date is valid otherwise False.
/// The date is valid if all of the following rules are satisfied:
/// 1. The date string is not empty.
/// 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_124_valid_date.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(valid_date(date: "03-11-2000") == true)
assert(valid_date(d... | [
"\n}"
] |
HumanEval_125_split_words | swift |
extension Int: Error {}
/// Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
/// should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
/// alphabet, ord('a') = 0, ord('b') = 1, ... or... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_125_split_words.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(split_words(txt: "Hello world!") == .success(["Hello", "wor... | [
"\n}"
] |
HumanEval_126_is_sorted | swift |
/// 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
func is_sorted(lst: [Int]) -> Bool {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_126_is_sorted.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_sorted(lst: [5]) == true)
assert(is_sorted(lst: [1, 2, 3... | [
"\n}"
] |
HumanEval_127_intersection | swift |
/// You are given two intervals,
/// where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
/// The given intervals are closed which means that the interval (start, end)
/// includes both start and end.
/// For each given interval, it is assumed that its start is less or equal its en... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_127_intersection.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(intersection(interval1: (1, 2), interval2: (2, 3)) == "NO")... | [
"\n}"
] |
HumanEval_128_prod_signs | swift |
/// 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:
func prod_signs(arr: [Int]) -> Int? {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_128_prod_signs.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(prod_signs(arr: [1, 2, 2, -4]) == -9)
assert(prod_signs(arr... | [
"\n}"
] |
HumanEval_129_minPath | swift |
/// Given a grid with N rows and N columns (N >= 2) and a positive integer k,
/// each cell of the grid contains a value. Every integer in the range [1, N * N]
/// inclusive appears exactly once on the cells of the grid.
/// You have to find the minimum path of length k in the grid. You can start
/// from any cell, a... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_129_minPath.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(minPath(grid: [[1, 2, 3], [4, 5, 6], [7, 8, 9]], k: 3) == [... | [
"\n}"
] |
HumanEval_12_longest | swift |
/// 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.
func longest(strings: [String]) -> String? {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_12_longest.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(longest(strings: [] as [String]) == nil)
assert(longest(str... | [
"\n}"
] |
HumanEval_130_tri | swift |
/// Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
/// the last couple centuries. However, what people don't know is Tribonacci sequence.
/// Tribonacci sequence is defined by the recurrence:
/// tri(1) = 3
/// tri(n) = 1 + n / 2, if n is even.
/// tri(n) = tri(n - 1) + tri(n - 2) + tr... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_130_tri.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(tri(n: 3) == [1, 3, 2, 8])
assert(tri(n: 4) == [1, 3, 2, 8,... | [
"\n}"
] |
HumanEval_131_digits | swift |
/// Given a positive integer n, return the product of the odd digits.
/// Return 0 if all digits are even.
/// For example:
func digits(n: Int) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_131_digits.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(digits(n: 5) == 5)
assert(digits(n: 54) == 5)
assert(digits... | [
"\n}"
] |
HumanEval_132_is_nested | swift |
/// 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.
func is_nested(string: String) -> Bool {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_132_is_nested.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_nested(string: "[[]]") == true)
assert(is_nested(string:... | [
"\n}"
] |
HumanEval_133_sum_squares | swift |
/// 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:
func sum_squares(lst: [Double]) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_133_sum_squares.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sum_squares(lst: [1.0, 2.0, 3.0]) == 14)
assert(sum_squares... | [
"\n}"
] |
HumanEval_134_check_if_last_char_is_a_letter | swift |
/// 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:
func check_if_last_char_is_a_letter(txt: String) -> Bool {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_134_check_if_last_char_is_a_letter.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(check_if_last_char_is_a_letter(txt: "apple") == false)
asse... | [
"\n}"
] |
HumanEval_135_can_arrange | swift |
/// 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:
func can_arrange(arr: [Int]) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_135_can_arrange.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(can_arrange(arr: [1, 2, 4, 3, 5]) == 3)
assert(can_arrange(... | [
"\n}"
] |
HumanEval_136_largest_smallest_integers | swift |
/// 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:
func largest_smallest_integers(lst: [Int]) -> (Int?, Int?) {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_136_largest_smallest_integers.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(largest_smallest_integers(lst: [2, 4, 1, 3, 5, 7]) == (nil,... | [
"\n}"
] |
HumanEval_137_compare_one | swift |
enum Value: Equatable, Hashable {
case intValue(Int)
case doubleValue(Double)
case stringValue(String)
}
/// Create a function that takes integers, floats, or strings representing
/// real numbers, and returns the larger variable in its given variable type.
/// Return None if the values are e... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_137_compare_one.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(compare_one(a: .intValue(1), b: .intValue(2)) == .intValue(... | [
"\n}"
] |
HumanEval_138_is_equal_to_sum_even | swift |
/// Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
/// Example
func is_equal_to_sum_even(n: Int) -> Bool {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_138_is_equal_to_sum_even.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(is_equal_to_sum_even(n: 4) == false)
assert(is_equal_to_sum... | [
"\n}"
] |
HumanEval_139_special_factorial | swift |
/// 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.
func special_factorial(n: Int) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_139_special_factorial.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(special_factorial(n: 4) == 288)
assert(special_factorial(n:... | [
"\n}"
] |
HumanEval_13_greatest_common_divisor | swift |
/// Return a greatest common divisor of two integers a and b
func greatest_common_divisor(a: Int, b: Int) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_13_greatest_common_divisor.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(greatest_common_divisor(a: 3, b: 7) == 1)
assert(greatest_c... | [
"\n}"
] |
HumanEval_140_fix_spaces | swift |
/// 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 -
func fix_spaces(text: String) -> String {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_140_fix_spaces.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(fix_spaces(text: "Example") == "Example")
assert(fix_spaces... | [
"\n}"
] |
HumanEval_141_file_name_check | swift |
/// Create a function which takes a string representing a file's name, and returns
/// 'Yes' if the the file's name is valid, and returns 'No' otherwise.
/// A file's name is considered to be valid if and only if all the following conditions
/// are met:
/// - There should not be more than three digits ('0'-'9') in t... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_141_file_name_check.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(file_name_check(file_name: "example.txt") == "Yes")
assert(... | [
"\n}"
] |
HumanEval_142_sum_squares | swift |
/// "
/// This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a
/// multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not
/// change the entries in the list whose in... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_142_sum_squares.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sum_squares(lst: [1, 2, 3]) == 6)
assert(sum_squares(lst: [... | [
"\n}"
] |
HumanEval_143_words_in_sentence | swift |
/// You are given a string representing a sentence,
/// the sentence contains some words separated by a space,
/// and you have to return a string that contains the words from the original sentence,
/// whose lengths are prime numbers,
/// the order of the words in the new string should be the same as the original one... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_143_words_in_sentence.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(words_in_sentence(sentence: "This is a test") == "is")
asse... | [
"\n}"
] |
HumanEval_144_simplify | swift |
/// Your task is to implement a function that will simplify the expression
/// x * n. The function returns True if x * n evaluates to a whole number and False
/// otherwise. Both x and n, are string representation of a fraction, and have the following format,
/// <numerator>/<denominator> where both numerator and deno... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_144_simplify.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(simplify(x: "1/5", n: "5/1") == true)
assert(simplify(x: "1... | [
"\n}"
] |
HumanEval_145_order_by_points | swift |
/// 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:
func order_by_points(nums: [Int]) -> [Int] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_145_order_by_points.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(order_by_points(nums: [1, 11, -1, -11, -12]) == [-1, -11, 1... | [
"\n}"
] |
HumanEval_146_specialFilter | swift |
/// 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:
func specialFilter(nums: [Int]) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_146_specialFilter.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(specialFilter(nums: [5, -2, 1, -5]) == 0)
assert(specialFil... | [
"\n}"
] |
HumanEval_147_get_max_triples | swift |
/// You are given a positive integer n. You have to create an integer array a of length n.
/// For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
/// Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
/// and a[i] + a[j] + a[k] is a multiple of 3.
/// Example :
/// Explanation:
/// a = [1,... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_147_get_max_triples.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(get_max_triples(n: 5) == 1)
assert(get_max_triples(n: 6) ==... | [
"\n}"
] |
HumanEval_148_bf | swift |
/// There are eight planets in our solar system: the closerst to the Sun
/// is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
/// Uranus, Neptune.
/// Write a function that takes two planet names as strings planet1 and planet2.
/// The function should return a tuple containing all planets whose... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_148_bf.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(bf(planet1: "Jupiter", planet2: "Neptune") == ["Saturn", "U... | [
"\n}"
] |
HumanEval_149_sorted_list_sum | swift |
/// Write a function that accepts a list of strings as a parameter,
/// deletes the strings that have odd lengths from it,
/// and returns the resulted list with a sorted order,
/// The list is always a list of strings and never an array of numbers,
/// and it may contain duplicates.
/// The order of the list should b... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_149_sorted_list_sum.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sorted_list_sum(lst: ["aa", "a", "aaa"]) == ["aa"])
assert(... | [
"\n}"
] |
HumanEval_14_all_prefixes | swift |
/// Return list of all prefixes from shortest to longest of the input string
func all_prefixes(string: String) -> [String] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_14_all_prefixes.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(all_prefixes(string: "") == [] as [String])
assert(all_pref... | [
"\n}"
] |
HumanEval_150_x_or_y | swift |
/// 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:
func x_or_y(n: Int, x: Int, y: Int) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_150_x_or_y.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(x_or_y(n: 7, x: 34, y: 12) == 34)
assert(x_or_y(n: 15, x: 8... | [
"\n}"
] |
HumanEval_151_double_the_difference | swift |
/// 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.
func double_the_difference(lst: [Double]) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_151_double_the_difference.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(double_the_difference(lst: [] as [Double]) == 0)
assert(dou... | [
"\n}"
] |
HumanEval_152_compare | swift |
/// I think we all remember that feeling when the result of some long-awaited
/// event is finally known. The feelings and thoughts you have at that moment are
/// definitely worth noting down and comparing.
/// Your task is to determine if a person correctly guessed the results of a number of matches.
/// You are giv... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_152_compare.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(compare(game: [1, 2, 3, 4, 5, 1], guess: [1, 2, 3, 4, 2, -2... | [
"\n}"
] |
HumanEval_153_Strongest_Extension | swift |
/// You will be given the name of a class (a string) and a list of extensions.
/// The extensions are to be used to load additional classes to the class. The
/// strength of the extension is as follows: Let CAP be the number of the uppercase
/// letters in the extension's name, and let SM be the number of lowercase le... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_153_Strongest_Extension.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(Strongest_Extension(class_name: "Watashi", extensions: ["tE... | [
"\n}"
] |
HumanEval_154_cycpattern_check | swift |
/// 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
func cycpattern_check(a: String, b: String) -> Bool {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_154_cycpattern_check.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(cycpattern_check(a: "xyzw", b: "xyw") == false)
assert(cycp... | [
"\n}"
] |
HumanEval_155_even_odd_count | swift |
/// Given an integer. return a tuple that has the number of even and odd digits respectively.
/// Example:
func even_odd_count(num: Int) -> (Int, Int) {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_155_even_odd_count.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(even_odd_count(num: 7) == (0, 1))
assert(even_odd_count(num... | [
"\n}"
] |
HumanEval_156_int_to_mini_roman | swift |
/// Given a positive integer, obtain its roman numeral equivalent as a string,
/// and return it in lowercase.
/// Restrictions: 1 <= num <= 1000
/// Examples:
func int_to_mini_roman(number: Int) -> String {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_156_int_to_mini_roman.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(int_to_mini_roman(number: 19) == "xix")
assert(int_to_mini_... | [
"\n}"
] |
HumanEval_157_right_angle_triangle | swift |
/// 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:
func right_angle_triangle(a: Int, b: Int, c: Int) -> Bool {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_157_right_angle_triangle.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(right_angle_triangle(a: 3, b: 4, c: 5) == true)
assert(righ... | [
"\n}"
] |
HumanEval_158_find_max | swift |
/// 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.
func find_max(words: [String]) -> String... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_158_find_max.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(find_max(words: ["name", "of", "string"]) == "string")
asse... | [
"\n}"
] |
HumanEval_159_eat | swift |
/// You're a hungry rabbit, and you already have eaten a certain number of carrots,
/// but now you need to eat more carrots to complete the day's meals.
/// you should return an array of [ total number of eaten carrots after your meals,
/// the number of carrots left after your meals ]
/// if there are not enough rem... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_159_eat.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(eat(number: 5, need: 6, remaining: 10) == [11, 4])
assert(e... | [
"\n}"
] |
HumanEval_15_string_sequence | swift |
/// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
func string_sequence(n: Int) -> String {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_15_string_sequence.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(string_sequence(n: 0) == "0")
assert(string_sequence(n: 3) ... | [
"\n}"
] |
HumanEval_161_solve | swift |
/// 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
func solve(s: String) -> String {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_161_solve.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(solve(s: "AsDf") == "aSdF")
assert(solve(s: "1234") == "432... | [
"\n}"
] |
HumanEval_162_string_to_md5 | swift |
/// Given a string 'text', return its md5 hash equivalent string.
/// If 'text' is an empty string, return None.
func string_to_md5(text: String) -> String? {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_162_string_to_md5.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(string_to_md5(text: "Hello world") == "3e25960a79dbc69b674c... | [
"\n}"
] |
HumanEval_163_generate_integers | swift |
/// Given two positive integers a and b, return the even digits between a
/// and b, in ascending order.
/// For example:
func generate_integers(a: Int, b: Int) -> [Int] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_163_generate_integers.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(generate_integers(a: 2, b: 10) == [2, 4, 6, 8])
assert(gene... | [
"\n}"
] |
HumanEval_16_count_distinct_characters | swift |
/// Given a string, find out how many distinct characters (regardless of case) does it consist of
func count_distinct_characters(string: String) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_16_count_distinct_characters.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(count_distinct_characters(string: "") == 0)
assert(count_di... | [
"\n}"
] |
HumanEval_17_parse_music | swift |
/// Input to this function is a string representing musical notes in a special ASCII format.
/// Your task is to parse this string and return list of integers corresponding to how many beats does each
/// not last.
/// Here is a legend:
/// 'o' - whole note, lasts four beats
/// 'o|' - half note, lasts two beats
/// '... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_17_parse_music.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(parse_music(music_string: "") == [] as [Int])
assert(parse_... | [
"\n}"
] |
HumanEval_18_how_many_times | swift |
/// Find how many times a given substring can be found in the original string. Count overlaping cases.
func how_many_times(string: String, substring: String) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_18_how_many_times.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(how_many_times(string: "", substring: "x") == 0)
assert(how... | [
"\n}"
] |
HumanEval_19_sort_numbers | swift |
/// 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
func sort_numbers(numbers: String) -> String {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_19_sort_numbers.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(sort_numbers(numbers: "") == "")
assert(sort_numbers(number... | [
"\n}"
] |
HumanEval_1_separate_paren_groups | swift |
/// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
/// separate those group into separate strings and return the list of those.
/// Separate groups are balanced (each open brace is properly closed) and not nested within each other
/// Ignore any spaces in the input... | remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_1_separate_paren_groups.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(separate_paren_groups(paren_string: "(()()) ((())) () ((())... | [
"\n}"
] |
HumanEval_20_find_closest_elements | swift |
/// 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).
func find_closest_elements(numbers: [Double]) -> (Double, Double) {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_20_find_closest_elements.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(find_closest_elements(numbers: [1.0, 2.0, 3.9, 4.0, 5.0, 2.... | [
"\n}"
] |
HumanEval_21_rescale_to_unit | swift |
/// 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
func rescale_to_unit(numbers: [Double]) -> [Double] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_21_rescale_to_unit.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(rescale_to_unit(numbers: [2.0, 49.9]) == [0.0, 1.0])
assert... | [
"\n}"
] |
HumanEval_22_filter_integers | swift |
/// Filter given list of any python values only for integers
func filter_integers(values: [AnyHashable]) -> [Int] {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_22_filter_integers.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(filter_integers(values: [] as [AnyHashable]) == [] as [Int]... | [
"\n}"
] |
HumanEval_23_strlen | swift |
/// Return length of given string
func strlen(string: String) -> Int {
| remove | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_23_strlen.py | verbatim | }
func ==(left: [(Int, Int)], right: [(Int, Int)]) -> Bool {
if left.count != right.count {
return false
}
for (l, r) in zip(left, right) {
if l != r {
return false
}
}
return true
}
assert(strlen(string: "") == 0)
assert(strlen(string: "x") == 1)
a... | [
"\n}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.