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_66_digitSum | swift |
/// Task
/// Write a function that takes a string as input and returns the sum of the upper characters only'
/// ASCII codes.
/// Examples:
/// >>> digitSum(s: "")
/// 0
/// >>> digitSum(s: "abAB")
/// 131
/// >>> digitSum(s: "abcCd")
/// 67
/// >>> digitSum(s: "helloE")
/// 69
/// >>> digitSum(s: "woArBld")
/// 131
/... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_66_digitSum.py | reworded | }
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(digitSum(s: "") == 0)
assert(digitSum(s: "abAB") == 131)
as... | [
"\n}"
] |
HumanEval_67_fruit_distribution | swift |
/// In this task, you will be given a string that represents a number of apples and oranges
/// that are distributed in a basket of fruit this basket contains
/// apples, oranges, and mango fruits. Given the string that represents the total number of
/// the oranges and apples and an integer that represent the tota... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_67_fruit_distribution.py | reworded | }
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(fruit_distribution(s: "5 apples and 6 oranges", n: 19) == 8... | [
"\n}"
] |
HumanEval_68_pluck | swift |
/// "Given an array representing a branch of a tree that has non-negative integer nodes
/// your task is to pluck one of the nodes and return it.
/// The plucked node should be the node with the smallest even value.
/// If multiple nodes with the same smallest even value are found return the node that has smallest ind... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_68_pluck.py | reworded | }
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(pluck(arr: [4, 2, 3]) == [2, 1])
assert(pluck(arr: [1, 2, 3... | [
"\n}"
] |
HumanEval_69_search | swift |
/// You are given a non-empty array of positive integers. Return the greatest integer that is greater than
/// zero, and has a frequency greater than or equal to the value of the integer itself.
/// The frequency of an integer is the number of times it appears in the array.
/// If no such a value exist, return -1.
/... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_69_search.py | reworded | }
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(search(lst: [5, 5, 5, 5, 1]) == 1)
assert(search(lst: [4, 1... | [
"\n}"
] |
HumanEval_6_parse_nested_parens | swift |
/// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
/// For each of the group, output the deepest level of nesting of parentheses.
/// E.g. (()()) has maximum two levels of nesting while ((())) has three.
/// >>> parse_nested_parens(paren_string: "(()()) ((())... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_6_parse_nested_parens.py | reworded | }
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_nested_parens(paren_string: "(()()) ((())) () ((())()... | [
"\n}"
] |
HumanEval_70_strange_sort_list | swift |
/// Given array of integers, return array in strange order.
/// Strange sorting, is when you start with the minimum value,
/// then maximum of the remaining integers, then minimum and so on.
/// Examples:
/// >>> strange_sort_list(lst: [1, 2, 3, 4])
/// [1, 4, 2, 3]
/// >>> strange_sort_list(lst: [5, 5, 5, 5])
/// [5,... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_70_strange_sort_list.py | reworded | }
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(strange_sort_list(lst: [1, 2, 3, 4]) == [1, 4, 2, 3])
asser... | [
"\n}"
] |
HumanEval_71_triangle_area | swift |
/// Given the lengths of the three sides of a triangle. Return the area of
/// the triangle rounded to 2 decimal points if the three sides form a valid triangle.
/// Otherwise return -1
/// Three sides make a valid triangle when the sum of any two sides is greater
/// than the third side.
/// Example:
/// >>> triang... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_71_triangle_area.py | reworded | }
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(triangle_area(a: 3, b: 4, c: 5) == 6.0)
assert(triangle_are... | [
"\n}"
] |
HumanEval_72_will_it_fly | swift |
/// Write a function that returns true if the object q will fly, and false otherwise.
/// The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
/// Example:
/// >>> will_it_fly(q: [1, 2], w: 5)
/// false
/// # 1+2 is less tha... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_72_will_it_fly.py | reworded | }
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(will_it_fly(q: [3, 2, 3], w: 9) == true)
assert(will_it_fly... | [
"\n}"
] |
HumanEval_73_smallest_change | swift |
/// Given an array arr of integers, find the minimum number of elements that
/// need to be changed to make the array palindromic. A palindromic array is an array that
/// is read the same backwards and forwards. In one change, you can change one element to any other element.
/// For example:
/// >>> smallest_change(a... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_73_smallest_change.py | reworded | }
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(smallest_change(arr: [1, 2, 3, 5, 4, 7, 9, 6]) == 4)
assert... | [
"\n}"
] |
HumanEval_74_total_match | swift |
/// Write a function that accepts two arrays of strings and returns the array that has
/// total number of chars in the all strings of the array less than the other array.
/// if the two arrays have the same number of chars, return the first array.
/// Examples
/// >>> total_match(lst1: [] as [String], lst2: [] as [S... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_74_total_match.py | reworded | }
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(total_match(lst1: [] as [String], lst2: [] as [String]) == ... | [
"\n}"
] |
HumanEval_75_is_multiply_prime | swift |
/// Write a function that returns true if the given number is the multiplication of 3 prime numbers
/// and false otherwise.
/// Knowing that (a) is less then 100.
/// Example:
/// >>> is_multiply_prime(a: 30)
/// true
/// 30 = 2 * 3 * 5
func is_multiply_prime(a: Int) -> Bool {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_75_is_multiply_prime.py | reworded | }
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_multiply_prime(a: 5) == false)
assert(is_multiply_prime(... | [
"\n}"
] |
HumanEval_76_is_simple_power | swift |
/// Your task is to write a function that returns true if a number x is a simple
/// power of n and false in other cases.
/// x is a simple power of n if n**int=x
/// For example:
/// >>> is_simple_power(x: 1, n: 4)
/// true
/// >>> is_simple_power(x: 2, n: 2)
/// true
/// >>> is_simple_power(x: 8, n: 2)
/// true
/// ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_76_is_simple_power.py | reworded | }
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_simple_power(x: 16, n: 2) == true)
assert(is_simple_powe... | [
"\n}"
] |
HumanEval_77_iscube | swift |
/// 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(a: 1)
/// true
/// >>> iscube(a: 2)
/// false
/// >>> iscube(a: -1)
/// true
/// >>> iscube(a: 64)
/// true
/// >>> iscub... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_77_iscube.py | reworded | }
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(iscube(a: 1) == true)
assert(iscube(a: 2) == false)
assert(... | [
"\n}"
] |
HumanEval_78_hex_key | swift |
/// You have been tasked to write a function that receives
/// a hexadecimal number as a string and counts the number of hexadecimal
/// digits that are primes (prime number, or a prime, is a natural number
/// greater than 1 that is not a product of two smaller natural numbers).
/// Hexadecimal digits are 0, 1, 2,... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_78_hex_key.py | reworded | }
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(hex_key(num: "AB") == 1)
assert(hex_key(num: "1077E") == 2)... | [
"\n}"
] |
HumanEval_79_decimal_to_binary | swift |
/// You will be given a number in decimal form and your task is to convert it to
/// binary format. The function should return a string, with each character representing a binary
/// number. Each character in the string will be '0' or '1'.
/// There will be an extra couple of characters 'db' at the beginning and at th... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_79_decimal_to_binary.py | reworded | }
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(decimal_to_binary(decimal: 0) == "db0db")
assert(decimal_to... | [
"\n}"
] |
HumanEval_7_filter_by_substring | swift |
/// Filter an input array of strings only for ones that contain given substring
/// >>> filter_by_substring(strings: [] as [String], substring: "a")
/// [] as [String]
/// >>> filter_by_substring(strings: ["abc", "bacd", "cde", "array"], substring: "a")
/// ["abc", "bacd", "array"]
func filter_by_substring(strings: [S... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_7_filter_by_substring.py | reworded | }
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_by_substring(strings: [] as [String], substring: "jo... | [
"\n}"
] |
HumanEval_80_is_happy | swift |
/// You are given a string s.
/// Your task is to check if the string is hapswift or not.
/// A string is hapswift if its length is at least 3 and every 3 consecutive letters are distinct
/// For example:
/// >>> is_happy(s: "a")
/// false
/// >>> is_happy(s: "aa")
/// false
/// >>> is_happy(s: "abcd")
/// true
/// >>... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_80_is_happy.py | reworded | }
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_happy(s: "a") == false)
assert(is_happy(s: "aa") == fals... | [
"\n}"
] |
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 an array of GPAs for some students and you have to write
/// a function ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_81_numerical_letter_grade.py | reworded | }
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(string: "Hello")
/// true
/// >>> prime_length(string: "abcdcba")
/// true
/// >>> prime_length(string: "kittens")
/// true
/// >>> prime_length(string: "orange")
//... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_82_prime_length.py | reworded | }
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 {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_83_starts_one_ends.py | reworded | }
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
/// >>> solve(N: 1000)
/// "1"
/// >>> solve(N: 150)
/// "110"
/// >>> solve(N: 147)
/// "1100"
/// Variables:
/// @N integer
/// Constraints: 0 ≤ N ≤ 10000.
/// Output:
/// a string of binary number
func solve(N: Int) -> String ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_84_solve.py | reworded | }
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 array of integers lst. add the even elements that are at odd indices..
/// Examples:
/// >>> add(lst: [4, 2, 6, 7])
/// 2
func add(lst: [Int]) -> Int {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_85_add.py | reworded | }
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... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_86_anti_shuffle.py | reworded | }
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 arrays,
/// 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 array,
/// and return array of tuples, [(x1, y1), (x2, y2) ...] such that
/// each tuple is ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_87_get_row.py | reworded | }
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 coswift 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'... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_88_sort_array.py | reworded | }
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(s: "hi")
/// "lm"
/// >>> encrypt(... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_89_encrypt.py | reworded | }
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 array of integers, return a tuple consisting of a sum and a product of all the integers in an array.
/// Empty sum should be equal to 0 and empty product should be equal to 1.
/// >>> sum_product(numbers: [] as [Int])
/// (0, 1)
/// >>> sum_product(numbers: [1, 2, 3, 4])
/// (10, 24)
func sum_product(n... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_8_sum_product.py | reworded | }
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 an array of integers.
/// Write a function next_smallest() that returns the 2nd smallest element of the array.
/// Return nil if there is no such element.
/// >>> next_smallest(lst: [1, 2, 3, 4, 5])
/// 2
/// >>> next_smallest(lst: [5, 1, 4, 3, 2])
/// 2
/// >>> next_smallest(lst: [] as [Int])
/// ni... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_90_next_smallest.py | reworded | }
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(S: "Hello world")
/// 0
/// >>> is_bored(S: "The sky is blue. The sun is shining. I love ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_91_is_bored.py | reworded | }
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(x: 5, y: 2, z: 7)
/// true
/// >>> any_int(x: 3, y: 2, z: 2)
/// false
/// >>> any_int(x: 3, y: -2, z... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_92_any_int.py | reworded | }
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(message: "test")
/// "TGST... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_93_encode.py | reworded | }
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 an array of integers.
/// You need to find the largest prime value and return the sum of its digits.
/// Examples:
/// >>> skjkasdkd(lst: [0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])
/// 10
/// >>> skjkasdkd(lst: [1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1]... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_94_skjkasdkd.py | reworded | }
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_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(n: 5)
/// [2, 3]
/// >>> count_up_to(n: 11)
/// [2, 3, 5, 7]
/// >>> count_up_to(n: 0)
/// [] as [Int]
/// >>> count_up_to(n: 20)
///... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_96_count_up_to.py | reworded | }
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(a: 148, b: 412)
/// 16
/// >>> multiply(a: 19, b: 28)
/// 72
/// >>> multiply(a: 2020, b: 1851)
/// 0
/// >>> multiply(a: 14, b: -15)
/// 20
func mul... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_97_multiply.py | reworded | }
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(s: "aBCdEf")
/// 1
/// >>> count_upper(s: "abcdefg")
/// 0
/// >>> count_upper(s: "dBBE")
/// 0
func count_upper(s: String) -> Int {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_98_count_upper.py | reworded | }
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(value: "10")
/// 10
/// >>> closest_integer(value: "15.3")
/// 15
/// Note:
/// Rounding a... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_99_closest_integer.py | reworded | }
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 array of integers, generate an array of rolling maximum element found until given moment
/// in the sequence.
/// >>> rolling_max(numbers: [1, 2, 3, 2, 3, 4, 2])
/// [1, 2, 3, 3, 3, 4, 4]
func rolling_max(numbers: [Int]) -> [Int] {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_9_rolling_max.py | reworded | }
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.
/// >>> has_close_elements(numbers: [1.0, 2.0, 3.0], threshold: 0.5)
/// false
/// >>> has_close_elements(numbers: [1.0, 2.8, 3.0, 4.0, 5.0, 2.0], threshold: 0.3)
/// true
func has_close_elements(numbers: [Double]... | transform | /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... | transform | /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:
/// >>> words_string(s: "Hi, my name is John")
/// ["Hi", "my", "name", "is", "John"]
/// >>> words_string(s: "One, two, three, four, five, six")
///... | transform | /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:
/// >>> choose_num(x: 12, y: 15)
/// 14
/// >>> choose_num(x: 13, y: 12)
/// -1
func choose_nu... | transform | /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:
/// >>> rounde... | transform | /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:
/// >>> unique_digits(x: [15, 33, 1422, 1])
/// [1, 15, 33]
/// >>> unique_digits(x: [152, 323, 1422, 10])
/// [] as [Int]
func u... | transform | /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:
/// >>> by_length(arr: [2, 1, 1, 4, 5, 8, 2, 3])... | transform | /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 *... | transform | /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:
/// >>> even_odd_palindrome(n: 3)
/// (1, 2)
/// Explanation:
/// Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
/// Exam... | transform | /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.
/// >>> count_nums(arr: [] as [Int])
/// 0
/// >>> count_nums(a... | transform | /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 ... | transform | /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.
/// >>> make_palindrome(string: "")
/// "... | transform | /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... | transform | /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:
/// >>> histogram(test: "a b c")
/// ["a" : 1, "b" : 1, "c" : 1]
... | transform | /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... | transform | /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.
/// >>> odd_count(lst: [... | transform | /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
/// >>> minSubArraySum(nums: [2, 3, 4, 1, 2, 4])
/// 1
/// >>> minSubArraySum(nums: [-1, -2, -3])
/// -6
func minSubArraySum(nums: [Int]) -> Int {
| transform | /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 ... | transform | /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:
/// >>> sort_array(arr: [1, 5, 2, 3, 4])
/// [1, 2, 3, 4, 5]
/// >>>... | transform | /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... | transform | /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... | transform | /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... | transform | /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.
/// >>> string_xor(a: "010", b: "110")
/// "100"
func string_xor(a: String, b: String) -> String {
| transform | /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:
/// >>> maximum(arr: [-3, -4, 5], k: 3)
/// [-4, -3, 5]
/// Example 2:
/// >>> maximum(arr: [4, -4, 4], k: 2)
/// [4, 4]
/// Example 3:
/// >>> maximum(arr: [-3, 2, 1, 2,... | transform | /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
/// >>> solution(lst: [5, 8, 7, 1])
/// 12
/// >>> solution(lst: [3, 3, 3, 3, 3])
/// 9
/// >>> solution(lst: [30, 13, 24, 321])
/// 0
func solution(lst: [Int]) -> Int {
| transform | /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:
/// >>> add_elements(arr: [111, 21, 3, 4000, 5, 6, 7, 8, 9], k: 4)
/// 24
/// Constraints:
/// 1. 1 <= len(arr) <= 100
/// 2. 1 <= k <= len(arr)
func a... | transform | /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... | transform | /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,... | transform | /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... | transform | /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
/// >>> is_sorted(lst: [5])
/// true
/// >>> is_sorted(lst: [1, 2, 3, 4, 5])
/// true
/// >>> is_... | transform | /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... | transform | /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:
/// >>> prod_signs(arr: [1, 2, 2, -4])
/// 9
/// >>> prod_signs(arr: [0, 1... | transform | /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... | transform | /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.
/// >>> longest(strings: [] as [String])
/// nil
/// >>> longest(strings: ["a", "b", "c"])
/// "a"
/// >>> longest(strings: ["a", "bb", "ccc"])
/// "... | transform | /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... | transform | /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:
/// >>> digits(n: 1)
/// 1
/// >>> digits(n: 4)
/// 0
/// >>> digits(n: 235)
/// 15
func digits(n: Int) -> Int {
| transform | /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.
/// >>> is_nested(string: "[[]]")
/// true
/// >>> is_nested(string: "[]]]]]]... | transform | /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:
/// >>> sum_squares(lst: [1.0, 2.0, 3.0])
/// 14
/// >>> sum_squares(lst: [1.0, 4.0, 9.0])
/// 98
/// >>> sum_squares(lst: [1.0, 3.... | transform | /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:
/// >>> check_if_last_char_is_a_letter(txt: "apple pie")
/// false
/// >>> c... | transform | /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:
/// >>> can_arrange(arr: [1, 2, 4, 3, 5])
/// 3
/// >>> ... | transform | /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:
/// >>> largest_smallest_integers(lst: [2, 4, 1, 3, 5, 7])
/// (nil, 1)
... | transform | /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... | transform | /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
/// >>> is_equal_to_sum_even(n: 4)
/// false
/// >>> is_equal_to_sum_even(n: 6)
/// false
/// >>> is_equal_to_sum_even(n: 8)
/// true
func is_equal_to_sum_even(n: Int) -> Bool {
| transform | /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:
/// >>> special_factorial(n: 4)
/// 288
/// The function will receive an integer as input and should return the special
/// factorial of this integer.
func special_factorial(n: Int) ... | transform | /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
/// >>> greatest_common_divisor(a: 3, b: 5)
/// 1
/// >>> greatest_common_divisor(a: 25, b: 15)
/// 5
func greatest_common_divisor(a: Int, b: Int) -> Int {
| transform | /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 -
/// >>> fix_spaces(text: " Example")
/// "Example"
/// >>> fix_spaces(text: " Example 1")
/// "Example_1"
/// >>> fix_spaces(text: " Example 2")
... | transform | /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... | transform | /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_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... | transform | /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... | transform | /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:
/// >>> order_by_points(nums: [1, 11, -1, -11, -12])
///... | transform | /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:
/// >>> specialFilter(nums: [15, -73, 14, -15])
/// 1
/// >>> specialFilter(nums: [33, -2,... | transform | /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 :
/// >>> get_max_triples(n: 5)... | transform | /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_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... | transform | /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
/// >>> all_prefixes(string: "abc")
/// ["a", "ab", "abc"]
func all_prefixes(string: String) -> [String] {
| transform | /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:
/// >>> x_or_y(n: 7, x: 34, y: 12)
/// 34
/// >>> x_or_y(n: 15, x: 8, y: 5)
/// 5
func x_or_y(n: Int, x: Int, y: Int) -> Int {
| transform | /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.
/// >>> double_the_difference(lst: [1, 3, 2, 0])
/// 10
/// >>> double_the_difference(lst: [-1, -2, 0])
/// 0
/// >>> double_the_difference(lst: [9, -2])
/// 81
/// >>> ... | transform | /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... | transform | /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... | transform | /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
/// >>> cycpattern_check(a: "abcd", b: "abd")
/// false
/// >>> cycpattern_check(a: "hello", b: "ell")
/// true
/// >>> cycpattern_check(a: "whassup", b: "psus")
/// false
/// >>> cycpattern_c... | transform | /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:
/// >>> even_odd_count(num: -12)
/// (1, 1)
/// >>> even_odd_count(num: 123)
/// (1, 2)
func even_odd_count(num: Int) -> (Int, Int) {
| transform | /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:
/// >>> int_to_mini_roman(number: 19)
/// "xix"
/// >>> int_to_mini_roman(number: 152)
/// "clii"
/// >>> int_to_mini_roman(number: 426)
/// "cdxxvi"
func int_... | transform | /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:
/// >>> right_angle_triangle(a: 3, b: 4, c: 5)
/// true
/// >>> right_ang... | transform | /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.
/// >>> find_max(words: ["name", "of", "... | transform | /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}"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.