task_id
stringlengths
18
20
prompt
stringlengths
177
1.43k
entry_point
stringlengths
1
24
test
stringlengths
287
23.1k
description
stringlengths
146
1.37k
language
stringclasses
1 value
canonical_solution
sequencelengths
5
37
HumanEval_kotlin/25
/** * You are an expert Kotlin programmer, and here is your task. * Return list of prime factors of given integer in the order from smallest to largest. * Each of the factors should be listed number of times corresponding to how many times it appeares in factorization. * Input number should be equal to the product of all factors * >>> factorize(8) * [2, 2, 2] * >>> factorize(25) * [5, 5] * >>> factorize(70) * [2, 5, 7] * */ fun factorize(n: Int): List<Int> {
factorize
fun main() { var arg00: Int = 2 var x0: List<Int> = factorize(arg00) var v0: List<Int> = mutableListOf(2) if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 4 var x1: List<Int> = factorize(arg10) var v1: List<Int> = mutableListOf(2, 2) if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 8 var x2: List<Int> = factorize(arg20) var v2: List<Int> = mutableListOf(2, 2, 2) if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 57 var x3: List<Int> = factorize(arg30) var v3: List<Int> = mutableListOf(3, 19) if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 3249 var x4: List<Int> = factorize(arg40) var v4: List<Int> = mutableListOf(3, 3, 19, 19) if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: Int = 185193 var x5: List<Int> = factorize(arg50) var v5: List<Int> = mutableListOf(3, 3, 3, 19, 19, 19) if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: Int = 20577 var x6: List<Int> = factorize(arg60) var v6: List<Int> = mutableListOf(3, 19, 19, 19) if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: Int = 18 var x7: List<Int> = factorize(arg70) var v7: List<Int> = mutableListOf(2, 3, 3) if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return list of prime factors of given integer in the order from smallest to largest. * Each of the factors should be listed number of times corresponding to how many times it appeares in factorization. * Input number should be equal to the product of all factors * >>> factorize(8) * [2, 2, 2] * >>> factorize(25) * [5, 5] * >>> factorize(70) * [2, 5, 7] * */
kotlin
[ "fun factorize(n: Int): List<Int> {", " var curN = n", " val factors = mutableListOf<Int>()", " for (i in 2..n) {", " if (i * i > n) {", " break", " }", " while (curN % i == 0) {", " curN /= i", " factors.add(i)", " }", " }", " if (curN != 1) {", " factors.add(curN)", " }", " return factors", "}", "", "" ]
HumanEval_kotlin/69
/** * You are an expert Kotlin programmer, and here is your task. * * Write a function that returns True if the object q will fly, and False otherwise. * The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w. * Example: * will_it_fly([1, 2], 5) ➞ False * # 1+2 is less than the maximum possible weight, but it's unbalanced. * will_it_fly([3, 2, 3], 1) ➞ False * # it's balanced, but 3+2+3 is more than the maximum possible weight. * will_it_fly([3, 2, 3], 9) ➞ True * # 3+2+3 is less than the maximum possible weight, and it's balanced. * will_it_fly([3], 5) ➞ True * # 3 is less than the maximum possible weight, and it's balanced. * */ fun willItFly(q: List<Int>, w: Int): Boolean {
willItFly
fun main() { var arg00: List<Int> = mutableListOf(3, 2, 3) var arg01: Int = 9 var x0: Boolean = willItFly(arg00, arg01) var v0: Boolean = true if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(1, 2) var arg11: Int = 5 var x1: Boolean = willItFly(arg10, arg11) var v1: Boolean = false if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(3) var arg21: Int = 5 var x2: Boolean = willItFly(arg20, arg21) var v2: Boolean = true if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(3, 2, 3) var arg31: Int = 1 var x3: Boolean = willItFly(arg30, arg31) var v3: Boolean = false if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: List<Int> = mutableListOf(1, 2, 3) var arg41: Int = 6 var x4: Boolean = willItFly(arg40, arg41) var v4: Boolean = false if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: List<Int> = mutableListOf(5) var arg51: Int = 5 var x5: Boolean = willItFly(arg50, arg51) var v5: Boolean = true if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } }
/** * You are an expert Kotlin programmer, and here is your task. * * Write a function that returns True if the object q will fly, and False otherwise. * The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w. * Example: * will_it_fly([1, 2], 5) ➞ False * # 1+2 is less than the maximum possible weight, but it's unbalanced. * will_it_fly([3, 2, 3], 1) ➞ False * # it's balanced, but 3+2+3 is more than the maximum possible weight. * will_it_fly([3, 2, 3], 9) ➞ True * # 3+2+3 is less than the maximum possible weight, and it's balanced. * will_it_fly([3], 5) ➞ True * # 3 is less than the maximum possible weight, and it's balanced. * */
kotlin
[ "fun willItFly(q: List<Int>, w: Int): Boolean {", " val isPalindromic = q == q.reversed()", " val sum = q.sum()", " return isPalindromic && sum <= w", "}", "", "" ]
HumanEval_kotlin/52
/** * You are an expert Kotlin programmer, and here is your task. * Return n-th Fibonacci number. * >>> fib(10) * 55 * >>> fib(1) * 1 * >>> fib(8) * 21 * */ fun fib(n: Int): Int {
fib
fun main() { var arg00: Int = 10 var x0: Int = fib(arg00) var v0: Int = 55 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 1 var x1: Int = fib(arg10) var v1: Int = 1 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 8 var x2: Int = fib(arg20) var v2: Int = 21 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 11 var x3: Int = fib(arg30) var v3: Int = 89 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 12 var x4: Int = fib(arg40) var v4: Int = 144 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return n-th Fibonacci number. * >>> fib(10) * 55 * >>> fib(1) * 1 * >>> fib(8) * 21 * */
kotlin
[ "fun fib(n: Int): Int {", " val fibs = mutableListOf(0, 1)", " while (fibs.size <= n) {", " fibs.add(fibs[fibs.size - 2] + fibs[fibs.size - 1])", " }", " return fibs[n]", "}", "", "" ]
HumanEval_kotlin/6
/** * You are an expert Kotlin programmer, and here is your task. * 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('(()()) ((())) () ((())()())') * [2, 3, 1, 3] * */ fun parseNestedParens(parenString: String): List<Int> {
parseNestedParens
fun main() { var arg00: String = "(()()) ((())) () ((())()())" var x0: List<Int> = parseNestedParens(arg00) var v0: List<Int> = mutableListOf(2, 3, 1, 3) if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "() (()) ((())) (((())))" var x1: List<Int> = parseNestedParens(arg10) var v1: List<Int> = mutableListOf(1, 2, 3, 4) if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "(()(())((())))" var x2: List<Int> = parseNestedParens(arg20) var v2: List<Int> = mutableListOf(4) if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * 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('(()()) ((())) () ((())()())') * [2, 3, 1, 3] * */
kotlin
[ "fun parseNestedParens(parenString: String): List<Int> {", " return parenString.split(\" \").map {", " it.runningFold(0) { balance, char ->", " when (char) {", " '(' -> {", " balance + 1", " }", "", " ')' -> {", " balance - 1", " }", "", " else -> {", " throw Exception(\"Invalid character\")", " }", " }", " }.max()", " }", "}", "", "" ]
HumanEval_kotlin/73
/** * You are an expert Kotlin programmer, and here is your task. * Your task is to write a function that returns true if a number x is a simple * power of n and false in other cases. * x is a simple power of n if n**int=x * For example: * is_simple_power(1, 4) => true * is_simple_power(2, 2) => true * is_simple_power(8, 2) => true * is_simple_power(3, 2) => false * is_simple_power(3, 1) => false * is_simple_power(5, 3) => false * */ fun isSimplePower(x: Int, n: Int): Boolean {
isSimplePower
fun main() { var arg00: Int = 16 var arg01: Int = 2 var x0: Boolean = isSimplePower(arg00, arg01) var v0: Boolean = true if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 143214 var arg11: Int = 16 var x1: Boolean = isSimplePower(arg10, arg11) var v1: Boolean = false if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 4 var arg21: Int = 2 var x2: Boolean = isSimplePower(arg20, arg21) var v2: Boolean = true if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 9 var arg31: Int = 3 var x3: Boolean = isSimplePower(arg30, arg31) var v3: Boolean = true if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 16 var arg41: Int = 4 var x4: Boolean = isSimplePower(arg40, arg41) var v4: Boolean = true if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: Int = 24 var arg51: Int = 2 var x5: Boolean = isSimplePower(arg50, arg51) var v5: Boolean = false if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: Int = 128 var arg61: Int = 4 var x6: Boolean = isSimplePower(arg60, arg61) var v6: Boolean = false if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: Int = 12 var arg71: Int = 6 var x7: Boolean = isSimplePower(arg70, arg71) var v7: Boolean = false if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80: Int = 1 var arg81: Int = 1 var x8: Boolean = isSimplePower(arg80, arg81) var v8: Boolean = true if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90: Int = 1 var arg91: Int = 12 var x9: Boolean = isSimplePower(arg90, arg91) var v9: Boolean = true if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } }
/** * You are an expert Kotlin programmer, and here is your task. * Your task is to write a function that returns true if a number x is a simple * power of n and false in other cases. * x is a simple power of n if n**int=x * For example: * is_simple_power(1, 4) => true * is_simple_power(2, 2) => true * is_simple_power(8, 2) => true * is_simple_power(3, 2) => false * is_simple_power(3, 1) => false * is_simple_power(5, 3) => false * */
kotlin
[ "fun isSimplePower(x: Int, n: Int): Boolean {", " var cur = x", " while (cur > 1 && n > 1 && cur % n == 0) {", " cur /= n", " }", " return cur == 1", "}", "", "" ]
HumanEval_kotlin/83
/** * You are an expert Kotlin programmer, and here is your task. * * Write a function that takes a string and returns an ordered version of it. * Ordered version of a string is a string where all words (separated by space) * are replaced by a new word where all the characters are arranged in * ascending order based on ascii value. * Note: You should keep the order of words and blank spaces in the sentence. * * For example: * anti_shuffle('Hi') returns 'Hi' * anti_shuffle('hello') returns 'ehllo' * anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor' * */ fun antiShuffle(s: String): String {
antiShuffle
fun main() { var arg00: String = "Hi" var x0: String = antiShuffle(arg00) var v0: String = "Hi" if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "hello" var x1: String = antiShuffle(arg10) var v1: String = "ehllo" if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "number" var x2: String = antiShuffle(arg20) var v2: String = "bemnru" if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "abcd" var x3: String = antiShuffle(arg30) var v3: String = "abcd" if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "Hello World!!!" var x4: String = antiShuffle(arg40) var v4: String = "Hello !!!Wdlor" if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: String = "" var x5: String = antiShuffle(arg50) var v5: String = "" if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: String = "Hi. My name is Mister Robot. How are you?" var x6: String = antiShuffle(arg60) var v6: String = ".Hi My aemn is Meirst .Rboot How aer ?ouy" if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * * Write a function that takes a string and returns an ordered version of it. * Ordered version of a string is a string where all words (separated by space) * are replaced by a new word where all the characters are arranged in * ascending order based on ascii value. * Note: You should keep the order of words and blank spaces in the sentence. * * For example: * anti_shuffle('Hi') returns 'Hi' * anti_shuffle('hello') returns 'ehllo' * anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor' * */
kotlin
[ "fun antiShuffle(s: String): String {", " val words = s.split(\" \")", " val sortedWords = words.map { word ->", " if (word.trim().isNotEmpty()) word.toCharArray().sorted().joinToString(\"\") else word", " }", " return sortedWords.joinToString(\" \")", "}", "", "" ]
HumanEval_kotlin/22
/** * You are an expert Kotlin programmer, and here is your task. * Filter given list of any Kotlin values only for integers * >>> filter_integers(['a', 3.14, 5]) * [5] * >>> filter_integers([1, 2, 3, 'abc', {}, []]) * [1, 2, 3] * */ fun filterIntegers(values: List<Any>): List<Any> {
filterIntegers
fun main() { var arg00: List<Any> = mutableListOf() var x0: List<Any> = filterIntegers(arg00) var v0: List<Any> = mutableListOf() if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Any> = mutableListOf(4, mutableMapOf<Any, Any>(), mutableListOf<Any>(), 23.2, 9, "adasd") var x1: List<Any> = filterIntegers(arg10) var v1: List<Any> = mutableListOf(4, 9) if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Any> = mutableListOf(3, "c", 3, 3, "a", "b") var x2: List<Any> = filterIntegers(arg20) var v2: List<Any> = mutableListOf(3, 3, 3) if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * Filter given list of any Kotlin values only for integers * >>> filter_integers(['a', 3.14, 5]) * [5] * >>> filter_integers([1, 2, 3, 'abc', {}, []]) * [1, 2, 3] * */
kotlin
[ "fun filterIntegers(values: List<Any>): List<Any> {", " return values.filterIsInstance<Int>()", "}", "", "" ]
HumanEval_kotlin/26
/** * You are an expert Kotlin programmer, and here is your task. * From a list of integers, remove all elements that occur more than once. * Keep order of elements left the same as in the input. * >>> remove_duplicates([1, 2, 3, 2, 4]) * [1, 3, 4] * */ fun removeDuplicates(numbers: List<Int>): List<Int> {
removeDuplicates
fun main() { var arg00: List<Int> = mutableListOf() var x0: List<Int> = removeDuplicates(arg00) var v0: List<Int> = mutableListOf() if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(1, 2, 3, 4) var x1: List<Int> = removeDuplicates(arg10) var v1: List<Int> = mutableListOf(1, 2, 3, 4) if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(1, 2, 3, 2, 4, 3, 5) var x2: List<Int> = removeDuplicates(arg20) var v2: List<Int> = mutableListOf(1, 4, 5) if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * From a list of integers, remove all elements that occur more than once. * Keep order of elements left the same as in the input. * >>> remove_duplicates([1, 2, 3, 2, 4]) * [1, 3, 4] * */
kotlin
[ "fun removeDuplicates(numbers: List<Int>): List<Int> {", " val occurrenceMap = numbers.groupingBy { it }.eachCount()", " return numbers.filter { occurrenceMap[it] == 1 }", "}", "", "" ]
HumanEval_kotlin/105
/** * You are an expert Kotlin programmer, and here is your task. * * 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([]) == 0 * >>> count_nums([-1, 11, -11]) == 1 * >>> count_nums([1, 1, 2]) == 3 * */ fun countNums(arr: List<Int>): Int {
countNums
fun main() { var arg00: List<Int> = mutableListOf() var x0: Int = countNums(arg00); var v0: Int = 0; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(-1, -2, 0) var x1: Int = countNums(arg10); var v1: Int = 0; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(1, 1, 2, -2, 3, 4, 5) var x2: Int = countNums(arg20); var v2: Int = 6; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(1, 6, 9, -6, 0, 1, 5) var x3: Int = countNums(arg30); var v3: Int = 5; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: List<Int> = mutableListOf(1, 100, 98, -7, 1, -1) var x4: Int = countNums(arg40); var v4: Int = 4; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: List<Int> = mutableListOf(12, 23, 34, -45, -56, 0) var x5: Int = countNums(arg50); var v5: Int = 5; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: List<Int> = mutableListOf(0, 1) var x6: Int = countNums(arg60); var v6: Int = 1; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: List<Int> = mutableListOf(1) var x7: Int = countNums(arg70); var v7: Int = 1; if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * * 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([]) == 0 * >>> count_nums([-1, 11, -11]) == 1 * >>> count_nums([1, 1, 2]) == 3 * */
kotlin
[ "fun countNums(arr: List<Int>): Int {", " fun countDigitSum(num: Int): Int {", " val sign = if (num >= 0) 1 else -1", " var x = Math.abs(num)", " var digitSum = 0", " while (x > 0) {", " if (x < 10) {", " digitSum += x * sign", " break", " } else {", " digitSum += x % 10", " x /= 10", " }", " }", " return digitSum", " }", " return arr.count { countDigitSum(it) > 0 }", "}", "", "" ]
HumanEval_kotlin/35
/** * You are an expert Kotlin programmer, and here is your task. * Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13. * >>> fizz_buzz(50) * 0 * >>> fizz_buzz(78) * 2 * >>> fizz_buzz(79) * 3 * */ fun fizzBuzz(n: Int): Int {
fizzBuzz
fun main() { var arg00: Int = 50 var x0: Int = fizzBuzz(arg00) var v0: Int = 0 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 78 var x1: Int = fizzBuzz(arg10) var v1: Int = 2 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 79 var x2: Int = fizzBuzz(arg20) var v2: Int = 3 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 100 var x3: Int = fizzBuzz(arg30) var v3: Int = 3 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 200 var x4: Int = fizzBuzz(arg40) var v4: Int = 6 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: Int = 4000 var x5: Int = fizzBuzz(arg50) var v5: Int = 192 if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: Int = 10000 var x6: Int = fizzBuzz(arg60) var v6: Int = 639 if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: Int = 100000 var x7: Int = fizzBuzz(arg70) var v7: Int = 8026 if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13. * >>> fizz_buzz(50) * 0 * >>> fizz_buzz(78) * 2 * >>> fizz_buzz(79) * 3 * */
kotlin
[ "fun fizzBuzz(n: Int): Int {", " return (1 until n).map { value ->", " if (value % 11 == 0 || value % 13 == 0) {", " value.toString().count { c -> c == '7' }", " } else {", " 0", " }", " }.sum()", "}", "", "" ]
HumanEval_kotlin/30
/** * You are an expert Kotlin programmer, and here is your task. * Return only positive numbers in the list. * >>> get_positive([-1, 2, -4, 5, 6]) * [2, 5, 6] * >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) * [5, 3, 2, 3, 9, 123, 1] * */ fun getPositive(l: List<Int>): List<Int> {
getPositive
fun main() { var arg00: List<Int> = mutableListOf(-1, -2, 4, 5, 6) var x0: List<Int> = getPositive(arg00) var v0: List<Int> = mutableListOf(4, 5, 6) if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10) var x1: List<Int> = getPositive(arg10) var v1: List<Int> = mutableListOf(5, 3, 2, 3, 3, 9, 123, 1) if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(-1, -2) var x2: List<Int> = getPositive(arg20) var v2: List<Int> = mutableListOf() if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf() var x3: List<Int> = getPositive(arg30) var v3: List<Int> = mutableListOf() if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return only positive numbers in the list. * >>> get_positive([-1, 2, -4, 5, 6]) * [2, 5, 6] * >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) * [5, 3, 2, 3, 9, 123, 1] * */
kotlin
[ "fun getPositive(l: List<Int>): List<Int> {", " return l.filter { it > 0 }", "}", "", "" ]
HumanEval_kotlin/80
/** * You are an expert Kotlin programmer, and here is your task. * * Given a positive integer n, return the count of the numbers of n-digit * positive integers that start or end with 1. * */ fun startsOneEnds(n: Int): Int {
startsOneEnds
fun main() { var arg00: Int = 1 var x0: Int = startsOneEnds(arg00) var v0: Int = 1 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 2 var x1: Int = startsOneEnds(arg10) var v1: Int = 18 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 3 var x2: Int = startsOneEnds(arg20) var v2: Int = 180 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 4 var x3: Int = startsOneEnds(arg30) var v3: Int = 1800 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 5 var x4: Int = startsOneEnds(arg40) var v4: Int = 18000 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * * Given a positive integer n, return the count of the numbers of n-digit * positive integers that start or end with 1. * */
kotlin
[ "fun startsOneEnds(n: Int): Int {", " if (n == 1) {", " return 1", " }", " var answer = 18", " repeat(n - 2) {", " answer *= 10", " }", " return answer", "}", "", "" ]
HumanEval_kotlin/11
/** * You are an expert Kotlin programmer, and here is your task. * 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('010', '110') * '100' * */ fun stringXor(a: String, b: String): String {
stringXor
fun main() { var arg00: String = "111000" var arg01: String = "101010" var x0: String = stringXor(arg00, arg01) var v0: String = "010010" if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "1" var arg11: String = "1" var x1: String = stringXor(arg10, arg11) var v1: String = "0" if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "0101" var arg21: String = "0000" var x2: String = stringXor(arg20, arg21) var v2: String = "0101" if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * 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('010', '110') * '100' * */
kotlin
[ "fun stringXor(a: String, b: String): String {", " return a.indices.map { index ->", " if (a[index] == b[index]) '0' else '1'", " }.joinToString(\"\")", "}", "", "" ]
HumanEval_kotlin/2
/** * You are an expert Kotlin programmer, and here is your task. * Given a positive floating point number, it can be decomposed into * an integer part (largest integer smaller than the given number) and decimals * (leftover part always smaller than 1). * Return the decimal part of the number. * >>> truncate_number(3.5) * 0.5 * */ fun truncateNumber(number: Double): Double {
truncateNumber
fun main() { var arg00: Double = 3.5 var x0: Double = truncateNumber(arg00) var v0: Double = 0.5 if (Math.abs(x0 - v0) > 1e-9) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Double = 1.33 var x1: Double = truncateNumber(arg10) var v1: Double = 0.33 if (Math.abs(x1 - v1) > 1e-9) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Double = 123.456 var x2: Double = truncateNumber(arg20) var v2: Double = 0.456 if (Math.abs(x2 - v2) > 1e-9) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * Given a positive floating point number, it can be decomposed into * an integer part (largest integer smaller than the given number) and decimals * (leftover part always smaller than 1). * Return the decimal part of the number. * >>> truncate_number(3.5) * 0.5 * */
kotlin
[ "fun truncateNumber(number: Double): Double {", " return number - Math.floor(number)", "}", "", "" ]
HumanEval_kotlin/138
/** * You are an expert Kotlin programmer, and here is your task. * Create a function which takes a string representing a file's name, and returns * 'Yes' if the the file's name is valid, and returns 'No' otherwise. * A file's name is considered to be valid if and only if all the following conditions * are met: * - There should not be more than three digits ('0'-'9') in the file's name. * - The file's name contains exactly one dot '.' * - The substring before the dot should not be empty, and it starts with a letter from * the latin alphapet ('a'-'z' and 'A'-'Z'). * - The substring after the dot should be one of these: ['txt', 'exe', 'dll'] * Examples: * file_name_check("example.txt") # => 'Yes' * file_name_check("1example.dll") # => 'No' (the name should start with a latin alphapet letter) * */ fun fileNameCheck(fileName : String) : String {
fileNameCheck
fun main() { var arg00 : String = "example.txt" var x0 : String = fileNameCheck(arg00); var v0 : String = "Yes"; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : String = "1example.dll" var x1 : String = fileNameCheck(arg10); var v1 : String = "No"; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : String = "s1sdf3.asd" var x2 : String = fileNameCheck(arg20); var v2 : String = "No"; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : String = "K.dll" var x3 : String = fileNameCheck(arg30); var v3 : String = "Yes"; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : String = "MY16FILE3.exe" var x4 : String = fileNameCheck(arg40); var v4 : String = "Yes"; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : String = "His12FILE94.exe" var x5 : String = fileNameCheck(arg50); var v5 : String = "No"; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : String = "_Y.txt" var x6 : String = fileNameCheck(arg60); var v6 : String = "No"; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70 : String = "?aREYA.exe" var x7 : String = fileNameCheck(arg70); var v7 : String = "No"; if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80 : String = "/this_is_valid.dll" var x8 : String = fileNameCheck(arg80); var v8 : String = "No"; if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90 : String = "this_is_valid.wow" var x9 : String = fileNameCheck(arg90); var v9 : String = "No"; if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } var arg100 : String = "this_is_valid.txt" var x10 : String = fileNameCheck(arg100); var v10 : String = "Yes"; if (x10 != v10) { throw Exception("Exception -- test case 10 did not pass. x10 = " + x10) } var arg110 : String = "this_is_valid.txtexe" var x11 : String = fileNameCheck(arg110); var v11 : String = "No"; if (x11 != v11) { throw Exception("Exception -- test case 11 did not pass. x11 = " + x11) } var arg120 : String = "#this2_i4s_5valid.ten" var x12 : String = fileNameCheck(arg120); var v12 : String = "No"; if (x12 != v12) { throw Exception("Exception -- test case 12 did not pass. x12 = " + x12) } var arg130 : String = "@this1_is6_valid.exe" var x13 : String = fileNameCheck(arg130); var v13 : String = "No"; if (x13 != v13) { throw Exception("Exception -- test case 13 did not pass. x13 = " + x13) } var arg140 : String = "this_is_12valid.6exe4.txt" var x14 : String = fileNameCheck(arg140); var v14 : String = "No"; if (x14 != v14) { throw Exception("Exception -- test case 14 did not pass. x14 = " + x14) } var arg150 : String = "all.exe.txt" var x15 : String = fileNameCheck(arg150); var v15 : String = "No"; if (x15 != v15) { throw Exception("Exception -- test case 15 did not pass. x15 = " + x15) } var arg160 : String = "I563_No.exe" var x16 : String = fileNameCheck(arg160); var v16 : String = "Yes"; if (x16 != v16) { throw Exception("Exception -- test case 16 did not pass. x16 = " + x16) } var arg170 : String = "Is3youfault.txt" var x17 : String = fileNameCheck(arg170); var v17 : String = "Yes"; if (x17 != v17) { throw Exception("Exception -- test case 17 did not pass. x17 = " + x17) } var arg180 : String = "no_one#knows.dll" var x18 : String = fileNameCheck(arg180); var v18 : String = "Yes"; if (x18 != v18) { throw Exception("Exception -- test case 18 did not pass. x18 = " + x18) } var arg190 : String = "1I563_Yes3.exe" var x19 : String = fileNameCheck(arg190); var v19 : String = "No"; if (x19 != v19) { throw Exception("Exception -- test case 19 did not pass. x19 = " + x19) } var arg200 : String = "I563_Yes3.txtt" var x20 : String = fileNameCheck(arg200); var v20 : String = "No"; if (x20 != v20) { throw Exception("Exception -- test case 20 did not pass. x20 = " + x20) } var arg210 : String = "final..txt" var x21 : String = fileNameCheck(arg210); var v21 : String = "No"; if (x21 != v21) { throw Exception("Exception -- test case 21 did not pass. x21 = " + x21) } var arg220 : String = "final132" var x22 : String = fileNameCheck(arg220); var v22 : String = "No"; if (x22 != v22) { throw Exception("Exception -- test case 22 did not pass. x22 = " + x22) } var arg230 : String = "_f4indsartal132." var x23 : String = fileNameCheck(arg230); var v23 : String = "No"; if (x23 != v23) { throw Exception("Exception -- test case 23 did not pass. x23 = " + x23) } var arg240 : String = ".txt" var x24 : String = fileNameCheck(arg240); var v24 : String = "No"; if (x24 != v24) { throw Exception("Exception -- test case 24 did not pass. x24 = " + x24) } var arg250 : String = "s." var x25 : String = fileNameCheck(arg250); var v25 : String = "No"; if (x25 != v25) { throw Exception("Exception -- test case 25 did not pass. x25 = " + x25) } }
/** * You are an expert Kotlin programmer, and here is your task. * Create a function which takes a string representing a file's name, and returns * 'Yes' if the the file's name is valid, and returns 'No' otherwise. * A file's name is considered to be valid if and only if all the following conditions * are met: * - There should not be more than three digits ('0'-'9') in the file's name. * - The file's name contains exactly one dot '.' * - The substring before the dot should not be empty, and it starts with a letter from * the latin alphapet ('a'-'z' and 'A'-'Z'). * - The substring after the dot should be one of these: ['txt', 'exe', 'dll'] * Examples: * file_name_check("example.txt") # => 'Yes' * file_name_check("1example.dll") # => 'No' (the name should start with a latin alphapet letter) * */
kotlin
[ "fun fileNameCheck(fileName : String) : String {", " val parts = fileName.split('.')", "", " if (parts.size != 2 || parts[0].isEmpty() || !parts[0][0].isLetter()) {", " return \"No\"", " }", " if (parts[0].count { it.isDigit() } > 3) {", " return \"No\"", " }", " val validExtensions = setOf(\"txt\", \"exe\", \"dll\")", " if (parts[1] !in validExtensions) {", " return \"No\"", " }", "", " return \"Yes\"", "}", "", "" ]
HumanEval_kotlin/37
/** * You are an expert Kotlin programmer, and here is your task. * * prime_fib returns n-th number that is a Fibonacci number and it's also prime. * >>> prime_fib(1) * 2 * >>> prime_fib(2) * 3 * >>> prime_fib(3) * 5 * >>> prime_fib(4) * 13 * >>> prime_fib(5) * 89 * */ fun primeFib(n: Int): Int {
primeFib
fun main() { var arg00: Int = 1 var x0: Int = primeFib(arg00) var v0: Int = 2 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 2 var x1: Int = primeFib(arg10) var v1: Int = 3 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 3 var x2: Int = primeFib(arg20) var v2: Int = 5 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 4 var x3: Int = primeFib(arg30) var v3: Int = 13 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 5 var x4: Int = primeFib(arg40) var v4: Int = 89 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: Int = 6 var x5: Int = primeFib(arg50) var v5: Int = 233 if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: Int = 7 var x6: Int = primeFib(arg60) var v6: Int = 1597 if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: Int = 8 var x7: Int = primeFib(arg70) var v7: Int = 28657 if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80: Int = 9 var x8: Int = primeFib(arg80) var v8: Int = 514229 if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90: Int = 10 var x9: Int = primeFib(arg90) var v9: Int = 433494437 if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } }
/** * You are an expert Kotlin programmer, and here is your task. * * prime_fib returns n-th number that is a Fibonacci number and it's also prime. * >>> prime_fib(1) * 2 * >>> prime_fib(2) * 3 * >>> prime_fib(3) * 5 * >>> prime_fib(4) * 13 * >>> prime_fib(5) * 89 * */
kotlin
[ "fun primeFib(n: Int): Int {", "", " fun isPrime(num: Int): Boolean {", " if (num == 1) {", " return false", " }", " for (i in 2..num) {", " if (i * i > num) {", " break", " }", " if (num % i == 0) {", " return false", " }", " }", " return true", " }", "", " var count = 0", " var currentFib = 1", " var previousFib = 0", "", " while (true) {", " val temp = currentFib", " currentFib += previousFib", " previousFib = temp", "", " if (isPrime(currentFib)) {", " count++", " if (count == n) return currentFib", " }", " }", "}", "", "" ]
HumanEval_kotlin/24
/** * You are an expert Kotlin programmer, and here is your task. * For a given number n, find the largest number that divides n evenly, smaller than n * >>> largest_divisor(15) * 5 * */ fun largestDivisor(n: Int): Int {
largestDivisor
fun main() { var arg00: Int = 3 var x0: Int = largestDivisor(arg00) var v0: Int = 1 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 7 var x1: Int = largestDivisor(arg10) var v1: Int = 1 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 10 var x2: Int = largestDivisor(arg20) var v2: Int = 5 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 100 var x3: Int = largestDivisor(arg30) var v3: Int = 50 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 49 var x4: Int = largestDivisor(arg40) var v4: Int = 7 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * For a given number n, find the largest number that divides n evenly, smaller than n * >>> largest_divisor(15) * 5 * */
kotlin
[ "fun largestDivisor(n: Int): Int {", " for (i in 2..n) {", " if (i * i > n) {", " break", " }", " if (n % i == 0) {", " return n / i", " }", " }", " return 1", "}", "", "" ]
HumanEval_kotlin/145
/** * You are an expert Kotlin programmer, and here is your task. * * There are eight planets in our solar system: the closest 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 orbits are * located between the orbit of planet1 and the orbit of planet2, sorted by * the proximity to the sun. * The function should return an empty tuple if planet1 or planet2 * are not correct planet names. * Examples * bf("Jupiter", "Neptune") ==> ("Saturn", "Uranus") * bf("Earth", "Mercury") ==> ("Venus") * bf("Mercury", "Uranus") ==> ("Venus", "Earth", "Mars", "Jupiter", "Saturn") * */ fun bf(planet1 : String, planet2 : String) : List<String> {
bf
fun main() { var arg00 : String = "Jupiter" var arg01 : String = "Neptune" var x0 : List<String> = bf(arg00, arg01); var v0 : List<String> = mutableListOf("Saturn", "Uranus"); if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : String = "Earth" var arg11 : String = "Mercury" var x1 : List<String> = bf(arg10, arg11); var v1 : List<String> = mutableListOf("Venus"); if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : String = "Mercury" var arg21 : String = "Uranus" var x2 : List<String> = bf(arg20, arg21); var v2 : List<String> = mutableListOf("Venus", "Earth", "Mars", "Jupiter", "Saturn"); if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : String = "Neptune" var arg31 : String = "Venus" var x3 : List<String> = bf(arg30, arg31); var v3 : List<String> = mutableListOf("Earth", "Mars", "Jupiter", "Saturn", "Uranus"); if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : String = "Earth" var arg41 : String = "Earth" var x4 : List<String> = bf(arg40, arg41); var v4 : List<String> = mutableListOf(); if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : String = "Mars" var arg51 : String = "Earth" var x5 : List<String> = bf(arg50, arg51); var v5 : List<String> = mutableListOf(); if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : String = "Jupiter" var arg61 : String = "Makemake" var x6 : List<String> = bf(arg60, arg61); var v6 : List<String> = mutableListOf(); if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * * There are eight planets in our solar system: the closest 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 orbits are * located between the orbit of planet1 and the orbit of planet2, sorted by * the proximity to the sun. * The function should return an empty tuple if planet1 or planet2 * are not correct planet names. * Examples * bf("Jupiter", "Neptune") ==> ("Saturn", "Uranus") * bf("Earth", "Mercury") ==> ("Venus") * bf("Mercury", "Uranus") ==> ("Venus", "Earth", "Mars", "Jupiter", "Saturn") * */
kotlin
[ "fun bf(planet1 : String, planet2 : String) : List<String> {", " val planets = listOf(\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\")", "\tval ind1 = planets.indexOf(planet1)", " val ind2 = planets.indexOf(planet2)", " if (ind1 == -1 || ind2 == -1 || ind1 == ind2) {", " return emptyList()", " }", " return planets.subList(Math.min(ind1, ind2) + 1, Math.max(ind1, ind2))", "}", "", "" ]
HumanEval_kotlin/120
/** * You are an expert Kotlin programmer, and here is your task. * * Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence. * The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined * as follows: start with any positive integer n. Then each term is obtained from the * previous term as follows: if the previous term is even, the next term is one half of * the previous term. If the previous term is odd, the next term is 3 times the previous * term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1. * Note: * 1. Collatz(1) is [1]. * 2. returned list sorted in increasing order. * For example: * get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5. * */ fun getOddCollatz(n : Int) : List<Int> {
getOddCollatz
fun main() { var arg00 : Int = 14 var x0 : List<Int> = getOddCollatz(arg00); var v0 : List<Int> = mutableListOf(1, 5, 7, 11, 13, 17); if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : Int = 5 var x1 : List<Int> = getOddCollatz(arg10); var v1 : List<Int> = mutableListOf(1, 5); if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : Int = 12 var x2 : List<Int> = getOddCollatz(arg20); var v2 : List<Int> = mutableListOf(1, 3, 5); if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : Int = 1 var x3 : List<Int> = getOddCollatz(arg30); var v3 : List<Int> = mutableListOf(1); if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * * Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence. * The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined * as follows: start with any positive integer n. Then each term is obtained from the * previous term as follows: if the previous term is even, the next term is one half of * the previous term. If the previous term is odd, the next term is 3 times the previous * term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1. * Note: * 1. Collatz(1) is [1]. * 2. returned list sorted in increasing order. * For example: * get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5. * */
kotlin
[ "fun getOddCollatz(n : Int) : List<Int> {", " var current = n", " val oddNumbers = mutableSetOf<Int>()", "", " while (current != 1) {", " if (current % 2 != 0) oddNumbers.add(current)", " current = if (current % 2 == 0) {", " current / 2", " } else {", " 3 * current + 1", " }", " }", " oddNumbers.add(1)", " return oddNumbers.sorted()", "}", "", "" ]
HumanEval_kotlin/76
/** * You are an expert Kotlin programmer, and here is your task. * You will be given a number in decimal form and your task is to convert it to * binary format. The function should return a string, with each character representing a binary * number. Each character in the string will be '0' or '1'. * There will be an extra couple of characters 'db' at the beginning and at the end of the string. * The extra characters are there to help with the format. * Examples: * decimal_to_binary(15) # returns "db1111db" * decimal_to_binary(32) # returns "db100000db" * */ fun decimalToBinary(decimal: Int): String {
decimalToBinary
fun main() { var arg00: Int = 0 var x0: String = decimalToBinary(arg00) var v0: String = "db0db" if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 32 var x1: String = decimalToBinary(arg10) var v1: String = "db100000db" if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 103 var x2: String = decimalToBinary(arg20) var v2: String = "db1100111db" if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 15 var x3: String = decimalToBinary(arg30) var v3: String = "db1111db" if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * You will be given a number in decimal form and your task is to convert it to * binary format. The function should return a string, with each character representing a binary * number. Each character in the string will be '0' or '1'. * There will be an extra couple of characters 'db' at the beginning and at the end of the string. * The extra characters are there to help with the format. * Examples: * decimal_to_binary(15) # returns "db1111db" * decimal_to_binary(32) # returns "db100000db" * */
kotlin
[ "fun decimalToBinary(decimal: Int): String {", " val binaryString = decimal.toString(2)", " return \"db${binaryString}db\"", "}", "", "" ]
HumanEval_kotlin/15
/** * You are an expert Kotlin programmer, and here is your task. * Return a string containing space-delimited numbers starting from 0 upto n inclusive. * >>> string_sequence(0) * '0' * >>> string_sequence(5) * '0 1 2 3 4 5' * */ fun stringSequence(n: Int): String {
stringSequence
fun main() { var arg00: Int = 0 var x0: String = stringSequence(arg00) var v0: String = "0" if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 3 var x1: String = stringSequence(arg10) var v1: String = "0 1 2 3" if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 10 var x2: String = stringSequence(arg20) var v2: String = "0 1 2 3 4 5 6 7 8 9 10" if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return a string containing space-delimited numbers starting from 0 upto n inclusive. * >>> string_sequence(0) * '0' * >>> string_sequence(5) * '0 1 2 3 4 5' * */
kotlin
[ "fun stringSequence(n: Int): String {", " return (0..n).joinToString(\" \")", "}", "", "" ]
HumanEval_kotlin/107
/** * You are an expert Kotlin programmer, and here is your task. * In this problem, you will implement a function that takes two lists of numbers, * and determines whether it is possible to perform an exchange of elements * between them to make lst1 a list of only even numbers. * There is no limit on the number of exchanged elements between lst1 and lst2. * If it is possible to exchange elements between the lst1 and lst2 to make * all the elements of lst1 to be even, return "YES". * Otherwise, return "NO". * For example: * exchange([1, 2, 3, 4], [1, 2, 3, 4]) => "YES" * exchange([1, 2, 3, 4], [1, 5, 3, 4]) => "NO" * It is assumed that the input lists will be non-empty. * */ fun exchange(lst1 : List<Int>, lst2 : List<Int>) : String {
exchange
fun main() { var arg00 : List<Int> = mutableListOf(1, 2, 3, 4) var arg01 : List<Int> = mutableListOf(1, 2, 3, 4) var x0 : String = exchange(arg00, arg01); var v0 : String = "YES"; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : List<Int> = mutableListOf(1, 2, 3, 4) var arg11 : List<Int> = mutableListOf(1, 5, 3, 4) var x1 : String = exchange(arg10, arg11); var v1 : String = "NO"; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : List<Int> = mutableListOf(1, 2, 3, 4) var arg21 : List<Int> = mutableListOf(2, 1, 4, 3) var x2 : String = exchange(arg20, arg21); var v2 : String = "YES"; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : List<Int> = mutableListOf(5, 7, 3) var arg31 : List<Int> = mutableListOf(2, 6, 4) var x3 : String = exchange(arg30, arg31); var v3 : String = "YES"; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : List<Int> = mutableListOf(5, 7, 3) var arg41 : List<Int> = mutableListOf(2, 6, 3) var x4 : String = exchange(arg40, arg41); var v4 : String = "NO"; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : List<Int> = mutableListOf(3, 2, 6, 1, 8, 9) var arg51 : List<Int> = mutableListOf(3, 5, 5, 1, 1, 1) var x5 : String = exchange(arg50, arg51); var v5 : String = "NO"; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : List<Int> = mutableListOf(100, 200) var arg61 : List<Int> = mutableListOf(200, 200) var x6 : String = exchange(arg60, arg61); var v6 : String = "YES"; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * In this problem, you will implement a function that takes two lists of numbers, * and determines whether it is possible to perform an exchange of elements * between them to make lst1 a list of only even numbers. * There is no limit on the number of exchanged elements between lst1 and lst2. * If it is possible to exchange elements between the lst1 and lst2 to make * all the elements of lst1 to be even, return "YES". * Otherwise, return "NO". * For example: * exchange([1, 2, 3, 4], [1, 2, 3, 4]) => "YES" * exchange([1, 2, 3, 4], [1, 5, 3, 4]) => "NO" * It is assumed that the input lists will be non-empty. * */
kotlin
[ "fun exchange(lst1 : List<Int>, lst2 : List<Int>) : String {", "\tval countEven = lst1.count { it % 2 == 0 } + lst2.count { it % 2 == 0 }", " return if (countEven >= lst1.size) {", " \"YES\"", " } else {", " \"NO\"", " }", "}", "", "" ]
HumanEval_kotlin/16
/** * You are an expert Kotlin programmer, and here is your task. * Given a string, find out how many distinct characters (regardless of case) does it consist of * >>> count_distinct_characters('xyzXYZ') * 3 * >>> count_distinct_characters('Jerry') * 4 * */ fun countDistinctCharacters(string: String): Int {
countDistinctCharacters
fun main() { var arg00: String = "" var x0: Int = countDistinctCharacters(arg00) var v0: Int = 0 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "abcde" var x1: Int = countDistinctCharacters(arg10) var v1: Int = 5 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "abcdecadeCADE" var x2: Int = countDistinctCharacters(arg20) var v2: Int = 5 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "aaaaAAAAaaaa" var x3: Int = countDistinctCharacters(arg30) var v3: Int = 1 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "Jerry jERRY JeRRRY" var x4: Int = countDistinctCharacters(arg40) var v4: Int = 5 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * Given a string, find out how many distinct characters (regardless of case) does it consist of * >>> count_distinct_characters('xyzXYZ') * 3 * >>> count_distinct_characters('Jerry') * 4 * */
kotlin
[ "fun countDistinctCharacters(string: String): Int {", " return string.lowercase().toSet().size", "}", "", "" ]
HumanEval_kotlin/61
/** * You are an expert Kotlin programmer, and here is your task. * Write a function vowels_count which takes a string representing * a word as input and returns the number of vowels in the string. * Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a * vowel, but only when it is at the end of the given word. * Example: * >>> vowels_count("abcde") * 2 * >>> vowels_count("ACEDY") * 3 * */ fun vowelsCount(s: String): Int {
vowelsCount
fun main() { var arg00: String = "abcde" var x0: Int = vowelsCount(arg00) var v0: Int = 2 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "Alone" var x1: Int = vowelsCount(arg10) var v1: Int = 3 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "key" var x2: Int = vowelsCount(arg20) var v2: Int = 2 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "bye" var x3: Int = vowelsCount(arg30) var v3: Int = 1 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "keY" var x4: Int = vowelsCount(arg40) var v4: Int = 2 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: String = "bYe" var x5: Int = vowelsCount(arg50) var v5: Int = 1 if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: String = "ACEDY" var x6: Int = vowelsCount(arg60) var v6: Int = 3 if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * Write a function vowels_count which takes a string representing * a word as input and returns the number of vowels in the string. * Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a * vowel, but only when it is at the end of the given word. * Example: * >>> vowels_count("abcde") * 2 * >>> vowels_count("ACEDY") * 3 * */
kotlin
[ "fun vowelsCount(s: String): Int {", " val vowels = setOf('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U')", " return s.count { it in vowels } + if (s.last().lowercase() == \"y\") 1 else 0", "}", "", "" ]
HumanEval_kotlin/115
/** * You are an expert Kotlin programmer, and here is your task. * You are given a word. Your task is to find the closest vowel that stands between * two consonants from the right side of the word (case sensitive). * * Vowels in the beginning and ending doesn't count. Return empty string if you didn't * find any vowel met the above condition. * You may assume that the given string contains English letter only. * Example: * get_closest_vowel("yogurt") ==> "u" * get_closest_vowel("FULL") ==> "U" * get_closest_vowel("quick") ==> "" * get_closest_vowel("ab") ==> "" * */ fun getClosestVowel(word: String): String {
getClosestVowel
fun main() { var arg00: String = "yogurt" var x0: String = getClosestVowel(arg00); var v0: String = "u"; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "full" var x1: String = getClosestVowel(arg10); var v1: String = "u"; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "easy" var x2: String = getClosestVowel(arg20); var v2: String = ""; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "eAsy" var x3: String = getClosestVowel(arg30); var v3: String = ""; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "ali" var x4: String = getClosestVowel(arg40); var v4: String = ""; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: String = "bad" var x5: String = getClosestVowel(arg50); var v5: String = "a"; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: String = "most" var x6: String = getClosestVowel(arg60); var v6: String = "o"; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: String = "ab" var x7: String = getClosestVowel(arg70); var v7: String = ""; if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80: String = "ba" var x8: String = getClosestVowel(arg80); var v8: String = ""; if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90: String = "quick" var x9: String = getClosestVowel(arg90); var v9: String = ""; if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } var arg100: String = "anime" var x10: String = getClosestVowel(arg100); var v10: String = "i"; if (x10 != v10) { throw Exception("Exception -- test case 10 did not pass. x10 = " + x10) } var arg110: String = "Asia" var x11: String = getClosestVowel(arg110); var v11: String = ""; if (x11 != v11) { throw Exception("Exception -- test case 11 did not pass. x11 = " + x11) } var arg120: String = "Above" var x12: String = getClosestVowel(arg120); var v12: String = "o"; if (x12 != v12) { throw Exception("Exception -- test case 12 did not pass. x12 = " + x12) } }
/** * You are an expert Kotlin programmer, and here is your task. * You are given a word. Your task is to find the closest vowel that stands between * two consonants from the right side of the word (case sensitive). * * Vowels in the beginning and ending doesn't count. Return empty string if you didn't * find any vowel met the above condition. * You may assume that the given string contains English letter only. * Example: * get_closest_vowel("yogurt") ==> "u" * get_closest_vowel("FULL") ==> "U" * get_closest_vowel("quick") ==> "" * get_closest_vowel("ab") ==> "" * */
kotlin
[ "fun getClosestVowel(word: String): String {", " val vowels = setOf('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U')", " val position = word.indices.reversed().firstOrNull { ind ->", " 0 < ind && ind < word.length - 1 && word[ind] in vowels && word[ind - 1] !in vowels && word[ind + 1] !in vowels", " }", " return if (position != null) {", " word[position].toString()", " } else {", " \"\"", " }", "}", "", "" ]
HumanEval_kotlin/111
/** * You are an expert Kotlin programmer, and here is your task. * * Given an array of integers nums, find the minimum sum of any non-empty sub-array * of nums. * Example * minSubArraySum([2, 3, 4, 1, 2, 4]) == 1 * minSubArraySum([-1, -2, -3]) == -6 * */ fun minsubarraysum(nums : List<Long>) : Long {
minsubarraysum
fun main() { var arg00 : List<Long> = mutableListOf(2, 3, 4, 1, 2, 4) var x0 : Long = minsubarraysum(arg00); var v0 : Long = 1; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : List<Long> = mutableListOf(-1, -2, -3) var x1 : Long = minsubarraysum(arg10); var v1 : Long = -6; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : List<Long> = mutableListOf(-1, -2, -3, 2, -10) var x2 : Long = minsubarraysum(arg20); var v2 : Long = -14; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : List<Long> = mutableListOf(-9999999999999999) var x3 : Long = minsubarraysum(arg30); var v3 : Long = -9999999999999999; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : List<Long> = mutableListOf(0, 10, 20, 1000000) var x4 : Long = minsubarraysum(arg40); var v4 : Long = 0; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : List<Long> = mutableListOf(-1, -2, -3, 10, -5) var x5 : Long = minsubarraysum(arg50); var v5 : Long = -6; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : List<Long> = mutableListOf(100, -1, -2, -3, 10, -5) var x6 : Long = minsubarraysum(arg60); var v6 : Long = -6; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70 : List<Long> = mutableListOf(10, 11, 13, 8, 3, 4) var x7 : Long = minsubarraysum(arg70); var v7 : Long = 3; if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80 : List<Long> = mutableListOf(100, -33, 32, -1, 0, -2) var x8 : Long = minsubarraysum(arg80); var v8 : Long = -33; if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90 : List<Long> = mutableListOf(-10) var x9 : Long = minsubarraysum(arg90); var v9 : Long = -10; if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } var arg100 : List<Long> = mutableListOf(7) var x10 : Long = minsubarraysum(arg100); var v10 : Long = 7; if (x10 != v10) { throw Exception("Exception -- test case 10 did not pass. x10 = " + x10) } var arg110 : List<Long> = mutableListOf(1, -1) var x11 : Long = minsubarraysum(arg110); var v11 : Long = -1; if (x11 != v11) { throw Exception("Exception -- test case 11 did not pass. x11 = " + x11) } }
/** * You are an expert Kotlin programmer, and here is your task. * * Given an array of integers nums, find the minimum sum of any non-empty sub-array * of nums. * Example * minSubArraySum([2, 3, 4, 1, 2, 4]) == 1 * minSubArraySum([-1, -2, -3]) == -6 * */
kotlin
[ "fun minsubarraysum(nums : List<Long>) : Long {", " var answer = nums[0]", "\tnums.indices.forEach { i ->", " nums.indices.forEach { j ->", " if (i <= j) {", " answer = Math.min(nums.subList(i, j + 1).sum(), answer)", " }", " }", " }", " return answer", "}", "", "" ]
HumanEval_kotlin/82
/** * You are an expert Kotlin programmer, and here is your task. * Given a non-empty list of integers lst. add the even elements that are at odd indices.. * Examples: * add([4, 2, 6, 7]) ==> 2 * */ fun add(lst: List<Int>): Int {
add
fun main() { var arg00: List<Int> = mutableListOf(4, 88) var x0: Int = add(arg00) var v0: Int = 88 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(4, 5, 6, 7, 2, 122) var x1: Int = add(arg10) var v1: Int = 122 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(4, 0, 6, 7) var x2: Int = add(arg20) var v2: Int = 0 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(4, 4, 6, 8) var x3: Int = add(arg30) var v3: Int = 12 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * Given a non-empty list of integers lst. add the even elements that are at odd indices.. * Examples: * add([4, 2, 6, 7]) ==> 2 * */
kotlin
[ "fun add(lst: List<Int>): Int {", " var answer = 0", " lst.forEachIndexed { index, value ->", " if (index % 2 == 1 && value % 2 == 0) {", " answer += value", " }", " }", " return answer", "}", "", "" ]
HumanEval_kotlin/49
/** * You are an expert Kotlin programmer, and here is your task. * Return True if all numbers in the list l are below threshold t. * >>> below_threshold([1, 2, 4, 10], 100) * True * >>> below_threshold([1, 20, 4, 10], 5) * False * */ fun belowThreshold(l: List<Int>, t: Int): Boolean {
belowThreshold
fun main() { var arg00: List<Int> = mutableListOf(1, 2, 4, 10) var arg01: Int = 100 var x0: Boolean = belowThreshold(arg00, arg01) var v0: Boolean = true if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(1, 20, 4, 10) var arg11: Int = 5 var x1: Boolean = belowThreshold(arg10, arg11) var v1: Boolean = false if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(1, 20, 4, 10) var arg21: Int = 21 var x2: Boolean = belowThreshold(arg20, arg21) var v2: Boolean = true if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(1, 20, 4, 10) var arg31: Int = 22 var x3: Boolean = belowThreshold(arg30, arg31) var v3: Boolean = true if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: List<Int> = mutableListOf(1, 8, 4, 10) var arg41: Int = 11 var x4: Boolean = belowThreshold(arg40, arg41) var v4: Boolean = true if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: List<Int> = mutableListOf(1, 8, 4, 10) var arg51: Int = 10 var x5: Boolean = belowThreshold(arg50, arg51) var v5: Boolean = false if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return True if all numbers in the list l are below threshold t. * >>> below_threshold([1, 2, 4, 10], 100) * True * >>> below_threshold([1, 20, 4, 10], 5) * False * */
kotlin
[ "fun belowThreshold(l: List<Int>, t: Int): Boolean {", " return l.all { it < t }", "}", "", "" ]
HumanEval_kotlin/29
/** * You are an expert Kotlin programmer, and here is your task. * Filter an input list of strings only for ones that start with a given prefix. * >>> filter_by_prefix([], 'a') * [] * >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a') * ['abc', 'array'] * */ fun filterByPrefix(strings: List<String>, prefix: String): List<String> {
filterByPrefix
fun main() { var arg00: List<String> = mutableListOf() var arg01: String = "john" var x0: List<String> = filterByPrefix(arg00, arg01) var v0: List<String> = mutableListOf() if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<String> = mutableListOf("xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx") var arg11: String = "xxx" var x1: List<String> = filterByPrefix(arg10, arg11) var v1: List<String> = mutableListOf("xxx", "xxxAAA", "xxx") if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } }
/** * You are an expert Kotlin programmer, and here is your task. * Filter an input list of strings only for ones that start with a given prefix. * >>> filter_by_prefix([], 'a') * [] * >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a') * ['abc', 'array'] * */
kotlin
[ "fun filterByPrefix(strings: List<String>, prefix: String): List<String> {", " return strings.filter { it.startsWith(prefix) }", "}", "", "" ]
HumanEval_kotlin/144
/** * You are an expert Kotlin programmer, and here is your task. * * 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 : * Input: n = 5 * Output: 1 * Explanation: * a = [1, 3, 7, 13, 21] * The only valid triple is (1, 7, 13). * */ fun getMaxTriples(n : Int) : Int {
getMaxTriples
fun main() { var arg00 : Int = 5 var x0 : Int = getMaxTriples(arg00); var v0 : Int = 1; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : Int = 6 var x1 : Int = getMaxTriples(arg10); var v1 : Int = 4; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : Int = 10 var x2 : Int = getMaxTriples(arg20); var v2 : Int = 36; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : Int = 100 var x3 : Int = getMaxTriples(arg30); var v3 : Int = 53361; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * * 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 : * Input: n = 5 * Output: 1 * Explanation: * a = [1, 3, 7, 13, 21] * The only valid triple is (1, 7, 13). * */
kotlin
[ "fun getMaxTriples(n : Int) : Int {", " val counts = IntArray(3) { 0 }", " for (i in 1..n) {", " val value = (i * i - i + 1) % 3", " counts[value]++", " }", " val triples = (counts[0] * (counts[0] - 1) * (counts[0] - 2)) / 6 +", " (counts[1] * (counts[1] - 1) * (counts[1] - 2)) / 6 +", " (counts[2] * (counts[2] - 1) * (counts[2] - 2)) / 6 +", " counts[0] * counts[1] * counts[2]", "", " return triples", "}", "", "" ]
HumanEval_kotlin/86
/** * You are an expert Kotlin programmer, and here is your task. * Create a function encrypt that takes a string as an argument and * returns a string encrypted with the alphabet being rotated. * The alphabet should be rotated in a manner such that the letters * shift down by two multiplied to two places. * For example: * encrypt('hi') returns 'lm' * encrypt('asdfghjkl') returns 'ewhjklnop' * encrypt('gf') returns 'kj' * encrypt('et') returns 'ix' * */ fun encrypt(s: String): String {
encrypt
fun main() { var arg00: String = "hi" var x0: String = encrypt(arg00) var v0: String = "lm" if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "asdfghjkl" var x1: String = encrypt(arg10) var v1: String = "ewhjklnop" if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "gf" var x2: String = encrypt(arg20) var v2: String = "kj" if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "et" var x3: String = encrypt(arg30) var v3: String = "ix" if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "faewfawefaewg" var x4: String = encrypt(arg40) var v4: String = "jeiajeaijeiak" if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: String = "hellomyfriend" var x5: String = encrypt(arg50) var v5: String = "lippsqcjvmirh" if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: String = "dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh" var x6: String = encrypt(arg60) var v6: String = "hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl" if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: String = "a" var x7: String = encrypt(arg70) var v7: String = "e" if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * Create a function encrypt that takes a string as an argument and * returns a string encrypted with the alphabet being rotated. * The alphabet should be rotated in a manner such that the letters * shift down by two multiplied to two places. * For example: * encrypt('hi') returns 'lm' * encrypt('asdfghjkl') returns 'ewhjklnop' * encrypt('gf') returns 'kj' * encrypt('et') returns 'ix' * */
kotlin
[ "fun encrypt(s: String): String {", " val shift = 4", " return s.map { char ->", " val shifted = ((char - 'a' + shift) % 26) + 'a'.code", " shifted.toChar()", " }.joinToString(\"\")", "}", "", "" ]
HumanEval_kotlin/23
/** * You are an expert Kotlin programmer, and here is your task. * Return length of given string * >>> strlen('') * 0 * >>> strlen('abc') * 3 * */ fun strlen(string: String): Int {
strlen
fun main() { var arg00: String = "" var x0: Int = strlen(arg00) var v0: Int = 0 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "x" var x1: Int = strlen(arg10) var v1: Int = 1 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "asdasnakj" var x2: Int = strlen(arg20) var v2: Int = 9 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return length of given string * >>> strlen('') * 0 * >>> strlen('abc') * 3 * */
kotlin
[ "fun strlen(string: String): Int {", " return string.length", "}", "", "" ]
HumanEval_kotlin/135
/** * You are an expert Kotlin programmer, and here is your task. * Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers * Example * is_equal_to_sum_even(4) == False * is_equal_to_sum_even(6) == False * is_equal_to_sum_even(8) == True * */ fun isEqualToSumEven(n : Int) : Boolean {
isEqualToSumEven
fun main() { var arg00 : Int = 4 var x0 : Boolean = isEqualToSumEven(arg00); var v0 : Boolean = false; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : Int = 6 var x1 : Boolean = isEqualToSumEven(arg10); var v1 : Boolean = false; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : Int = 8 var x2 : Boolean = isEqualToSumEven(arg20); var v2 : Boolean = true; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : Int = 10 var x3 : Boolean = isEqualToSumEven(arg30); var v3 : Boolean = true; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : Int = 11 var x4 : Boolean = isEqualToSumEven(arg40); var v4 : Boolean = false; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : Int = 12 var x5 : Boolean = isEqualToSumEven(arg50); var v5 : Boolean = true; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : Int = 13 var x6 : Boolean = isEqualToSumEven(arg60); var v6 : Boolean = false; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70 : Int = 16 var x7 : Boolean = isEqualToSumEven(arg70); var v7 : Boolean = true; if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers * Example * is_equal_to_sum_even(4) == False * is_equal_to_sum_even(6) == False * is_equal_to_sum_even(8) == True * */
kotlin
[ "fun isEqualToSumEven(n : Int) : Boolean {", " return n % 2 == 0 && n >= 8", "}", "", "" ]
HumanEval_kotlin/72
/** * You are an expert Kotlin programmer, and here is your task. * 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 than 100. * Example: * is_multiply_prime(30) == True * 30 = 2 * 3 * 5 * */ fun isMultiplyPrime(a: Int): Boolean {
isMultiplyPrime
fun main() { var arg00: Int = 5 var x0: Boolean = isMultiplyPrime(arg00) var v0: Boolean = false if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 30 var x1: Boolean = isMultiplyPrime(arg10) var v1: Boolean = true if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 8 var x2: Boolean = isMultiplyPrime(arg20) var v2: Boolean = true if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 10 var x3: Boolean = isMultiplyPrime(arg30) var v3: Boolean = false if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 125 var x4: Boolean = isMultiplyPrime(arg40) var v4: Boolean = true if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: Int = 105 var x5: Boolean = isMultiplyPrime(arg50) var v5: Boolean = true if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: Int = 126 var x6: Boolean = isMultiplyPrime(arg60) var v6: Boolean = false if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: Int = 729 var x7: Boolean = isMultiplyPrime(arg70) var v7: Boolean = false if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80: Int = 891 var x8: Boolean = isMultiplyPrime(arg80) var v8: Boolean = false if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90: Int = 1001 var x9: Boolean = isMultiplyPrime(arg90) var v9: Boolean = true if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } }
/** * You are an expert Kotlin programmer, and here is your task. * 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 than 100. * Example: * is_multiply_prime(30) == True * 30 = 2 * 3 * 5 * */
kotlin
[ "fun isMultiplyPrime(a: Int): Boolean {", " var cur = a", " val factors = mutableListOf<Int>()", " for (i in 2..a) {", " if (i * i > a) {", " break", " }", " while (cur % i == 0) {", " cur /= i", " factors.add(i)", " }", " }", " if (cur != 1) {", " factors.add(cur)", " }", " return factors.size == 3", "}", "", "" ]
HumanEval_kotlin/59
/** * You are an expert Kotlin programmer, and here is your task. * xs represent coefficients of a polynomial. * xs[0] + xs[1] * x + xs[2] * x^2 + .... * Return derivative of this polynomial in the same form. * >>> derivative([3, 1, 2, 4, 5]) * [1, 4, 12, 20] * >>> derivative([1, 2, 3]) * [2, 6] * */ fun derivative(xs: List<Int>): List<Int> {
derivative
fun main() { var arg00: List<Int> = mutableListOf(3, 1, 2, 4, 5) var x0: List<Int> = derivative(arg00) var v0: List<Int> = mutableListOf(1, 4, 12, 20) if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(1, 2, 3) var x1: List<Int> = derivative(arg10) var v1: List<Int> = mutableListOf(2, 6) if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(3, 2, 1) var x2: List<Int> = derivative(arg20) var v2: List<Int> = mutableListOf(2, 2) if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(3, 2, 1, 0, 4) var x3: List<Int> = derivative(arg30) var v3: List<Int> = mutableListOf(2, 2, 0, 16) if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: List<Int> = mutableListOf(1) var x4: List<Int> = derivative(arg40) var v4: List<Int> = mutableListOf() if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * xs represent coefficients of a polynomial. * xs[0] + xs[1] * x + xs[2] * x^2 + .... * Return derivative of this polynomial in the same form. * >>> derivative([3, 1, 2, 4, 5]) * [1, 4, 12, 20] * >>> derivative([1, 2, 3]) * [2, 6] * */
kotlin
[ "fun derivative(xs: List<Int>): List<Int> {", " return xs.mapIndexed { index, value ->", " value * index", " }.drop(1)", "}", "", "" ]
HumanEval_kotlin/10
/** * You are an expert Kotlin programmer, and here is your task. * 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('') * '' * >>> make_palindrome('cat') * 'catac' * >>> make_palindrome('cata') * 'catac' * */ fun makePalindrome(string: String): String {
makePalindrome
fun main() { var arg00: String = "" var x0: String = makePalindrome(arg00) var v0: String = "" if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "x" var x1: String = makePalindrome(arg10) var v1: String = "x" if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "xyz" var x2: String = makePalindrome(arg20) var v2: String = "xyzyx" if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "xyx" var x3: String = makePalindrome(arg30) var v3: String = "xyx" if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "jerry" var x4: String = makePalindrome(arg40) var v4: String = "jerryrrej" if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * 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('') * '' * >>> make_palindrome('cat') * 'catac' * >>> make_palindrome('cata') * 'catac' * */
kotlin
[ "fun makePalindrome(string: String): String {", " for (startPosition in string.indices) {", " if (string.substring(startPosition) == string.substring(startPosition).reversed()) {", " return string + string.substring(0, startPosition).reversed()", " }", " }", " return string", "}", "", "" ]
HumanEval_kotlin/103
/** * You are an expert Kotlin programmer, and here is your task. * Implement the function f that takes n as a parameter, * and ret urns a list of size n, such that the value of the element at index i is the factorial of i if i is even * or the sum of numbers from 1 to i otherwise. * i starts from 1. * the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i). * Example: * f(5) == [1, 2, 6, 24, 15] * */ fun f(n : Int) : List<Int> {
f
fun main() { var arg00 : Int = 5 var x0 : List<Int> = f(arg00); var v0 : List<Int> = mutableListOf(1, 2, 6, 24, 15); if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : Int = 7 var x1 : List<Int> = f(arg10); var v1 : List<Int> = mutableListOf(1, 2, 6, 24, 15, 720, 28); if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : Int = 1 var x2 : List<Int> = f(arg20); var v2 : List<Int> = mutableListOf(1); if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : Int = 3 var x3 : List<Int> = f(arg30); var v3 : List<Int> = mutableListOf(1, 2, 6); if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * Implement the function f that takes n as a parameter, * and ret urns a list of size n, such that the value of the element at index i is the factorial of i if i is even * or the sum of numbers from 1 to i otherwise. * i starts from 1. * the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i). * Example: * f(5) == [1, 2, 6, 24, 15] * */
kotlin
[ "fun f(n : Int) : List<Int> {", " fun factorial(num: Int): Int = if (num == 0) 1 else num * factorial(num - 1)", " fun sumToNum(num: Int): Int = (1..num).sum()", " return (1..n).map { i ->", " if (i % 2 == 0) factorial(i) else sumToNum(i)", " }", "}", "", "" ]
HumanEval_kotlin/108
/** * You are an expert Kotlin programmer, and here is your task. * 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('a b c') == {'a': 1, 'b': 1, 'c': 1} * histogram('a b b a') == {'a': 2, 'b': 2} * histogram('a b c a b') == {'a': 2, 'b': 2} * histogram('b b b b a') == {'b': 4} * histogram('') == {} * */ fun histogram(text : String) : Map<String, Int> {
histogram
fun main() { var arg00 : String = "a b b a" var x0 : Map<String, Int> = histogram(arg00); var v0 : Map<String, Int> = mutableMapOf("a" to 2, "b" to 2); if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : String = "a b c a b" var x1 : Map<String, Int> = histogram(arg10); var v1 : Map<String, Int> = mutableMapOf("a" to 2, "b" to 2); if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : String = "a b c d g" var x2 : Map<String, Int> = histogram(arg20); var v2 : Map<String, Int> = mutableMapOf("a" to 1, "b" to 1, "c" to 1, "d" to 1, "g" to 1); if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : String = "r t g" var x3 : Map<String, Int> = histogram(arg30); var v3 : Map<String, Int> = mutableMapOf("r" to 1, "t" to 1, "g" to 1); if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : String = "b b b b a" var x4 : Map<String, Int> = histogram(arg40); var v4 : Map<String, Int> = mutableMapOf("b" to 4); if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : String = "r t g" var x5 : Map<String, Int> = histogram(arg50); var v5 : Map<String, Int> = mutableMapOf("r" to 1, "t" to 1, "g" to 1); if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : String = "" var x6 : Map<String, Int> = histogram(arg60); var v6 : Map<String, Int> = mutableMapOf(); if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70 : String = "a" var x7 : Map<String, Int> = histogram(arg70); var v7 : Map<String, Int> = mutableMapOf("a" to 1); if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * 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('a b c') == {'a': 1, 'b': 1, 'c': 1} * histogram('a b b a') == {'a': 2, 'b': 2} * histogram('a b c a b') == {'a': 2, 'b': 2} * histogram('b b b b a') == {'b': 4} * histogram('') == {} * */
kotlin
[ "fun histogram(text : String) : Map<String, Int> {", " if (text.isEmpty()) return emptyMap()", "", " val counts = text.split(\" \")", " .filter { it.isNotEmpty() } // Remove any empty strings resulting from extra spaces", " .groupingBy { it }", " .eachCount()", "", " val maxCount = counts.maxByOrNull { it.value }?.value ?: return emptyMap()", " return counts.filter { it.value == maxCount }", "}", "", "" ]
HumanEval_kotlin/146
/** * You are an expert Kotlin programmer, and here is your task. * Write a function that accepts a list of strings as a parameter, * deletes the strings that have odd lengths from it, * and returns the resulted list with a sorted order, * The list is always a list of strings and never an array of numbers, * and it may contain duplicates. * The order of the list should be ascending by length of each word, and you * should return the list sorted by that rule. * If two words have the same length, sort the list alphabetically. * The function should return a list of strings in sorted order. * You may assume that all words will have the same length. * For example: * assert list_sort(["aa", "a", "aaa"]) => ["aa"] * assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"] * */ fun sortedListSum(lst : List<String>) : List<String> {
sortedListSum
fun main() { var arg00 : List<String> = mutableListOf("aa", "a", "aaa") var x0 : List<Any> = sortedListSum(arg00); var v0 : List<Any> = mutableListOf("aa"); if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : List<String> = mutableListOf("school", "AI", "asdf", "b") var x1 : List<Any> = sortedListSum(arg10); var v1 : List<Any> = mutableListOf("AI", "asdf", "school"); if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : List<String> = mutableListOf("d", "b", "c", "a") var x2 : List<Any> = sortedListSum(arg20); var v2 : List<Any> = mutableListOf(); if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : List<String> = mutableListOf("d", "dcba", "abcd", "a") var x3 : List<Any> = sortedListSum(arg30); var v3 : List<Any> = mutableListOf("abcd", "dcba"); if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : List<String> = mutableListOf("AI", "ai", "au") var x4 : List<Any> = sortedListSum(arg40); var v4 : List<Any> = mutableListOf("AI", "ai", "au"); if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : List<String> = mutableListOf("a", "b", "b", "c", "c", "a") var x5 : List<Any> = sortedListSum(arg50); var v5 : List<Any> = mutableListOf(); if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : List<String> = mutableListOf("aaaa", "bbbb", "dd", "cc") var x6 : List<Any> = sortedListSum(arg60); var v6 : List<Any> = mutableListOf("cc", "dd", "aaaa", "bbbb"); if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * Write a function that accepts a list of strings as a parameter, * deletes the strings that have odd lengths from it, * and returns the resulted list with a sorted order, * The list is always a list of strings and never an array of numbers, * and it may contain duplicates. * The order of the list should be ascending by length of each word, and you * should return the list sorted by that rule. * If two words have the same length, sort the list alphabetically. * The function should return a list of strings in sorted order. * You may assume that all words will have the same length. * For example: * assert list_sort(["aa", "a", "aaa"]) => ["aa"] * assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"] * */
kotlin
[ "fun sortedListSum(lst : List<String>) : List<String> {", " return lst.filter { it.length % 2 == 0 }", " .sortedWith(compareBy({ it.length }, { it }))", "}", "", "" ]
HumanEval_kotlin/38
/** * You are an expert Kotlin programmer, and here is your task. * triples_sum_to_zero takes a list of integers as an input. * it returns True if there are three distinct elements in the list that * sum to zero, and False otherwise. * >>> triples_sum_to_zero([1, 3, 5, 0]) * False * >>> triples_sum_to_zero([1, 3, -2, 1]) * True * >>> triples_sum_to_zero([1, 2, 3, 7]) * False * >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7]) * True * >>> triples_sum_to_zero([1]) * False * */ fun triplesSumToZero(l: List<Int>): Boolean {
triplesSumToZero
fun main() { var arg00: List<Int> = mutableListOf(1, 3, 5, 0) var x0: Boolean = triplesSumToZero(arg00) var v0: Boolean = false if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(1, 3, 5, -1) var x1: Boolean = triplesSumToZero(arg10) var v1: Boolean = false if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(1, 3, -2, 1) var x2: Boolean = triplesSumToZero(arg20) var v2: Boolean = true if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(1, 2, 3, 7) var x3: Boolean = triplesSumToZero(arg30) var v3: Boolean = false if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: List<Int> = mutableListOf(1, 2, 5, 7) var x4: Boolean = triplesSumToZero(arg40) var v4: Boolean = false if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: List<Int> = mutableListOf(2, 4, -5, 3, 9, 7) var x5: Boolean = triplesSumToZero(arg50) var v5: Boolean = true if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: List<Int> = mutableListOf(1) var x6: Boolean = triplesSumToZero(arg60) var v6: Boolean = false if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: List<Int> = mutableListOf(1, 3, 5, -100) var x7: Boolean = triplesSumToZero(arg70) var v7: Boolean = false if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80: List<Int> = mutableListOf(100, 3, 5, -100) var x8: Boolean = triplesSumToZero(arg80) var v8: Boolean = false if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } }
/** * You are an expert Kotlin programmer, and here is your task. * triples_sum_to_zero takes a list of integers as an input. * it returns True if there are three distinct elements in the list that * sum to zero, and False otherwise. * >>> triples_sum_to_zero([1, 3, 5, 0]) * False * >>> triples_sum_to_zero([1, 3, -2, 1]) * True * >>> triples_sum_to_zero([1, 2, 3, 7]) * False * >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7]) * True * >>> triples_sum_to_zero([1]) * False * */
kotlin
[ "fun triplesSumToZero(l: List<Int>): Boolean {", " val sortedList = l.sorted()", " for (i in 0 until sortedList.size - 2) {", " // Avoid duplicate elements", " if (i > 0 && sortedList[i] == sortedList[i - 1]) continue", "", " var left = i + 1", " var right = sortedList.size - 1", " while (left < right) {", " val sum = sortedList[i] + sortedList[left] + sortedList[right]", " if (sum == 0) {", " return true", " } else if (sum < 0) {", " left++", " } else {", " right--", " }", " }", " }", " return false", "}", "" ]
HumanEval_kotlin/143
/** * You are an expert Kotlin programmer, and here is your task. * 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([15, -73, 14, -15]) => 1 * specialFilter([33, -2, -3, 45, 21, 109]) => 2 * */ fun specialfilter(nums : List<Int>) : Int {
specialfilter
fun main() { var arg00 : List<Int> = mutableListOf(5, -2, 1, -5) var x0 : Int = specialfilter(arg00); var v0 : Int = 0; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : List<Int> = mutableListOf(15, -73, 14, -15) var x1 : Int = specialfilter(arg10); var v1 : Int = 1; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : List<Int> = mutableListOf(33, -2, -3, 45, 21, 109) var x2 : Int = specialfilter(arg20); var v2 : Int = 2; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : List<Int> = mutableListOf(43, -12, 93, 125, 121, 109) var x3 : Int = specialfilter(arg30); var v3 : Int = 4; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : List<Int> = mutableListOf(71, -2, -33, 75, 21, 19) var x4 : Int = specialfilter(arg40); var v4 : Int = 3; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : List<Int> = mutableListOf(1) var x5 : Int = specialfilter(arg50); var v5 : Int = 0; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : List<Int> = mutableListOf() var x6 : Int = specialfilter(arg60); var v6 : Int = 0; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * 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([15, -73, 14, -15]) => 1 * specialFilter([33, -2, -3, 45, 21, 109]) => 2 * */
kotlin
[ "fun specialfilter(nums : List<Int>) : Int {", " val oddDigits = setOf('1', '3', '5', '7', '9')", "\treturn nums.count { it > 10 && it.toString().first() in oddDigits && it.toString().last() in oddDigits }", "}", "", "" ]
HumanEval_kotlin/132
/** * You are an expert Kotlin programmer, and here is your task. * 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([1,2,4,3,5]) = 3 * can_arrange([1,2,3]) = -1 * */ fun canArrange(arr : List<Int>) : Int {
canArrange
fun main() { var arg00 : List<Int> = mutableListOf(1, 2, 4, 3, 5) var x0 : Int = canArrange(arg00); var v0 : Int = 3; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : List<Int> = mutableListOf(1, 2, 4, 5) var x1 : Int = canArrange(arg10); var v1 : Int = -1; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : List<Int> = mutableListOf(1, 4, 2, 5, 6, 7, 8, 9, 10) var x2 : Int = canArrange(arg20); var v2 : Int = 2; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : List<Int> = mutableListOf(4, 8, 5, 7, 3) var x3 : Int = canArrange(arg30); var v3 : Int = 4; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : List<Int> = mutableListOf() var x4 : Int = canArrange(arg40); var v4 : Int = -1; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * 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([1,2,4,3,5]) = 3 * can_arrange([1,2,3]) = -1 * */
kotlin
[ "fun canArrange(arr : List<Int>) : Int {", " for (i in (1 until arr.size).reversed()) {", " if (arr[i] < arr[i - 1]) {", " return i", " }", " }", " return -1", "}", "", "" ]
HumanEval_kotlin/12
/** * You are an expert Kotlin programmer, and here is your task. * Out of list of strings, return the longest one. Return the first one in case of multiple * strings of the same length. Return in case the input list is empty. * >>> longest([]) * >>> longest(['a', 'b', 'c']) * 'a' * >>> longest(['a', 'bb', 'ccc']) * 'ccc' * */ fun longest(strings: List<String>): String? {
longest
fun main() { var arg00: List<String> = mutableListOf() var x0: String? = longest(arg00) var v0: String? = null if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<String> = mutableListOf("x", "y", "z") var x1: String? = longest(arg10) var v1: String? = "x" if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<String> = mutableListOf("x", "yyy", "zzzz", "www", "kkkk", "abc") var x2: String? = longest(arg20) var v2: String? = "zzzz" if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * Out of list of strings, return the longest one. Return the first one in case of multiple * strings of the same length. Return in case the input list is empty. * >>> longest([]) * >>> longest(['a', 'b', 'c']) * 'a' * >>> longest(['a', 'bb', 'ccc']) * 'ccc' * */
kotlin
[ "fun longest(strings: List<String>): String? {", " if (strings.isEmpty()) return null", "", " return strings.maxWithOrNull(compareBy { it.length })", "}", "", "" ]
HumanEval_kotlin/31
/** * You are an expert Kotlin programmer, and here is your task. * Return true if a given number is prime, and false otherwise. * >>> is_prime(6) * False * >>> is_prime(101) * True * >>> is_prime(11) * True * >>> is_prime(13441) * True * >>> is_prime(61) * True * >>> is_prime(4) * False * >>> is_prime(1) * False * */ fun isPrime(n: Int): Boolean {
isPrime
fun main() { var arg00: Int = 6 var x0: Boolean = isPrime(arg00) var v0: Boolean = false if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 101 var x1: Boolean = isPrime(arg10) var v1: Boolean = true if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 11 var x2: Boolean = isPrime(arg20) var v2: Boolean = true if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 13441 var x3: Boolean = isPrime(arg30) var v3: Boolean = true if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 61 var x4: Boolean = isPrime(arg40) var v4: Boolean = true if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: Int = 4 var x5: Boolean = isPrime(arg50) var v5: Boolean = false if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: Int = 1 var x6: Boolean = isPrime(arg60) var v6: Boolean = false if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: Int = 5 var x7: Boolean = isPrime(arg70) var v7: Boolean = true if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80: Int = 11 var x8: Boolean = isPrime(arg80) var v8: Boolean = true if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90: Int = 17 var x9: Boolean = isPrime(arg90) var v9: Boolean = true if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } var arg100: Int = 85 var x10: Boolean = isPrime(arg100) var v10: Boolean = false if (x10 != v10) { throw Exception("Exception -- test case 10 did not pass. x10 = " + x10) } var arg110: Int = 77 var x11: Boolean = isPrime(arg110) var v11: Boolean = false if (x11 != v11) { throw Exception("Exception -- test case 11 did not pass. x11 = " + x11) } var arg120: Int = 255379 var x12: Boolean = isPrime(arg120) var v12: Boolean = false if (x12 != v12) { throw Exception("Exception -- test case 12 did not pass. x12 = " + x12) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return true if a given number is prime, and false otherwise. * >>> is_prime(6) * False * >>> is_prime(101) * True * >>> is_prime(11) * True * >>> is_prime(13441) * True * >>> is_prime(61) * True * >>> is_prime(4) * False * >>> is_prime(1) * False * */
kotlin
[ "fun isPrime(n: Int): Boolean {", " if (n == 1) {", " return false", " }", " for (i in 2..n) {", " if (i * i > n) {", " break", " }", " if (n % i == 0) {", " return false", " }", " }", " return true", "}", "", "" ]
HumanEval_kotlin/102
/** * You are an expert Kotlin programmer, and here is your task. * * 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: * arr = [2, 1, 1, 4, 5, 8, 2, 3] * -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8] * -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1] * return ["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"] * * If the array is empty, return an empty array: * arr = [] * return [] * * If the array has any strange number ignore it: * arr = [1, -1 , 55] * -> sort arr -> [-1, 1, 55] * -> reverse arr -> [55, 1, -1] * return = ['One'] * */ fun byLength(arr: List<Int>): List<String> {
byLength
fun main() { var arg00: List<Int> = mutableListOf(2, 1, 1, 4, 5, 8, 2, 3) var x0: List<String> = byLength(arg00) var v0: List<String> = mutableListOf("Eight", "Five", "Four", "Three", "Two", "Two", "One", "One") if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf() var x1: List<String> = byLength(arg10) var v1: List<String> = mutableListOf() if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(1, -1, 55) var x2: List<String> = byLength(arg20) var v2: List<String> = mutableListOf("One") if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(1, -1, 3, 2) var x3: List<String> = byLength(arg30) var v3: List<String> = mutableListOf("Three", "Two", "One") if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: List<Int> = mutableListOf(9, 4, 8) var x4: List<String> = byLength(arg40) var v4: List<String> = mutableListOf("Nine", "Eight", "Four") if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * * 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: * arr = [2, 1, 1, 4, 5, 8, 2, 3] * -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8] * -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1] * return ["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"] * * If the array is empty, return an empty array: * arr = [] * return [] * * If the array has any strange number ignore it: * arr = [1, -1 , 55] * -> sort arr -> [-1, 1, 55] * -> reverse arr -> [55, 1, -1] * return = ['One'] * */
kotlin
[ "fun byLength(arr: List<Int>): List<String> {", " val numberNames = mapOf(", " 1 to \"One\", 2 to \"Two\", 3 to \"Three\", 4 to \"Four\",", " 5 to \"Five\", 6 to \"Six\", 7 to \"Seven\", 8 to \"Eight\", 9 to \"Nine\"", " )", "", " // Filter, sort, reverse, and then map integers to their corresponding names", " return arr.filter { it in 1..9 }", " .sorted()", " .reversed()", " .mapNotNull { numberNames[it] }", "}", "", "" ]
HumanEval_kotlin/64
/** * You are an expert Kotlin programmer, and here is your task. * * In this task, you will be given a string that represents a number of apples and oranges * that are distributed in a basket of fruit this basket contains * apples, oranges, and mango fruits. Given the string that represents the total number of * the oranges and apples and an integer that represent the total number of the fruits * in the basket return the number of the mango fruits in the basket. * for example: * fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 - 6 = 8 * fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 - 1 = 2 * fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 - 3 = 95 * fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 - 1 = 19 * */ fun fruitDistribution(s: String, totalFruits: Int): Int {
fruitDistribution
fun main() { var arg00: String = "5 apples and 6 oranges" var arg01: Int = 19 var x0: Int = fruitDistribution(arg00, arg01) var v0: Int = 8 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "5 apples and 6 oranges" var arg11: Int = 21 var x1: Int = fruitDistribution(arg10, arg11) var v1: Int = 10 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "0 apples and 1 oranges" var arg21: Int = 3 var x2: Int = fruitDistribution(arg20, arg21) var v2: Int = 2 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "1 apples and 0 oranges" var arg31: Int = 3 var x3: Int = fruitDistribution(arg30, arg31) var v3: Int = 2 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "2 apples and 3 oranges" var arg41: Int = 100 var x4: Int = fruitDistribution(arg40, arg41) var v4: Int = 95 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: String = "2 apples and 3 oranges" var arg51: Int = 5 var x5: Int = fruitDistribution(arg50, arg51) var v5: Int = 0 if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: String = "1 apples and 100 oranges" var arg61: Int = 120 var x6: Int = fruitDistribution(arg60, arg61) var v6: Int = 19 if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * * In this task, you will be given a string that represents a number of apples and oranges * that are distributed in a basket of fruit this basket contains * apples, oranges, and mango fruits. Given the string that represents the total number of * the oranges and apples and an integer that represent the total number of the fruits * in the basket return the number of the mango fruits in the basket. * for example: * fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 - 6 = 8 * fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 - 1 = 2 * fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 - 3 = 95 * fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 - 1 = 19 * */
kotlin
[ "fun fruitDistribution(s: String, totalFruits: Int): Int {", " // Extract the numbers from the string", " val numbers = s.split(\" \").filter { it.toIntOrNull() != null }.map { it.toInt() }", " // Assuming the string format is always \"<number> apples and <number> oranges\"", " val apples = numbers[0]", " val oranges = numbers[1]", "", " // Calculate the number of mangoes", " return totalFruits - apples - oranges", "}", "", "" ]
HumanEval_kotlin/157
/** * You are an expert Kotlin programmer, and here is your task. * * Given two lists operator, and operand. The first list has basic algebra operations, and * the second list is a list of integers. Use the two given lists to build the algebric * expression and return the evaluation of this expression. * The basic algebra operations: * Addition ( + ) * Subtraction ( - ) * Multiplication ( * ) * Floor division ( // ) * Exponentiation ( ** ) * Example: * operator['+', '*', '-'] * array = [2, 3, 4, 5] * result = 2 + 3 * 4 - 5 * => result = 9 * Note: * The length of operator list is equal to the length of operand list minus one. * Operand is a list of of non-negative integers. * Operator list has at least one operator, and operand list has at least two operands. * */ fun doAlgebra(operator: List<String>, operand: List<Int>): Int {
doAlgebra
fun main() { var arg00: List<String> = mutableListOf("**", "*", "+") var arg01: List<Int> = mutableListOf(2, 3, 4, 5) var x0: Int = doAlgebra(arg00, arg01); var v0: Int = 37; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<String> = mutableListOf("+", "*", "-") var arg11: List<Int> = mutableListOf(2, 3, 4, 5) var x1: Int = doAlgebra(arg10, arg11); var v1: Int = 9; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<String> = mutableListOf("//", "*") var arg21: List<Int> = mutableListOf(7, 3, 4) var x2: Int = doAlgebra(arg20, arg21); var v2: Int = 8; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * * Given two lists operator, and operand. The first list has basic algebra operations, and * the second list is a list of integers. Use the two given lists to build the algebric * expression and return the evaluation of this expression. * The basic algebra operations: * Addition ( + ) * Subtraction ( - ) * Multiplication ( * ) * Floor division ( // ) * Exponentiation ( ** ) * Example: * operator['+', '*', '-'] * array = [2, 3, 4, 5] * result = 2 + 3 * 4 - 5 * => result = 9 * Note: * The length of operator list is equal to the length of operand list minus one. * Operand is a list of of non-negative integers. * Operator list has at least one operator, and operand list has at least two operands. * */
kotlin
[ "fun doAlgebra(operator: List<String>, operand: List<Int>): Int {", " if (operator.isEmpty()) {", " return operand[0]", " }", " operator.withIndex().reversed().forEach { (index, op) ->", " when (op) {", " \"+\" -> return doAlgebra(operator.subList(0, index), operand.subList(0, index + 1)) +", " doAlgebra(operator.subList(index + 1, operator.size), operand.subList(index + 1, operand.size))", "", " \"-\" -> return doAlgebra(operator.subList(0, index), operand.subList(0, index + 1)) -", " doAlgebra(operator.subList(index + 1, operator.size), operand.subList(index + 1, operand.size))", " }", " }", " operator.withIndex().reversed().forEach { (index, op) ->", " when (op) {", " \"*\" -> return doAlgebra(operator.subList(0, index), operand.subList(0, index + 1)) *", " doAlgebra(operator.subList(index + 1, operator.size), operand.subList(index + 1, operand.size))", "", " \"//\" -> return doAlgebra(operator.subList(0, index), operand.subList(0, index + 1)) /", " doAlgebra(operator.subList(index + 1, operator.size), operand.subList(index + 1, operand.size))", " }", " }", " operator.withIndex().reversed().forEach { (index, op) ->", " when (op) {", " \"**\" -> return Math.pow(", " doAlgebra(operator.subList(0, index), operand.subList(0, index + 1)).toDouble(),", " doAlgebra(operator.subList(index + 1, operator.size), operand.subList(index + 1, operand.size)).toDouble()", " ).toInt()", " }", " }", "", " throw Exception(\"Invalid operator\")", "}", "", "" ]
HumanEval_kotlin/96
/** * You are an expert Kotlin programmer, and here is your task. * * Create a function that takes a value (string) representing a number * and returns the closest integer to it. If the number is equidistant * from two integers, round it away from zero. * Examples * >>> closest_integer("10") * 10 * >>> closest_integer("15.3") * 15 * Note: * Rounding away from zero means that if the given number is equidistant * from two integers, the one you should return is the one that is the * farthest from zero. For example closest_integer("14.5") should * return 15 and closest_integer("-14.5") should return -15. * */ fun closestInteger(value: String): Int {
closestInteger
fun main() { var arg00: String = "10" var x0: Int = closestInteger(arg00) var v0: Int = 10 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "14.5" var x1: Int = closestInteger(arg10) var v1: Int = 15 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "-15.5" var x2: Int = closestInteger(arg20) var v2: Int = -16 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "15.3" var x3: Int = closestInteger(arg30) var v3: Int = 15 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "0" var x4: Int = closestInteger(arg40) var v4: Int = 0 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * * Create a function that takes a value (string) representing a number * and returns the closest integer to it. If the number is equidistant * from two integers, round it away from zero. * Examples * >>> closest_integer("10") * 10 * >>> closest_integer("15.3") * 15 * Note: * Rounding away from zero means that if the given number is equidistant * from two integers, the one you should return is the one that is the * farthest from zero. For example closest_integer("14.5") should * return 15 and closest_integer("-14.5") should return -15. * */
kotlin
[ "fun closestInteger(value: String): Int {", " val number = value.toDouble()", " val fractionalPart = number % 1.0", " val isHalf = fractionalPart == 0.5 || fractionalPart == -0.5", "", " return if (isHalf) {", " if (number > 0) Math.ceil(number).toInt() else Math.floor(number).toInt()", " } else {", " Math.round(number).toInt()", " }", "}", "", "" ]
HumanEval_kotlin/44
/** * You are an expert Kotlin programmer, and here is your task. * The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows: * fib4(0) -> 0 * fib4(1) -> 0 * fib4(2) -> 2 * fib4(3) -> 0 * fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4). * Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion. * >>> fib4(5) * 4 * >>> fib4(6) * 8 * >>> fib4(7) * 14 * */ fun fib4(n: Int): Int {
fib4
fun main() { var arg00: Int = 5 var x0: Int = fib4(arg00) var v0: Int = 4 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 8 var x1: Int = fib4(arg10) var v1: Int = 28 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 10 var x2: Int = fib4(arg20) var v2: Int = 104 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 12 var x3: Int = fib4(arg30) var v3: Int = 386 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows: * fib4(0) -> 0 * fib4(1) -> 0 * fib4(2) -> 2 * fib4(3) -> 0 * fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4). * Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion. * >>> fib4(5) * 4 * >>> fib4(6) * 8 * >>> fib4(7) * 14 * */
kotlin
[ "fun fib4(n: Int): Int {", " val fibs = mutableListOf(0, 0, 2, 0)", " var index = 0", " while (fibs.size <= n) {", " fibs.add(fibs[index] + fibs[index + 1] + fibs[index + 2] + fibs[index + 3])", " index++", " }", " return fibs[n]", "}", "", "" ]
HumanEval_kotlin/63
/** * You are an expert Kotlin programmer, and here is your task. * Task * Write a function that takes a string as input and returns the sum of the upper characters only' * ASCII codes. * Examples: * digitSum("") => 0 * digitSum("abAB") => 131 * digitSum("abcCd") => 67 * digitSum("helloE") => 69 * digitSum("woArBld") => 131 * digitSum("aAaaaXa") => 153 * */ fun digitsum(s: String): Int {
digitsum
fun main() { var arg00: String = "" var x0: Int = digitsum(arg00) var v0: Int = 0 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "abAB" var x1: Int = digitsum(arg10) var v1: Int = 131 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "abcCd" var x2: Int = digitsum(arg20) var v2: Int = 67 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "helloE" var x3: Int = digitsum(arg30) var v3: Int = 69 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "woArBld" var x4: Int = digitsum(arg40) var v4: Int = 131 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: String = "aAaaaXa" var x5: Int = digitsum(arg50) var v5: Int = 153 if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: String = " How are yOu?" var x6: Int = digitsum(arg60) var v6: Int = 151 if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: String = "You arE Very Smart" var x7: Int = digitsum(arg70) var v7: Int = 327 if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * Task * Write a function that takes a string as input and returns the sum of the upper characters only' * ASCII codes. * Examples: * digitSum("") => 0 * digitSum("abAB") => 131 * digitSum("abcCd") => 67 * digitSum("helloE") => 69 * digitSum("woArBld") => 131 * digitSum("aAaaaXa") => 153 * */
kotlin
[ "fun digitsum(s: String): Int {", " return s.filter { it.isUpperCase() }.map { it.code }.sum()", "}", "", "" ]
HumanEval_kotlin/14
/** * You are an expert Kotlin programmer, and here is your task. * Return list of all prefixes from shortest to longest of the input string * >>> all_prefixes('abc') * ['a', 'ab', 'abc'] * */ fun allPrefixes(string: String): List<Any> {
allPrefixes
fun main() { var arg00: String = "" var x0: List<Any> = allPrefixes(arg00) var v0: List<Any> = mutableListOf() if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "asdfgh" var x1: List<Any> = allPrefixes(arg10) var v1: List<Any> = mutableListOf("a", "as", "asd", "asdf", "asdfg", "asdfgh") if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "WWW" var x2: List<Any> = allPrefixes(arg20) var v2: List<Any> = mutableListOf("W", "WW", "WWW") if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } }
/** * You are an expert Kotlin programmer, and here is your task. * Return list of all prefixes from shortest to longest of the input string * >>> all_prefixes('abc') * ['a', 'ab', 'abc'] * */
kotlin
[ "fun allPrefixes(string: String): List<Any> {", " return string.indices.map { index ->", " string.substring(0, index + 1)", " }", "}", "", "" ]
HumanEval_kotlin/95
/** * You are an expert Kotlin programmer, and here is your task. * * 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 * */ fun countUpper(s: String): Int {
countUpper
fun main() { var arg00: String = "abcdefg" var x0: Int = countUpper(arg00) var v0: Int = 0 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "dBBE" var x1: Int = countUpper(arg10) var v1: Int = 0 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "" var x2: Int = countUpper(arg20) var v2: Int = 0 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "EEEE" var x3: Int = countUpper(arg30) var v3: Int = 2 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * * 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 * */
kotlin
[ "fun countUpper(s: String): Int {", " val vowels = setOf('A', 'E', 'I', 'O', 'U')", " return s.filterIndexed { index, c -> index % 2 == 0 && c in vowels }.length", "}", "", "" ]
HumanEval_kotlin/9
/** * You are an expert Kotlin programmer, and here is your task. * 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] * */ fun rollingMax(numbers: List<Int>): List<Int> {
rollingMax
fun main() { var arg00: List<Int> = mutableListOf() var x0: List<Int> = rollingMax(arg00) var v0: List<Int> = mutableListOf() if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(1, 2, 3, 4) var x1: List<Int> = rollingMax(arg10) var v1: List<Int> = mutableListOf(1, 2, 3, 4) if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(4, 3, 2, 1) var x2: List<Int> = rollingMax(arg20) var v2: List<Int> = mutableListOf(4, 4, 4, 4) if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(3, 2, 3, 100, 3) var x3: List<Int> = rollingMax(arg30) var v3: List<Int> = mutableListOf(3, 3, 3, 100, 100) if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } }
/** * You are an expert Kotlin programmer, and here is your task. * 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] * */
kotlin
[ "fun rollingMax(numbers: List<Int>): List<Int> {", " return numbers.runningFold(0) { mx, value -> Math.max(mx, value) }.drop(1)", "}", "", "" ]
HumanEval_kotlin/152
/** * You are an expert Kotlin programmer, and here is your task. * Given an integer. return a tuple that has the number of even and odd digits respectively. * Example: * even_odd_count(-12) ==> (1, 1) * even_odd_count(123) ==> (1, 2) * */ fun evenOddCount(num : Int) : List<Int> {
evenOddCount
fun main() { var arg00 : Int = 7 var x0 : List<Int> = evenOddCount(arg00); var v0 : List<Int> = mutableListOf(0, 1); if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : Int = -78 var x1 : List<Int> = evenOddCount(arg10); var v1 : List<Int> = mutableListOf(1, 1); if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : Int = 3452 var x2 : List<Int> = evenOddCount(arg20); var v2 : List<Int> = mutableListOf(2, 2); if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : Int = 346211 var x3 : List<Int> = evenOddCount(arg30); var v3 : List<Int> = mutableListOf(3, 3); if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : Int = -345821 var x4 : List<Int> = evenOddCount(arg40); var v4 : List<Int> = mutableListOf(3, 3); if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : Int = -2 var x5 : List<Int> = evenOddCount(arg50); var v5 : List<Int> = mutableListOf(1, 0); if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : Int = -45347 var x6 : List<Int> = evenOddCount(arg60); var v6 : List<Int> = mutableListOf(2, 3); if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70 : Int = 0 var x7 : List<Int> = evenOddCount(arg70); var v7 : List<Int> = mutableListOf(1, 0); if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * Given an integer. return a tuple that has the number of even and odd digits respectively. * Example: * even_odd_count(-12) ==> (1, 1) * even_odd_count(123) ==> (1, 2) * */
kotlin
[ "fun evenOddCount(num : Int) : List<Int> {", " val digits = num.toString().filter { it.isDigit() }", " val evenCount = digits.count { (it - '0') % 2 == 0 }", "\treturn listOf(evenCount, digits.length - evenCount)", "}", "", "" ]
HumanEval_kotlin/50
/** * You are an expert Kotlin programmer, and here is your task. * Add two numbers x and y * >>> add(2, 3) * 5 * >>> add(5, 7) * 12 * */ fun add(x: Int, y: Int): Int {
add
fun main() { var arg00: Int = 0 var arg01: Int = 1 var x0: Int = add(arg00, arg01) var v0: Int = 1 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: Int = 1 var arg11: Int = 0 var x1: Int = add(arg10, arg11) var v1: Int = 1 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: Int = 2 var arg21: Int = 3 var x2: Int = add(arg20, arg21) var v2: Int = 5 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: Int = 5 var arg31: Int = 7 var x3: Int = add(arg30, arg31) var v3: Int = 12 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: Int = 7 var arg41: Int = 5 var x4: Int = add(arg40, arg41) var v4: Int = 12 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: Int = 572 var arg51: Int = 725 var x5: Int = add(arg50, arg51) var v5: Int = 1297 if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: Int = 51 var arg61: Int = 804 var x6: Int = add(arg60, arg61) var v6: Int = 855 if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: Int = 645 var arg71: Int = 96 var x7: Int = add(arg70, arg71) var v7: Int = 741 if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80: Int = 712 var arg81: Int = 853 var x8: Int = add(arg80, arg81) var v8: Int = 1565 if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90: Int = 223 var arg91: Int = 101 var x9: Int = add(arg90, arg91) var v9: Int = 324 if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } var arg100: Int = 76 var arg101: Int = 29 var x10: Int = add(arg100, arg101) var v10: Int = 105 if (x10 != v10) { throw Exception("Exception -- test case 10 did not pass. x10 = " + x10) } var arg110: Int = 416 var arg111: Int = 149 var x11: Int = add(arg110, arg111) var v11: Int = 565 if (x11 != v11) { throw Exception("Exception -- test case 11 did not pass. x11 = " + x11) } var arg120: Int = 145 var arg121: Int = 409 var x12: Int = add(arg120, arg121) var v12: Int = 554 if (x12 != v12) { throw Exception("Exception -- test case 12 did not pass. x12 = " + x12) } var arg130: Int = 535 var arg131: Int = 430 var x13: Int = add(arg130, arg131) var v13: Int = 965 if (x13 != v13) { throw Exception("Exception -- test case 13 did not pass. x13 = " + x13) } var arg140: Int = 118 var arg141: Int = 303 var x14: Int = add(arg140, arg141) var v14: Int = 421 if (x14 != v14) { throw Exception("Exception -- test case 14 did not pass. x14 = " + x14) } var arg150: Int = 287 var arg151: Int = 94 var x15: Int = add(arg150, arg151) var v15: Int = 381 if (x15 != v15) { throw Exception("Exception -- test case 15 did not pass. x15 = " + x15) } var arg160: Int = 768 var arg161: Int = 257 var x16: Int = add(arg160, arg161) var v16: Int = 1025 if (x16 != v16) { throw Exception("Exception -- test case 16 did not pass. x16 = " + x16) } var arg170: Int = 421 var arg171: Int = 677 var x17: Int = add(arg170, arg171) var v17: Int = 1098 if (x17 != v17) { throw Exception("Exception -- test case 17 did not pass. x17 = " + x17) } var arg180: Int = 802 var arg181: Int = 814 var x18: Int = add(arg180, arg181) var v18: Int = 1616 if (x18 != v18) { throw Exception("Exception -- test case 18 did not pass. x18 = " + x18) } var arg190: Int = 510 var arg191: Int = 922 var x19: Int = add(arg190, arg191) var v19: Int = 1432 if (x19 != v19) { throw Exception("Exception -- test case 19 did not pass. x19 = " + x19) } var arg200: Int = 345 var arg201: Int = 819 var x20: Int = add(arg200, arg201) var v20: Int = 1164 if (x20 != v20) { throw Exception("Exception -- test case 20 did not pass. x20 = " + x20) } var arg210: Int = 895 var arg211: Int = 436 var x21: Int = add(arg210, arg211) var v21: Int = 1331 if (x21 != v21) { throw Exception("Exception -- test case 21 did not pass. x21 = " + x21) } var arg220: Int = 123 var arg221: Int = 424 var x22: Int = add(arg220, arg221) var v22: Int = 547 if (x22 != v22) { throw Exception("Exception -- test case 22 did not pass. x22 = " + x22) } var arg230: Int = 923 var arg231: Int = 245 var x23: Int = add(arg230, arg231) var v23: Int = 1168 if (x23 != v23) { throw Exception("Exception -- test case 23 did not pass. x23 = " + x23) } var arg240: Int = 23 var arg241: Int = 438 var x24: Int = add(arg240, arg241) var v24: Int = 461 if (x24 != v24) { throw Exception("Exception -- test case 24 did not pass. x24 = " + x24) } var arg250: Int = 565 var arg251: Int = 133 var x25: Int = add(arg250, arg251) var v25: Int = 698 if (x25 != v25) { throw Exception("Exception -- test case 25 did not pass. x25 = " + x25) } var arg260: Int = 945 var arg261: Int = 925 var x26: Int = add(arg260, arg261) var v26: Int = 1870 if (x26 != v26) { throw Exception("Exception -- test case 26 did not pass. x26 = " + x26) } var arg270: Int = 261 var arg271: Int = 983 var x27: Int = add(arg270, arg271) var v27: Int = 1244 if (x27 != v27) { throw Exception("Exception -- test case 27 did not pass. x27 = " + x27) } var arg280: Int = 139 var arg281: Int = 577 var x28: Int = add(arg280, arg281) var v28: Int = 716 if (x28 != v28) { throw Exception("Exception -- test case 28 did not pass. x28 = " + x28) } var arg290: Int = 763 var arg291: Int = 178 var x29: Int = add(arg290, arg291) var v29: Int = 941 if (x29 != v29) { throw Exception("Exception -- test case 29 did not pass. x29 = " + x29) } var arg300: Int = 147 var arg301: Int = 892 var x30: Int = add(arg300, arg301) var v30: Int = 1039 if (x30 != v30) { throw Exception("Exception -- test case 30 did not pass. x30 = " + x30) } var arg310: Int = 436 var arg311: Int = 402 var x31: Int = add(arg310, arg311) var v31: Int = 838 if (x31 != v31) { throw Exception("Exception -- test case 31 did not pass. x31 = " + x31) } var arg320: Int = 610 var arg321: Int = 581 var x32: Int = add(arg320, arg321) var v32: Int = 1191 if (x32 != v32) { throw Exception("Exception -- test case 32 did not pass. x32 = " + x32) } var arg330: Int = 103 var arg331: Int = 416 var x33: Int = add(arg330, arg331) var v33: Int = 519 if (x33 != v33) { throw Exception("Exception -- test case 33 did not pass. x33 = " + x33) } var arg340: Int = 339 var arg341: Int = 990 var x34: Int = add(arg340, arg341) var v34: Int = 1329 if (x34 != v34) { throw Exception("Exception -- test case 34 did not pass. x34 = " + x34) } var arg350: Int = 130 var arg351: Int = 504 var x35: Int = add(arg350, arg351) var v35: Int = 634 if (x35 != v35) { throw Exception("Exception -- test case 35 did not pass. x35 = " + x35) } var arg360: Int = 242 var arg361: Int = 717 var x36: Int = add(arg360, arg361) var v36: Int = 959 if (x36 != v36) { throw Exception("Exception -- test case 36 did not pass. x36 = " + x36) } var arg370: Int = 562 var arg371: Int = 110 var x37: Int = add(arg370, arg371) var v37: Int = 672 if (x37 != v37) { throw Exception("Exception -- test case 37 did not pass. x37 = " + x37) } var arg380: Int = 396 var arg381: Int = 909 var x38: Int = add(arg380, arg381) var v38: Int = 1305 if (x38 != v38) { throw Exception("Exception -- test case 38 did not pass. x38 = " + x38) } var arg390: Int = 887 var arg391: Int = 703 var x39: Int = add(arg390, arg391) var v39: Int = 1590 if (x39 != v39) { throw Exception("Exception -- test case 39 did not pass. x39 = " + x39) } var arg400: Int = 870 var arg401: Int = 551 var x40: Int = add(arg400, arg401) var v40: Int = 1421 if (x40 != v40) { throw Exception("Exception -- test case 40 did not pass. x40 = " + x40) } var arg410: Int = 422 var arg411: Int = 391 var x41: Int = add(arg410, arg411) var v41: Int = 813 if (x41 != v41) { throw Exception("Exception -- test case 41 did not pass. x41 = " + x41) } var arg420: Int = 299 var arg421: Int = 505 var x42: Int = add(arg420, arg421) var v42: Int = 804 if (x42 != v42) { throw Exception("Exception -- test case 42 did not pass. x42 = " + x42) } var arg430: Int = 346 var arg431: Int = 56 var x43: Int = add(arg430, arg431) var v43: Int = 402 if (x43 != v43) { throw Exception("Exception -- test case 43 did not pass. x43 = " + x43) } var arg440: Int = 36 var arg441: Int = 706 var x44: Int = add(arg440, arg441) var v44: Int = 742 if (x44 != v44) { throw Exception("Exception -- test case 44 did not pass. x44 = " + x44) } var arg450: Int = 738 var arg451: Int = 411 var x45: Int = add(arg450, arg451) var v45: Int = 1149 if (x45 != v45) { throw Exception("Exception -- test case 45 did not pass. x45 = " + x45) } var arg460: Int = 679 var arg461: Int = 87 var x46: Int = add(arg460, arg461) var v46: Int = 766 if (x46 != v46) { throw Exception("Exception -- test case 46 did not pass. x46 = " + x46) } var arg470: Int = 25 var arg471: Int = 303 var x47: Int = add(arg470, arg471) var v47: Int = 328 if (x47 != v47) { throw Exception("Exception -- test case 47 did not pass. x47 = " + x47) } var arg480: Int = 161 var arg481: Int = 612 var x48: Int = add(arg480, arg481) var v48: Int = 773 if (x48 != v48) { throw Exception("Exception -- test case 48 did not pass. x48 = " + x48) } var arg490: Int = 306 var arg491: Int = 841 var x49: Int = add(arg490, arg491) var v49: Int = 1147 if (x49 != v49) { throw Exception("Exception -- test case 49 did not pass. x49 = " + x49) } var arg500: Int = 973 var arg501: Int = 411 var x50: Int = add(arg500, arg501) var v50: Int = 1384 if (x50 != v50) { throw Exception("Exception -- test case 50 did not pass. x50 = " + x50) } var arg510: Int = 711 var arg511: Int = 157 var x51: Int = add(arg510, arg511) var v51: Int = 868 if (x51 != v51) { throw Exception("Exception -- test case 51 did not pass. x51 = " + x51) } var arg520: Int = 471 var arg521: Int = 27 var x52: Int = add(arg520, arg521) var v52: Int = 498 if (x52 != v52) { throw Exception("Exception -- test case 52 did not pass. x52 = " + x52) } var arg530: Int = 714 var arg531: Int = 792 var x53: Int = add(arg530, arg531) var v53: Int = 1506 if (x53 != v53) { throw Exception("Exception -- test case 53 did not pass. x53 = " + x53) } var arg540: Int = 38 var arg541: Int = 206 var x54: Int = add(arg540, arg541) var v54: Int = 244 if (x54 != v54) { throw Exception("Exception -- test case 54 did not pass. x54 = " + x54) } var arg550: Int = 907 var arg551: Int = 343 var x55: Int = add(arg550, arg551) var v55: Int = 1250 if (x55 != v55) { throw Exception("Exception -- test case 55 did not pass. x55 = " + x55) } var arg560: Int = 23 var arg561: Int = 760 var x56: Int = add(arg560, arg561) var v56: Int = 783 if (x56 != v56) { throw Exception("Exception -- test case 56 did not pass. x56 = " + x56) } var arg570: Int = 524 var arg571: Int = 859 var x57: Int = add(arg570, arg571) var v57: Int = 1383 if (x57 != v57) { throw Exception("Exception -- test case 57 did not pass. x57 = " + x57) } var arg580: Int = 30 var arg581: Int = 529 var x58: Int = add(arg580, arg581) var v58: Int = 559 if (x58 != v58) { throw Exception("Exception -- test case 58 did not pass. x58 = " + x58) } var arg590: Int = 341 var arg591: Int = 691 var x59: Int = add(arg590, arg591) var v59: Int = 1032 if (x59 != v59) { throw Exception("Exception -- test case 59 did not pass. x59 = " + x59) } var arg600: Int = 167 var arg601: Int = 729 var x60: Int = add(arg600, arg601) var v60: Int = 896 if (x60 != v60) { throw Exception("Exception -- test case 60 did not pass. x60 = " + x60) } var arg610: Int = 636 var arg611: Int = 289 var x61: Int = add(arg610, arg611) var v61: Int = 925 if (x61 != v61) { throw Exception("Exception -- test case 61 did not pass. x61 = " + x61) } var arg620: Int = 503 var arg621: Int = 144 var x62: Int = add(arg620, arg621) var v62: Int = 647 if (x62 != v62) { throw Exception("Exception -- test case 62 did not pass. x62 = " + x62) } var arg630: Int = 51 var arg631: Int = 985 var x63: Int = add(arg630, arg631) var v63: Int = 1036 if (x63 != v63) { throw Exception("Exception -- test case 63 did not pass. x63 = " + x63) } var arg640: Int = 287 var arg641: Int = 149 var x64: Int = add(arg640, arg641) var v64: Int = 436 if (x64 != v64) { throw Exception("Exception -- test case 64 did not pass. x64 = " + x64) } var arg650: Int = 659 var arg651: Int = 75 var x65: Int = add(arg650, arg651) var v65: Int = 734 if (x65 != v65) { throw Exception("Exception -- test case 65 did not pass. x65 = " + x65) } var arg660: Int = 462 var arg661: Int = 797 var x66: Int = add(arg660, arg661) var v66: Int = 1259 if (x66 != v66) { throw Exception("Exception -- test case 66 did not pass. x66 = " + x66) } var arg670: Int = 406 var arg671: Int = 141 var x67: Int = add(arg670, arg671) var v67: Int = 547 if (x67 != v67) { throw Exception("Exception -- test case 67 did not pass. x67 = " + x67) } var arg680: Int = 106 var arg681: Int = 44 var x68: Int = add(arg680, arg681) var v68: Int = 150 if (x68 != v68) { throw Exception("Exception -- test case 68 did not pass. x68 = " + x68) } var arg690: Int = 300 var arg691: Int = 934 var x69: Int = add(arg690, arg691) var v69: Int = 1234 if (x69 != v69) { throw Exception("Exception -- test case 69 did not pass. x69 = " + x69) } var arg700: Int = 471 var arg701: Int = 524 var x70: Int = add(arg700, arg701) var v70: Int = 995 if (x70 != v70) { throw Exception("Exception -- test case 70 did not pass. x70 = " + x70) } var arg710: Int = 122 var arg711: Int = 429 var x71: Int = add(arg710, arg711) var v71: Int = 551 if (x71 != v71) { throw Exception("Exception -- test case 71 did not pass. x71 = " + x71) } var arg720: Int = 735 var arg721: Int = 195 var x72: Int = add(arg720, arg721) var v72: Int = 930 if (x72 != v72) { throw Exception("Exception -- test case 72 did not pass. x72 = " + x72) } var arg730: Int = 335 var arg731: Int = 484 var x73: Int = add(arg730, arg731) var v73: Int = 819 if (x73 != v73) { throw Exception("Exception -- test case 73 did not pass. x73 = " + x73) } var arg740: Int = 28 var arg741: Int = 809 var x74: Int = add(arg740, arg741) var v74: Int = 837 if (x74 != v74) { throw Exception("Exception -- test case 74 did not pass. x74 = " + x74) } var arg750: Int = 430 var arg751: Int = 20 var x75: Int = add(arg750, arg751) var v75: Int = 450 if (x75 != v75) { throw Exception("Exception -- test case 75 did not pass. x75 = " + x75) } var arg760: Int = 916 var arg761: Int = 635 var x76: Int = add(arg760, arg761) var v76: Int = 1551 if (x76 != v76) { throw Exception("Exception -- test case 76 did not pass. x76 = " + x76) } var arg770: Int = 301 var arg771: Int = 999 var x77: Int = add(arg770, arg771) var v77: Int = 1300 if (x77 != v77) { throw Exception("Exception -- test case 77 did not pass. x77 = " + x77) } var arg780: Int = 454 var arg781: Int = 466 var x78: Int = add(arg780, arg781) var v78: Int = 920 if (x78 != v78) { throw Exception("Exception -- test case 78 did not pass. x78 = " + x78) } var arg790: Int = 905 var arg791: Int = 259 var x79: Int = add(arg790, arg791) var v79: Int = 1164 if (x79 != v79) { throw Exception("Exception -- test case 79 did not pass. x79 = " + x79) } var arg800: Int = 168 var arg801: Int = 205 var x80: Int = add(arg800, arg801) var v80: Int = 373 if (x80 != v80) { throw Exception("Exception -- test case 80 did not pass. x80 = " + x80) } var arg810: Int = 570 var arg811: Int = 434 var x81: Int = add(arg810, arg811) var v81: Int = 1004 if (x81 != v81) { throw Exception("Exception -- test case 81 did not pass. x81 = " + x81) } var arg820: Int = 64 var arg821: Int = 959 var x82: Int = add(arg820, arg821) var v82: Int = 1023 if (x82 != v82) { throw Exception("Exception -- test case 82 did not pass. x82 = " + x82) } var arg830: Int = 957 var arg831: Int = 510 var x83: Int = add(arg830, arg831) var v83: Int = 1467 if (x83 != v83) { throw Exception("Exception -- test case 83 did not pass. x83 = " + x83) } var arg840: Int = 722 var arg841: Int = 598 var x84: Int = add(arg840, arg841) var v84: Int = 1320 if (x84 != v84) { throw Exception("Exception -- test case 84 did not pass. x84 = " + x84) } var arg850: Int = 770 var arg851: Int = 226 var x85: Int = add(arg850, arg851) var v85: Int = 996 if (x85 != v85) { throw Exception("Exception -- test case 85 did not pass. x85 = " + x85) } var arg860: Int = 579 var arg861: Int = 66 var x86: Int = add(arg860, arg861) var v86: Int = 645 if (x86 != v86) { throw Exception("Exception -- test case 86 did not pass. x86 = " + x86) } var arg870: Int = 117 var arg871: Int = 674 var x87: Int = add(arg870, arg871) var v87: Int = 791 if (x87 != v87) { throw Exception("Exception -- test case 87 did not pass. x87 = " + x87) } var arg880: Int = 530 var arg881: Int = 30 var x88: Int = add(arg880, arg881) var v88: Int = 560 if (x88 != v88) { throw Exception("Exception -- test case 88 did not pass. x88 = " + x88) } var arg890: Int = 776 var arg891: Int = 345 var x89: Int = add(arg890, arg891) var v89: Int = 1121 if (x89 != v89) { throw Exception("Exception -- test case 89 did not pass. x89 = " + x89) } var arg900: Int = 327 var arg901: Int = 389 var x90: Int = add(arg900, arg901) var v90: Int = 716 if (x90 != v90) { throw Exception("Exception -- test case 90 did not pass. x90 = " + x90) } var arg910: Int = 596 var arg911: Int = 12 var x91: Int = add(arg910, arg911) var v91: Int = 608 if (x91 != v91) { throw Exception("Exception -- test case 91 did not pass. x91 = " + x91) } var arg920: Int = 599 var arg921: Int = 511 var x92: Int = add(arg920, arg921) var v92: Int = 1110 if (x92 != v92) { throw Exception("Exception -- test case 92 did not pass. x92 = " + x92) } var arg930: Int = 936 var arg931: Int = 476 var x93: Int = add(arg930, arg931) var v93: Int = 1412 if (x93 != v93) { throw Exception("Exception -- test case 93 did not pass. x93 = " + x93) } var arg940: Int = 461 var arg941: Int = 14 var x94: Int = add(arg940, arg941) var v94: Int = 475 if (x94 != v94) { throw Exception("Exception -- test case 94 did not pass. x94 = " + x94) } var arg950: Int = 966 var arg951: Int = 157 var x95: Int = add(arg950, arg951) var v95: Int = 1123 if (x95 != v95) { throw Exception("Exception -- test case 95 did not pass. x95 = " + x95) } var arg960: Int = 326 var arg961: Int = 91 var x96: Int = add(arg960, arg961) var v96: Int = 417 if (x96 != v96) { throw Exception("Exception -- test case 96 did not pass. x96 = " + x96) } var arg970: Int = 392 var arg971: Int = 455 var x97: Int = add(arg970, arg971) var v97: Int = 847 if (x97 != v97) { throw Exception("Exception -- test case 97 did not pass. x97 = " + x97) } var arg980: Int = 446 var arg981: Int = 477 var x98: Int = add(arg980, arg981) var v98: Int = 923 if (x98 != v98) { throw Exception("Exception -- test case 98 did not pass. x98 = " + x98) } var arg990: Int = 324 var arg991: Int = 860 var x99: Int = add(arg990, arg991) var v99: Int = 1184 if (x99 != v99) { throw Exception("Exception -- test case 99 did not pass. x99 = " + x99) } var arg1000: Int = 945 var arg1001: Int = 85 var x100: Int = add(arg1000, arg1001) var v100: Int = 1030 if (x100 != v100) { throw Exception("Exception -- test case 100 did not pass. x100 = " + x100) } var arg1010: Int = 886 var arg1011: Int = 582 var x101: Int = add(arg1010, arg1011) var v101: Int = 1468 if (x101 != v101) { throw Exception("Exception -- test case 101 did not pass. x101 = " + x101) } var arg1020: Int = 886 var arg1021: Int = 712 var x102: Int = add(arg1020, arg1021) var v102: Int = 1598 if (x102 != v102) { throw Exception("Exception -- test case 102 did not pass. x102 = " + x102) } var arg1030: Int = 842 var arg1031: Int = 953 var x103: Int = add(arg1030, arg1031) var v103: Int = 1795 if (x103 != v103) { throw Exception("Exception -- test case 103 did not pass. x103 = " + x103) } }
/** * You are an expert Kotlin programmer, and here is your task. * Add two numbers x and y * >>> add(2, 3) * 5 * >>> add(5, 7) * 12 * */
kotlin
[ "fun add(x: Int, y: Int): Int {", " return x + y", "}", "", "" ]
HumanEval_kotlin/85
/** * You are an expert Kotlin programmer, and here is your task. * * Given an array of non-negative integers, return a copy of the given array after sorting, * you will sort the given array in ascending order if the sum( first index value, last index value) is odd, * or sort it in descending order if the sum( first index value, last index value) is even. * Note: * * don't change the given array. * Examples: * * sort_array([]) => [] * * sort_array([5]) => [5] * * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5] * * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0] * */ fun sortArrayByBinary(array: List<Int>): List<Int> {
sortArrayByBinary
fun main() { var arg00: List<Int> = mutableListOf() var x0: List<Int> = sortArrayByBinary(arg00) var v0: List<Int> = mutableListOf() if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(5) var x1: List<Int> = sortArrayByBinary(arg10) var v1: List<Int> = mutableListOf(5) if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(2, 4, 3, 0, 1, 5) var x2: List<Int> = sortArrayByBinary(arg20) var v2: List<Int> = mutableListOf(0, 1, 2, 3, 4, 5) if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(2, 4, 3, 0, 1, 5, 6) var x3: List<Int> = sortArrayByBinary(arg30) var v3: List<Int> = mutableListOf(6, 5, 4, 3, 2, 1, 0) if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: List<Int> = mutableListOf(2, 1) var x4: List<Int> = sortArrayByBinary(arg40) var v4: List<Int> = mutableListOf(1, 2) if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: List<Int> = mutableListOf(15, 42, 87, 32, 11, 0) var x5: List<Int> = sortArrayByBinary(arg50) var v5: List<Int> = mutableListOf(0, 11, 15, 32, 42, 87) if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: List<Int> = mutableListOf(21, 14, 23, 11) var x6: List<Int> = sortArrayByBinary(arg60) var v6: List<Int> = mutableListOf(23, 21, 14, 11) if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * * Given an array of non-negative integers, return a copy of the given array after sorting, * you will sort the given array in ascending order if the sum( first index value, last index value) is odd, * or sort it in descending order if the sum( first index value, last index value) is even. * Note: * * don't change the given array. * Examples: * * sort_array([]) => [] * * sort_array([5]) => [5] * * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5] * * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0] * */
kotlin
[ "fun sortArrayByBinary(array: List<Int>): List<Int> {", " if (array.size == 0) {", " return emptyList()", " }", " if ((array.first() + array.last()) % 2 == 0) {", " return array.sortedDescending()", " }", " return array.sorted()", "}", "", "" ]
HumanEval_kotlin/91
/** * You are an expert Kotlin programmer, and here is your task. * You are given a list of integers. * You need to find the largest prime value and return the sum of its digits. * Examples: * For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10 * For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25 * For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13 * For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11 * For lst = [0,81,12,3,1,21] the output should be 3 * For lst = [0,8,1,2,1,7] the output should be 7 * */ fun skjkasdkd(lst: List<Int>): Int {
skjkasdkd
fun main() { var arg00: List<Int> = mutableListOf(0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3) var x0: Int = skjkasdkd(arg00) var v0: Int = 10 if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: List<Int> = mutableListOf(1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1) var x1: Int = skjkasdkd(arg10) var v1: Int = 25 if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: List<Int> = mutableListOf(1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3) var x2: Int = skjkasdkd(arg20) var v2: Int = 13 if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: List<Int> = mutableListOf(0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6) var x3: Int = skjkasdkd(arg30) var v3: Int = 11 if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: List<Int> = mutableListOf(0, 81, 12, 3, 1, 21) var x4: Int = skjkasdkd(arg40) var v4: Int = 3 if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: List<Int> = mutableListOf(0, 8, 1, 2, 1, 7) var x5: Int = skjkasdkd(arg50) var v5: Int = 7 if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: List<Int> = mutableListOf(8191) var x6: Int = skjkasdkd(arg60) var v6: Int = 19 if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: List<Int> = mutableListOf(8191, 123456, 127, 7) var x7: Int = skjkasdkd(arg70) var v7: Int = 19 if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80: List<Int> = mutableListOf(127, 97, 8192) var x8: Int = skjkasdkd(arg80) var v8: Int = 10 if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } }
/** * You are an expert Kotlin programmer, and here is your task. * You are given a list of integers. * You need to find the largest prime value and return the sum of its digits. * Examples: * For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10 * For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25 * For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13 * For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11 * For lst = [0,81,12,3,1,21] the output should be 3 * For lst = [0,8,1,2,1,7] the output should be 7 * */
kotlin
[ "fun skjkasdkd(lst: List<Int>): Int {", " fun isPrime(num: Int): Boolean {", " if (num == 1) {", " return false", " }", " for (i in 2..num) {", " if (i * i > num) {", " break", " }", " if (num % i == 0) {", " return false", " }", " }", " return true", " }", "", " var maxPrime = lst.filter { isPrime(it) }.max()", " var digitSum = 0", " while (maxPrime > 0) {", " digitSum += maxPrime % 10", " maxPrime /= 10", " }", " return digitSum", "}", "", "" ]
HumanEval_kotlin/148
/** * You are an expert Kotlin programmer, and here is your task. * * 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([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10 * double_the_difference([-1, -2, 0]) == 0 * double_the_difference([9, -2]) == 81 * double_the_difference([0]) == 0 * If the input list is empty, return 0. * */ fun doubleTheDifference(lst : List<Number>) : Int {
doubleTheDifference
fun main() { var arg00 : List<Number> = mutableListOf() var x0 : Int = doubleTheDifference(arg00); var v0 : Int = 0; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : List<Number> = mutableListOf(5, 4) var x1 : Int = doubleTheDifference(arg10); var v1 : Int = 25; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : List<Number> = mutableListOf(0.1, 0.2, 0.3) var x2 : Int = doubleTheDifference(arg20); var v2 : Int = 0; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : List<Number> = mutableListOf(-10, -20, -30) var x3 : Int = doubleTheDifference(arg30); var v3 : Int = 0; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : List<Number> = mutableListOf(-1, -2, 8) var x4 : Int = doubleTheDifference(arg40); var v4 : Int = 0; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : List<Number> = mutableListOf(0.2, 3, 5) var x5 : Int = doubleTheDifference(arg50); var v5 : Int = 34; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : List<Number> = mutableListOf(-99, -97, -95, -93, -91, -89, -87, -85, -83, -81, -79, -77, -75, -73, -71, -69, -67, -65, -63, -61, -59, -57, -55, -53, -51, -49, -47, -45, -43, -41, -39, -37, -35, -33, -31, -29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99) var x6 : Int = doubleTheDifference(arg60); var v6 : Int = 166650; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } }
/** * You are an expert Kotlin programmer, and here is your task. * * 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([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10 * double_the_difference([-1, -2, 0]) == 0 * double_the_difference([9, -2]) == 81 * double_the_difference([0]) == 0 * If the input list is empty, return 0. * */
kotlin
[ "fun doubleTheDifference(lst : List<Number>) : Int {", "\treturn lst.sumOf { if (it is Int && it > 0 && it % 2 == 1) it * it else 0 }", "}", "", "" ]
HumanEval_kotlin/121
/** * You are an expert Kotlin programmer, and here is your task. * You have to write a function which validates a given date string and * returns True if the date is valid otherwise False. * The date is valid if all of the following rules are satisfied: * 1. The date string is not empty. * 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2. * 3. The months should not be less than 1 or higher than 12. * 4. The date should be in the format: mm-dd-yyyy * for example: * valid_date('03-11-2000') => True * valid_date('15-01-2012') => False * valid_date('04-0-2040') => False * valid_date('06-04-2020') => True * valid_date('06/04/2020') => False * */ fun validDate(date : String) : Boolean {
validDate
fun main() { var arg00 : String = "03-11-2000" var x0 : Boolean = validDate(arg00); var v0 : Boolean = true; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : String = "15-01-2012" var x1 : Boolean = validDate(arg10); var v1 : Boolean = false; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : String = "04-0-2040" var x2 : Boolean = validDate(arg20); var v2 : Boolean = false; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : String = "06-04-2020" var x3 : Boolean = validDate(arg30); var v3 : Boolean = true; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : String = "01-01-2007" var x4 : Boolean = validDate(arg40); var v4 : Boolean = true; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50 : String = "03-32-2011" var x5 : Boolean = validDate(arg50); var v5 : Boolean = false; if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60 : String = "" var x6 : Boolean = validDate(arg60); var v6 : Boolean = false; if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70 : String = "04-31-3000" var x7 : Boolean = validDate(arg70); var v7 : Boolean = false; if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } var arg80 : String = "06-06-2005" var x8 : Boolean = validDate(arg80); var v8 : Boolean = true; if (x8 != v8) { throw Exception("Exception -- test case 8 did not pass. x8 = " + x8) } var arg90 : String = "21-31-2000" var x9 : Boolean = validDate(arg90); var v9 : Boolean = false; if (x9 != v9) { throw Exception("Exception -- test case 9 did not pass. x9 = " + x9) } var arg100 : String = "04-12-2003" var x10 : Boolean = validDate(arg100); var v10 : Boolean = true; if (x10 != v10) { throw Exception("Exception -- test case 10 did not pass. x10 = " + x10) } var arg110 : String = "04122003" var x11 : Boolean = validDate(arg110); var v11 : Boolean = false; if (x11 != v11) { throw Exception("Exception -- test case 11 did not pass. x11 = " + x11) } var arg120 : String = "20030412" var x12 : Boolean = validDate(arg120); var v12 : Boolean = false; if (x12 != v12) { throw Exception("Exception -- test case 12 did not pass. x12 = " + x12) } var arg130 : String = "2003-04" var x13 : Boolean = validDate(arg130); var v13 : Boolean = false; if (x13 != v13) { throw Exception("Exception -- test case 13 did not pass. x13 = " + x13) } var arg140 : String = "2003-04-12" var x14 : Boolean = validDate(arg140); var v14 : Boolean = false; if (x14 != v14) { throw Exception("Exception -- test case 14 did not pass. x14 = " + x14) } var arg150 : String = "04-2003" var x15 : Boolean = validDate(arg150); var v15 : Boolean = false; if (x15 != v15) { throw Exception("Exception -- test case 15 did not pass. x15 = " + x15) } }
/** * You are an expert Kotlin programmer, and here is your task. * You have to write a function which validates a given date string and * returns True if the date is valid otherwise False. * The date is valid if all of the following rules are satisfied: * 1. The date string is not empty. * 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2. * 3. The months should not be less than 1 or higher than 12. * 4. The date should be in the format: mm-dd-yyyy * for example: * valid_date('03-11-2000') => True * valid_date('15-01-2012') => False * valid_date('04-0-2040') => False * valid_date('06-04-2020') => True * valid_date('06/04/2020') => False * */
kotlin
[ "fun validDate(date : String) : Boolean {", " val regex = Regex(\"\"\"\\d{2}-\\d{2}-\\d{4}\"\"\")", " if (!regex.matches(date)) return false", "", " val (month, day, year) = date.split(\"-\").map { it.toInt() }", "", " if (month !in 1..12) return false", "", " val daysInMonth = when (month) {", " 4, 6, 9, 11 -> 30", " 2 -> 29 // Not accounting for leap years", " else -> 31", " }", "", " if (day !in 1..daysInMonth) return false", "", " return true", "}", "", "" ]
HumanEval_kotlin/137
/** * You are an expert Kotlin programmer, and here is your task. * * 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("Example") == "Example" * fix_spaces("Example 1") == "Example_1" * fix_spaces(" Example 2") == "_Example_2" * fix_spaces(" Example 3") == "_Example-3" * */ fun fixSpaces(text : String) : String {
fixSpaces
fun main() { var arg00 : String = "Example" var x0 : String = fixSpaces(arg00); var v0 : String = "Example"; if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10 : String = "Mudasir Hanif " var x1 : String = fixSpaces(arg10); var v1 : String = "Mudasir_Hanif_"; if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20 : String = "Yellow Yellow Dirty Fellow" var x2 : String = fixSpaces(arg20); var v2 : String = "Yellow_Yellow__Dirty__Fellow"; if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30 : String = "Exa mple" var x3 : String = fixSpaces(arg30); var v3 : String = "Exa-mple"; if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40 : String = " Exa 1 2 2 mple" var x4 : String = fixSpaces(arg40); var v4 : String = "-Exa_1_2_2_mple"; if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } }
/** * You are an expert Kotlin programmer, and here is your task. * * 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("Example") == "Example" * fix_spaces("Example 1") == "Example_1" * fix_spaces(" Example 2") == "_Example_2" * fix_spaces(" Example 3") == "_Example-3" * */
kotlin
[ "fun fixSpaces(text : String) : String {", "\treturn text.replace(Regex(\" {3,}\"), \"-\").replace(' ', '_')", "}", "", "" ]
HumanEval_kotlin/77
/** * You are an expert Kotlin programmer, and here is your task. * You are given a string s. * Your task is to check if the string is happy or not. * A string is happy if its length is at least 3 and every 3 consecutive letters are distinct * For example: * is_happy(a) => False * is_happy(aa) => False * is_happy(abcd) => True * is_happy(aabb) => False * is_happy(adb) => True * is_happy(xyy) => False * */ fun isHappy(s: String): Boolean {
isHappy
fun main() { var arg00: String = "a" var x0: Boolean = isHappy(arg00) var v0: Boolean = false if (x0 != v0) { throw Exception("Exception -- test case 0 did not pass. x0 = " + x0) } var arg10: String = "aa" var x1: Boolean = isHappy(arg10) var v1: Boolean = false if (x1 != v1) { throw Exception("Exception -- test case 1 did not pass. x1 = " + x1) } var arg20: String = "abcd" var x2: Boolean = isHappy(arg20) var v2: Boolean = true if (x2 != v2) { throw Exception("Exception -- test case 2 did not pass. x2 = " + x2) } var arg30: String = "aabb" var x3: Boolean = isHappy(arg30) var v3: Boolean = false if (x3 != v3) { throw Exception("Exception -- test case 3 did not pass. x3 = " + x3) } var arg40: String = "adb" var x4: Boolean = isHappy(arg40) var v4: Boolean = true if (x4 != v4) { throw Exception("Exception -- test case 4 did not pass. x4 = " + x4) } var arg50: String = "xyy" var x5: Boolean = isHappy(arg50) var v5: Boolean = false if (x5 != v5) { throw Exception("Exception -- test case 5 did not pass. x5 = " + x5) } var arg60: String = "iopaxpoi" var x6: Boolean = isHappy(arg60) var v6: Boolean = true if (x6 != v6) { throw Exception("Exception -- test case 6 did not pass. x6 = " + x6) } var arg70: String = "iopaxioi" var x7: Boolean = isHappy(arg70) var v7: Boolean = false if (x7 != v7) { throw Exception("Exception -- test case 7 did not pass. x7 = " + x7) } }
/** * You are an expert Kotlin programmer, and here is your task. * You are given a string s. * Your task is to check if the string is happy or not. * A string is happy if its length is at least 3 and every 3 consecutive letters are distinct * For example: * is_happy(a) => False * is_happy(aa) => False * is_happy(abcd) => True * is_happy(aabb) => False * is_happy(adb) => True * is_happy(xyy) => False * */
kotlin
[ "fun isHappy(s: String): Boolean {", " if (s.length < 3) {", " return false", " }", "", " for (i in 0 until s.length - 2) {", " if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {", " return false", " }", " }", " return true", "}", "", "" ]