name stringclasses 161
values | language stringclasses 22
values | prompt stringlengths 40 2.27k | doctests stringclasses 3
values | original stringclasses 956
values | prompt_terminology stringclasses 2
values | tests stringlengths 125 5.35k | stop_tokens listlengths 1 7 |
|---|---|---|---|---|---|---|---|
HumanEval_34_unique | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return sorted unique elements in a list
// >>> unique((List[Long](5l.toLong, 3l.toLong, 5l.toLong, 2l.toLong, 3l.toLong, 3l.toLong, 9l.toLong, 0l.toLong, 123l.toLong)))
// (List[Long](0l.toLong, 2l.toLong, 3l.toLong, 5l.toLong, 9l.toL... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_34_unique.py | reworded | }
def main(args: Array[String]) = {
assert(unique((List[Long](5l.toLong, 3l.toLong, 5l.toLong, 2l.toLong, 3l.toLong, 3l.toLong, 9l.toLong, 0l.toLong, 123l.toLong))).equals((List[Long](0l.toLong, 2l.toLong, 3l.toLong, 5l.toLong, 9l.toLong, 123l.toLong))));
}
}
| [
"\n }\n"
] |
HumanEval_35_max_element | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return maximum element in the list.
// >>> maxElement((List[Long](1l.toLong, 2l.toLong, 3l.toLong)))
// (3l)
// >>> maxElement((List[Long](5l.toLong, 3l.toLong, -5l.toLong, 2l.toLong, -3l.toLong, 3l.toLong, 9l.toLong, 0l.toLong, 1... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_35_max_element.py | reworded | }
def main(args: Array[String]) = {
assert(maxElement((List[Long](1l.toLong, 2l.toLong, 3l.toLong))) == (3l));
assert(maxElement((List[Long](5l.toLong, 3l.toLong, -5l.toLong, 2l.toLong, -3l.toLong, 3l.toLong, 9l.toLong, 0l.toLong, 124l.toLong, 1l.toLong, -10l.toLong))) == (124l));
}
}
| [
"\n }\n"
] |
HumanEval_36_fizz_buzz | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// >>> fizzBuzz((50l))
// (0l)
// >>> fizzBuzz((78l))
// (2l)
// >>> fizzBuzz((79l))
// (3l)
def fizzBuzz(n : ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_36_fizz_buzz.py | reworded | }
def main(args: Array[String]) = {
assert(fizzBuzz((50l)) == (0l));
assert(fizzBuzz((78l)) == (2l));
assert(fizzBuzz((79l)) == (3l));
assert(fizzBuzz((100l)) == (3l));
assert(fizzBuzz((200l)) == (6l));
assert(fizzBuzz((4000l)) == (192l));
assert(fizzBuzz((10000l)) == (639l));
as... | [
"\n }\n"
] |
HumanEval_37_sort_even | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// This function takes a list l and returns a list l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// >>> sortEven((Lis... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_37_sort_even.py | reworded | }
def main(args: Array[String]) = {
assert(sortEven((List[Long](1l.toLong, 2l.toLong, 3l.toLong))).equals((List[Long](1l.toLong, 2l.toLong, 3l.toLong))));
assert(sortEven((List[Long](5l.toLong, 3l.toLong, -5l.toLong, 2l.toLong, -3l.toLong, 3l.toLong, 9l.toLong, 0l.toLong, 123l.toLong, 1l.toLong, -10l.to... | [
"\n }\n"
] |
HumanEval_39_prime_fib | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// >>> primeFib((1l))
// (2l)
// >>> primeFib((2l))
// (3l)
// >>> primeFib((3l))
// (5l)
// >>> primeFib((4l))
// (13l)
// >>> ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_39_prime_fib.py | reworded | }
def main(args: Array[String]) = {
assert(primeFib((1l)) == (2l));
assert(primeFib((2l)) == (3l));
assert(primeFib((3l)) == (5l));
assert(primeFib((4l)) == (13l));
assert(primeFib((5l)) == (89l));
assert(primeFib((6l)) == (233l));
assert(primeFib((7l)) == (1597l));
assert(primeF... | [
"\n }\n"
] |
HumanEval_3_below_zero | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You're given a list of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_3_below_zero.py | reworded | }
def main(args: Array[String]) = {
assert(belowZero((List[Long]())) == (false));
assert(belowZero((List[Long](1l.toLong, 2l.toLong, -3l.toLong, 1l.toLong, 2l.toLong, -3l.toLong))) == (false));
assert(belowZero((List[Long](1l.toLong, 2l.toLong, -4l.toLong, 5l.toLong, 6l.toLong))) == (true));
ass... | [
"\n }\n"
] |
HumanEval_40_triples_sum_to_zero | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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.
// >>> triplesSumToZero((List[Long](1l.toLong, 3l.toLong, 5l.t... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_40_triples_sum_to_zero.py | reworded | }
def main(args: Array[String]) = {
assert(triplesSumToZero((List[Long](1l.toLong, 3l.toLong, 5l.toLong, 0l.toLong))) == (false));
assert(triplesSumToZero((List[Long](1l.toLong, 3l.toLong, 5l.toLong, -1l.toLong))) == (false));
assert(triplesSumToZero((List[Long](1l.toLong, 3l.toLong, -2l.toLong, 1l.... | [
"\n }\n"
] |
HumanEval_41_car_race_collision | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right; simultaneously, a different set of n cars
// are driving right to left. The two sets of cars start out being very far from
//... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_41_car_race_collision.py | reworded | }
def main(args: Array[String]) = {
assert(carRaceCollision((2l)) == (4l));
assert(carRaceCollision((3l)) == (9l));
assert(carRaceCollision((4l)) == (16l));
assert(carRaceCollision((8l)) == (64l));
assert(carRaceCollision((10l)) == (100l));
}
}
| [
"\n }\n"
] |
HumanEval_42_incr_list | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return list with elements incremented by 1.
// >>> incrList((List[Long](1l.toLong, 2l.toLong, 3l.toLong)))
// (List[Long](2l.toLong, 3l.toLong, 4l.toLong))
// >>> incrList((List[Long](5l.toLong, 3l.toLong, 5l.toLong, 2l.toLong, 3l... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_42_incr_list.py | reworded | }
def main(args: Array[String]) = {
assert(incrList((List[Long]())).equals((List[Long]())));
assert(incrList((List[Long](3l.toLong, 2l.toLong, 1l.toLong))).equals((List[Long](4l.toLong, 3l.toLong, 2l.toLong))));
assert(incrList((List[Long](5l.toLong, 2l.toLong, 5l.toLong, 2l.toLong, 3l.toLong, 3l.to... | [
"\n }\n"
] |
HumanEval_43_pairs_sum_to_zero | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// pairs_sum_to_zero takes a list of integers as an input.
// it returns true if there are two distinct elements in the list that
// sum to zero, and false otherwise.
// >>> pairsSumToZero((List[Long](1l.toLong, 3l.toLong, 5l.toLong,... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_43_pairs_sum_to_zero.py | reworded | }
def main(args: Array[String]) = {
assert(pairsSumToZero((List[Long](1l.toLong, 3l.toLong, 5l.toLong, 0l.toLong))) == (false));
assert(pairsSumToZero((List[Long](1l.toLong, 3l.toLong, -2l.toLong, 1l.toLong))) == (false));
assert(pairsSumToZero((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 7l.toLong)... | [
"\n }\n"
] |
HumanEval_44_change_base | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// >>> changeBase((8l), (3l))
// ("22")
// >>> changeBase((8l), (2l))
// ("1000")... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_44_change_base.py | reworded | }
def main(args: Array[String]) = {
assert(changeBase((8l), (3l)).equals(("22")));
assert(changeBase((9l), (3l)).equals(("100")));
assert(changeBase((234l), (2l)).equals(("11101010")));
assert(changeBase((16l), (2l)).equals(("10000")));
assert(changeBase((8l), (2l)).equals(("1000")));
as... | [
"\n }\n"
] |
HumanEval_45_triangle_area | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given length of a side and high return area for a triangle.
// >>> triangleArea((5l), (3l))
// (7.5f)
def triangleArea(a : Long, h : Long) : Float = {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_45_triangle_area.py | reworded | }
def main(args: Array[String]) = {
assert(triangleArea((5l), (3l)) == (7.5f));
assert(triangleArea((2l), (2l)) == (2.0f));
assert(triangleArea((10l), (8l)) == (40.0f));
}
}
| [
"\n }\n"
] |
HumanEval_46_fib4 | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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-... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_46_fib4.py | reworded | }
def main(args: Array[String]) = {
assert(fib4((5l)) == (4l));
assert(fib4((8l)) == (28l));
assert(fib4((10l)) == (104l));
assert(fib4((12l)) == (386l));
}
}
| [
"\n }\n"
] |
HumanEval_47_median | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return median of elements in the list l.
// >>> median((List[Long](3l.toLong, 1l.toLong, 2l.toLong, 4l.toLong, 5l.toLong)))
// 3l
// >>> median((List[Long](-10l.toLong, 4l.toLong, 6l.toLong, 1000l.toLong, 10l.toLong, 20l.toLong)))... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_47_median.py | reworded | }
def main(args: Array[String]) = {
assert(median((List[Long](3l.toLong, 1l.toLong, 2l.toLong, 4l.toLong, 5l.toLong))) == 3l);
assert(median((List[Long](-10l.toLong, 4l.toLong, 6l.toLong, 1000l.toLong, 10l.toLong, 20l.toLong))) == (8.0f));
assert(median((List[Long](5l.toLong))) == 5l);
assert(me... | [
"\n }\n"
] |
HumanEval_48_is_palindrome | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Checks if given string is a palindrome
// >>> isPalindrome((""))
// (true)
// >>> isPalindrome(("aba"))
// (true)
// >>> isPalindrome(("aaaaa"))
// (true)
// >>> isPalindrome(("zbcd"))
// (false)
def isPali... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_48_is_palindrome.py | reworded | }
def main(args: Array[String]) = {
assert(isPalindrome(("")) == (true));
assert(isPalindrome(("aba")) == (true));
assert(isPalindrome(("aaaaa")) == (true));
assert(isPalindrome(("zbcd")) == (false));
assert(isPalindrome(("xywyx")) == (true));
assert(isPalindrome(("xywyz")) == (false));
... | [
"\n }\n"
] |
HumanEval_49_modp | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return 2^n modulo p (be aware of numerics).
// >>> modp((3l), (5l))
// (3l)
// >>> modp((1101l), (101l))
// (2l)
// >>> modp((0l), (101l))
// (1l)
// >>> modp((3l), (11l))
// (8l)
// >>> modp((100l), (101l)... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_49_modp.py | reworded | }
def main(args: Array[String]) = {
assert(modp((3l), (5l)) == (3l));
assert(modp((1101l), (101l)) == (2l));
assert(modp((0l), (101l)) == (1l));
assert(modp((3l), (11l)) == (8l));
assert(modp((100l), (101l)) == (1l));
assert(modp((30l), (5l)) == (4l));
assert(modp((31l), (5l)) == (3l... | [
"\n }\n"
] |
HumanEval_4_mean_absolute_deviation | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// For a given list of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_4_mean_absolute_deviation.py | reworded | }
def main(args: Array[String]) = {
assert(meanAbsoluteDeviation((List[Float](1.0f.toFloat, 2.0f.toFloat))) == (0.5f));
assert(meanAbsoluteDeviation((List[Float](1.0f.toFloat, 2.0f.toFloat, 3.0f.toFloat, 4.0f.toFloat))) == (1.0f));
assert(meanAbsoluteDeviation((List[Float](1.0f.toFloat, 2.0f.toFloat... | [
"\n }\n"
] |
HumanEval_51_remove_vowels | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// remove_vowels is a function that takes string and returns string without vowels.
// >>> removeVowels((""))
// ("")
// >>> removeVowels(("abcdef"))
// ("bcdf")
// >>> removeVowels(("aaaaa"))
// ("")
// >>> removeVow... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_51_remove_vowels.py | reworded | }
def main(args: Array[String]) = {
assert(removeVowels(("")).equals(("")));
assert(removeVowels(("abcdef\nghijklm")).equals(("bcdf\nghjklm")));
assert(removeVowels(("fedcba")).equals(("fdcb")));
assert(removeVowels(("eeeee")).equals(("")));
assert(removeVowels(("acBAA")).equals(("cB")));
... | [
"\n }\n"
] |
HumanEval_52_below_threshold | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return true if all numbers in the list l are below threshold t.
// >>> belowThreshold((List[Long](1l.toLong, 2l.toLong, 4l.toLong, 10l.toLong)), (100l))
// (true)
// >>> belowThreshold((List[Long](1l.toLong, 20l.toLong, 4l.toLong,... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_52_below_threshold.py | reworded | }
def main(args: Array[String]) = {
assert(belowThreshold((List[Long](1l.toLong, 2l.toLong, 4l.toLong, 10l.toLong)), (100l)) == (true));
assert(belowThreshold((List[Long](1l.toLong, 20l.toLong, 4l.toLong, 10l.toLong)), (5l)) == (false));
assert(belowThreshold((List[Long](1l.toLong, 20l.toLong, 4l.to... | [
"\n }\n"
] |
HumanEval_53_add | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Add two numbers x and y
// >>> add((2l), (3l))
// (5l)
// >>> add((5l), (7l))
// (12l)
def add(x : Long, y : Long) : Long = {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_53_add.py | reworded | }
def main(args: Array[String]) = {
assert(add((0l), (1l)) == (1l));
assert(add((1l), (0l)) == (1l));
assert(add((2l), (3l)) == (5l));
assert(add((5l), (7l)) == (12l));
assert(add((7l), (5l)) == (12l));
}
}
| [
"\n }\n"
] |
HumanEval_54_same_chars | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Check if two words have the same characters.
// >>> sameChars(("eabcdzzzz"), ("dddzzzzzzzddeddabc"))
// (true)
// >>> sameChars(("abcd"), ("dddddddabc"))
// (true)
// >>> sameChars(("dddddddabc"), ("abcd"))
// (true)
... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_54_same_chars.py | reworded | }
def main(args: Array[String]) = {
assert(sameChars(("eabcdzzzz"), ("dddzzzzzzzddeddabc")) == (true));
assert(sameChars(("abcd"), ("dddddddabc")) == (true));
assert(sameChars(("dddddddabc"), ("abcd")) == (true));
assert(sameChars(("eabcd"), ("dddddddabc")) == (false));
assert(sameChars(("ab... | [
"\n }\n"
] |
HumanEval_55_fib | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return n-th Fibonacci number.
// >>> fib((10l))
// (55l)
// >>> fib((1l))
// (1l)
// >>> fib((8l))
// (21l)
def fib(n : Long) : Long = {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_55_fib.py | reworded | }
def main(args: Array[String]) = {
assert(fib((10l)) == (55l));
assert(fib((1l)) == (1l));
assert(fib((8l)) == (21l));
assert(fib((11l)) == (89l));
assert(fib((12l)) == (144l));
}
}
| [
"\n }\n"
] |
HumanEval_56_correct_bracketing | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// >>> correctBracketing(("<"))
// (false)
// >>> correctBracketing(("<>"))
// (true)
// >>> correctBrac... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_56_correct_bracketing.py | reworded | }
def main(args: Array[String]) = {
assert(correctBracketing(("<>")) == (true));
assert(correctBracketing(("<<><>>")) == (true));
assert(correctBracketing(("<><><<><>><>")) == (true));
assert(correctBracketing(("<><><<<><><>><>><<><><<>>>")) == (true));
assert(correctBracketing(("<<<><>>>>")... | [
"\n }\n"
] |
HumanEval_57_monotonic | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return true is list elements are monotonically increasing or decreasing.
// >>> monotonic((List[Long](1l.toLong, 2l.toLong, 4l.toLong, 20l.toLong)))
// (true)
// >>> monotonic((List[Long](1l.toLong, 20l.toLong, 4l.toLong, 10l.toLo... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_57_monotonic.py | reworded | }
def main(args: Array[String]) = {
assert(monotonic((List[Long](1l.toLong, 2l.toLong, 4l.toLong, 10l.toLong))) == (true));
assert(monotonic((List[Long](1l.toLong, 2l.toLong, 4l.toLong, 20l.toLong))) == (true));
assert(monotonic((List[Long](1l.toLong, 20l.toLong, 4l.toLong, 10l.toLong))) == (false))... | [
"\n }\n"
] |
HumanEval_58_common | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return sorted unique common elements for two lists.
// >>> common((List[Long](1l.toLong, 4l.toLong, 3l.toLong, 34l.toLong, 653l.toLong, 2l.toLong, 5l.toLong)), (List[Long](5l.toLong, 7l.toLong, 1l.toLong, 5l.toLong, 9l.toLong, 653l.toLong... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_58_common.py | reworded | }
def main(args: Array[String]) = {
assert(common((List[Long](1l.toLong, 4l.toLong, 3l.toLong, 34l.toLong, 653l.toLong, 2l.toLong, 5l.toLong)), (List[Long](5l.toLong, 7l.toLong, 1l.toLong, 5l.toLong, 9l.toLong, 653l.toLong, 121l.toLong))).equals((List[Long](1l.toLong, 5l.toLong, 653l.toLong))));
assert(... | [
"\n }\n"
] |
HumanEval_59_largest_prime_factor | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// >>> largestPrimeFactor((13195l))
// (29l)
// >>> largestPrimeFactor((2048l))
// (2l)
def largestPrimeFactor(n : Long) : Long = {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_59_largest_prime_factor.py | reworded | }
def main(args: Array[String]) = {
assert(largestPrimeFactor((15l)) == (5l));
assert(largestPrimeFactor((27l)) == (3l));
assert(largestPrimeFactor((63l)) == (7l));
assert(largestPrimeFactor((330l)) == (11l));
assert(largestPrimeFactor((13195l)) == (29l));
}
}
| [
"\n }\n"
] |
HumanEval_5_intersperse | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
// >>> intersperse((List[Long]()), (4l))
// (List[Long]())
// >>> intersperse((List[Long](1l.toLong, 2l.toLong, 3l.toLong)), (4l))
// (... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_5_intersperse.py | reworded | }
def main(args: Array[String]) = {
assert(intersperse((List[Long]()), (7l)).equals((List[Long]())));
assert(intersperse((List[Long](5l.toLong, 6l.toLong, 3l.toLong, 2l.toLong)), (8l)).equals((List[Long](5l.toLong, 8l.toLong, 6l.toLong, 8l.toLong, 3l.toLong, 8l.toLong, 2l.toLong))));
assert(interspe... | [
"\n }\n"
] |
HumanEval_60_sum_to_n | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// sum_to_n is a function that sums numbers from 1 to n.
// >>> sumToN((30l))
// (465l)
// >>> sumToN((100l))
// (5050l)
// >>> sumToN((5l))
// (15l)
// >>> sumToN((10l))
// (55l)
// >>> sumToN((1l))
// (1... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_60_sum_to_n.py | reworded | }
def main(args: Array[String]) = {
assert(sumToN((1l)) == (1l));
assert(sumToN((6l)) == (21l));
assert(sumToN((11l)) == (66l));
assert(sumToN((30l)) == (465l));
assert(sumToN((100l)) == (5050l));
}
}
| [
"\n }\n"
] |
HumanEval_61_correct_bracketing | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// >>> correctBracketing(("("))
// (false)
// >>> correctBracketing(("()"))
// (true)
// >>> correctBrac... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_61_correct_bracketing.py | reworded | }
def main(args: Array[String]) = {
assert(correctBracketing(("()")) == (true));
assert(correctBracketing(("(()())")) == (true));
assert(correctBracketing(("()()(()())()")) == (true));
assert(correctBracketing(("()()((()()())())(()()(()))")) == (true));
assert(correctBracketing(("((()())))")... | [
"\n }\n"
] |
HumanEval_62_derivative | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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((List[Long](3l.toLong, 1l.toLong, 2l.toLong, 4l.toLong, 5l.toLong)))
... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_62_derivative.py | reworded | }
def main(args: Array[String]) = {
assert(derivative((List[Long](3l.toLong, 1l.toLong, 2l.toLong, 4l.toLong, 5l.toLong))).equals((List[Long](1l.toLong, 4l.toLong, 12l.toLong, 20l.toLong))));
assert(derivative((List[Long](1l.toLong, 2l.toLong, 3l.toLong))).equals((List[Long](2l.toLong, 6l.toLong))));
... | [
"\n }\n"
] |
HumanEval_63_fibfib | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Pleas... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_63_fibfib.py | reworded | }
def main(args: Array[String]) = {
assert(fibfib((2l)) == (1l));
assert(fibfib((1l)) == (0l));
assert(fibfib((5l)) == (4l));
assert(fibfib((8l)) == (24l));
assert(fibfib((10l)) == (81l));
assert(fibfib((12l)) == (274l));
assert(fibfib((14l)) == (927l));
}
}
| [
"\n }\n"
] |
HumanEval_64_vowels_count | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_64_vowels_count.py | reworded | }
def main(args: Array[String]) = {
assert(vowelsCount(("abcde")) == (2l));
assert(vowelsCount(("Alone")) == (3l));
assert(vowelsCount(("key")) == (2l));
assert(vowelsCount(("bye")) == (1l));
assert(vowelsCount(("keY")) == (2l));
assert(vowelsCount(("bYe")) == (1l));
assert(vowelsCou... | [
"\n }\n"
] |
HumanEval_65_circular_shift | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// >>> circularShift((12l), (1l))
// ("21")
// >>> c... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_65_circular_shift.py | reworded | }
def main(args: Array[String]) = {
assert(circularShift((100l), (2l)).equals(("001")));
assert(circularShift((12l), (2l)).equals(("12")));
assert(circularShift((97l), (8l)).equals(("79")));
assert(circularShift((12l), (1l)).equals(("21")));
assert(circularShift((11l), (101l)).equals(("11"))... | [
"\n }\n"
] |
HumanEval_66_digitSum | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// >>> digitSum((""))
// (0l)
// >>> digitSum(("abAB"))
// (131l)
// >>> digi... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_66_digitSum.py | reworded | }
def main(args: Array[String]) = {
assert(digitSum(("")) == (0l));
assert(digitSum(("abAB")) == (131l));
assert(digitSum(("abcCd")) == (67l));
assert(digitSum(("helloE")) == (69l));
assert(digitSum(("woArBld")) == (131l));
assert(digitSum(("aAaaaXa")) == (153l));
assert(digitSum((" ... | [
"\n }\n"
] |
HumanEval_67_fruit_distribution | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 tot... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_67_fruit_distribution.py | reworded | }
def main(args: Array[String]) = {
assert(fruitDistribution(("5 apples and 6 oranges"), (19l)) == (8l));
assert(fruitDistribution(("5 apples and 6 oranges"), (21l)) == (10l));
assert(fruitDistribution(("0 apples and 1 oranges"), (3l)) == (2l));
assert(fruitDistribution(("1 apples and 0 oranges"... | [
"\n }\n"
] |
HumanEval_68_pluck | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// "Given a list representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes w... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_68_pluck.py | reworded | }
def main(args: Array[String]) = {
assert(pluck((List[Long](4l.toLong, 2l.toLong, 3l.toLong))).equals((List[Long](2l.toLong, 1l.toLong))));
assert(pluck((List[Long](1l.toLong, 2l.toLong, 3l.toLong))).equals((List[Long](2l.toLong, 1l.toLong))));
assert(pluck((List[Long]())).equals((List[Long]())));
... | [
"\n }\n"
] |
HumanEval_69_search | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a non-empty list of positive integers. Return the greatest integer that is greater than
// zero, and has a frequency greater than or equal to the value of the integer itself.
// The frequency of an integer is the numbe... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_69_search.py | reworded | }
def main(args: Array[String]) = {
assert(search((List[Long](5l.toLong, 5l.toLong, 5l.toLong, 5l.toLong, 1l.toLong))) == (1l));
assert(search((List[Long](4l.toLong, 1l.toLong, 4l.toLong, 1l.toLong, 4l.toLong, 4l.toLong))) == (4l));
assert(search((List[Long](3l.toLong, 3l.toLong))) == (-1l));
as... | [
"\n }\n"
] |
HumanEval_6_parse_nested_parens | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_6_parse_nested_parens.py | reworded | }
def main(args: Array[String]) = {
assert(parseNestedParens(("(()()) ((())) () ((())()())")).equals((List[Long](2l.toLong, 3l.toLong, 1l.toLong, 3l.toLong))));
assert(parseNestedParens(("() (()) ((())) (((())))")).equals((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong))));
assert(parseNested... | [
"\n }\n"
] |
HumanEval_70_strange_sort_list | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given list of integers, return list in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// >>> strangeSortList((List[L... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_70_strange_sort_list.py | reworded | }
def main(args: Array[String]) = {
assert(strangeSortList((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong))).equals((List[Long](1l.toLong, 4l.toLong, 2l.toLong, 3l.toLong))));
assert(strangeSortList((List[Long](5l.toLong, 6l.toLong, 7l.toLong, 8l.toLong, 9l.toLong))).equals((List[Long](5l.toLong... | [
"\n }\n"
] |
HumanEval_71_triangle_area | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle.
// Otherwise return -1
// Three sides make a valid triangle when the sum... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_71_triangle_area.py | reworded | }
def main(args: Array[String]) = {
assert(triangleArea((3l), (4l), (5l)) == (6.0f));
assert(triangleArea((1l), (2l), (10l)) == -1l);
assert(triangleArea((4l), (8l), (5l)) == (8.18f));
assert(triangleArea((2l), (2l), (2l)) == (1.73f));
assert(triangleArea((1l), (2l), (3l)) == -1l);
asser... | [
"\n }\n"
] |
HumanEval_72_will_it_fly | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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.
//... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_72_will_it_fly.py | reworded | }
def main(args: Array[String]) = {
assert(willItFly((List[Long](3l.toLong, 2l.toLong, 3l.toLong)), (9l)) == (true));
assert(willItFly((List[Long](1l.toLong, 2l.toLong)), (5l)) == (false));
assert(willItFly((List[Long](3l.toLong)), (5l)) == (true));
assert(willItFly((List[Long](3l.toLong, 2l.toL... | [
"\n }\n"
] |
HumanEval_73_smallest_change | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a list arr of integers, find the minimum number of elements that
// need to be changed to make the list palindromic. A palindromic list is a list that
// is read the same backwards and forwards. In one change, you can change one... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_73_smallest_change.py | reworded | }
def main(args: Array[String]) = {
assert(smallestChange((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 5l.toLong, 4l.toLong, 7l.toLong, 9l.toLong, 6l.toLong))) == (4l));
assert(smallestChange((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 3l.toLong, 2l.toLong, 2l.toLong))) == (1l));
assert(... | [
"\n }\n"
] |
HumanEval_74_total_match | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Write a function that accepts two lists of strings and returns the list that has
// total number of chars in the all strings of the list less than the other list.
// if the two lists have the same number of chars, return the first li... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_74_total_match.py | reworded | }
def main(args: Array[String]) = {
assert(totalMatch((List[String]()), (List[String]())).equals((List[String]())));
assert(totalMatch((List[String]("hi", "admin")), (List[String]("hi", "hi"))).equals((List[String]("hi", "hi"))));
assert(totalMatch((List[String]("hi", "admin")), (List[String]("hi", ... | [
"\n }\n"
] |
HumanEval_75_is_multiply_prime | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100.
// Example:
// >>> isMultiplyPrime((30l))
// (true)
// 30 =... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_75_is_multiply_prime.py | reworded | }
def main(args: Array[String]) = {
assert(isMultiplyPrime((5l)) == (false));
assert(isMultiplyPrime((30l)) == (true));
assert(isMultiplyPrime((8l)) == (true));
assert(isMultiplyPrime((10l)) == (false));
assert(isMultiplyPrime((125l)) == (true));
assert(isMultiplyPrime((105l)) == (true))... | [
"\n }\n"
] |
HumanEval_76_is_simple_power | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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:
// >>> isSimplePower((1l), (4l))
// (true)
//... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_76_is_simple_power.py | reworded | }
def main(args: Array[String]) = {
assert(isSimplePower((16l), (2l)) == (true));
assert(isSimplePower((143214l), (16l)) == (false));
assert(isSimplePower((4l), (2l)) == (true));
assert(isSimplePower((9l), (3l)) == (true));
assert(isSimplePower((16l), (4l)) == (true));
assert(isSimplePow... | [
"\n }\n"
] |
HumanEval_77_iscube | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Write a function that takes an integer a and returns true
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// >>> iscube((1l))
// (true)
// >>> iscub... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_77_iscube.py | reworded | }
def main(args: Array[String]) = {
assert(iscube((1l)) == (true));
assert(iscube((2l)) == (false));
assert(iscube((-1l)) == (true));
assert(iscube((64l)) == (true));
assert(iscube((180l)) == (false));
assert(iscube((1000l)) == (true));
assert(iscube((0l)) == (true));
assert(iscu... | [
"\n }\n"
] |
HumanEval_78_hex_key | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You have been tasked to write a function that receives
// a hexadecimal number as a string and counts the number of hexadecimal
// digits that are primes (prime number, or a prime, is a natural number
// greater than 1 that is ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_78_hex_key.py | reworded | }
def main(args: Array[String]) = {
assert(hexKey(("AB")) == (1l));
assert(hexKey(("1077E")) == (2l));
assert(hexKey(("ABED1A33")) == (4l));
assert(hexKey(("2020")) == (2l));
assert(hexKey(("123456789ABCDEF0")) == (6l));
assert(hexKey(("112233445566778899AABBCCDDEEFF00")) == (12l));
... | [
"\n }\n"
] |
HumanEval_79_decimal_to_binary | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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'.
... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_79_decimal_to_binary.py | reworded | }
def main(args: Array[String]) = {
assert(decimalToBinary((0l)).equals(("db0db")));
assert(decimalToBinary((32l)).equals(("db100000db")));
assert(decimalToBinary((103l)).equals(("db1100111db")));
assert(decimalToBinary((15l)).equals(("db1111db")));
}
}
| [
"\n }\n"
] |
HumanEval_7_filter_by_substring | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Filter an input list of strings only for ones that contain given substring
// >>> filterBySubstring((List[String]()), ("a"))
// (List[String]())
// >>> filterBySubstring((List[String]("abc", "bacd", "cde", "array")), ("a"))
//... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_7_filter_by_substring.py | reworded | }
def main(args: Array[String]) = {
assert(filterBySubstring((List[String]()), ("john")).equals((List[String]())));
assert(filterBySubstring((List[String]("xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx")), ("xxx")).equals((List[String]("xxx", "xxxAAA", "xxx"))));
assert(filterBySubstring((List[Stri... | [
"\n }\n"
] |
HumanEval_80_is_happy | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a string s.
// Your task is to check if the string is hapscala or not.
// A string is hapscala if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// >>> isHappy(("a"))
//... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_80_is_happy.py | reworded | }
def main(args: Array[String]) = {
assert(isHappy(("a")) == (false));
assert(isHappy(("aa")) == (false));
assert(isHappy(("abcd")) == (true));
assert(isHappy(("aabb")) == (false));
assert(isHappy(("adb")) == (true));
assert(isHappy(("xyy")) == (false));
assert(isHappy(("iopaxpoi")) ... | [
"\n }\n"
] |
HumanEval_81_numerical_letter_grade | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has g... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_81_numerical_letter_grade.py | reworded | }
def main(args: Array[String]) = {
assert(numericalLetterGrade((List[Float](4.0f.toFloat, 3l.toFloat, 1.7f.toFloat, 2l.toFloat, 3.5f.toFloat))).equals((List[String]("A+", "B", "C-", "C", "A-"))));
assert(numericalLetterGrade((List[Float](1.2f.toFloat))).equals((List[String]("D+"))));
assert(numeric... | [
"\n }\n"
] |
HumanEval_82_prime_length | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// >>> primeLength(("Hello"))
// (true)
// >>> primeLength(("abcdcba"))
// (true)
// >>... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_82_prime_length.py | reworded | }
def main(args: Array[String]) = {
assert(primeLength(("Hello")) == (true));
assert(primeLength(("abcdcba")) == (true));
assert(primeLength(("kittens")) == (true));
assert(primeLength(("orange")) == (false));
assert(primeLength(("wow")) == (true));
assert(primeLength(("world")) == (true... | [
"\n }\n"
] |
HumanEval_83_starts_one_ends | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that start or end with 1.
def startsOneEnds(n : Long) : Long = {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_83_starts_one_ends.py | reworded | }
def main(args: Array[String]) = {
assert(startsOneEnds((1l)) == (1l));
assert(startsOneEnds((2l)) == (18l));
assert(startsOneEnds((3l)) == (180l));
assert(startsOneEnds((4l)) == (1800l));
assert(startsOneEnds((5l)) == (18000l));
}
}
| [
"\n }\n"
] |
HumanEval_84_solve | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a positive integer N, return the total sum of its digits in binary.
// Example
// >>> solve((1000l))
// ("1")
// >>> solve((150l))
// ("110")
// >>> solve((147l))
// ("1100")
// Variables:
// @N integ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_84_solve.py | reworded | }
def main(args: Array[String]) = {
assert(solve((1000l)).equals(("1")));
assert(solve((150l)).equals(("110")));
assert(solve((147l)).equals(("1100")));
assert(solve((333l)).equals(("1001")));
assert(solve((963l)).equals(("10010")));
}
}
| [
"\n }\n"
] |
HumanEval_85_add | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a non-empty list of integers lst. add the even elements that are at odd indices..
// Examples:
// >>> add((List[Long](4l.toLong, 2l.toLong, 6l.toLong, 7l.toLong)))
// (2l)
def add(lst : List[Long]) : Long = {
| transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_85_add.py | reworded | }
def main(args: Array[String]) = {
assert(add((List[Long](4l.toLong, 88l.toLong))) == (88l));
assert(add((List[Long](4l.toLong, 5l.toLong, 6l.toLong, 7l.toLong, 2l.toLong, 122l.toLong))) == (122l));
assert(add((List[Long](4l.toLong, 0l.toLong, 6l.toLong, 7l.toLong))) == (0l));
assert(add((List[... | [
"\n }\n"
] |
HumanEval_86_anti_shuffle | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Write a function that takes a string and returns an ordered version of it.
// Ordered version of string, is a string where all words (separated by space)
// are replaced by a new word where all the characters arranged in
// ascend... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_86_anti_shuffle.py | reworded | }
def main(args: Array[String]) = {
assert(antiShuffle(("Hi")).equals(("Hi")));
assert(antiShuffle(("hello")).equals(("ehllo")));
assert(antiShuffle(("number")).equals(("bemnru")));
assert(antiShuffle(("abcd")).equals(("abcd")));
assert(antiShuffle(("Hello World!!!")).equals(("Hello !!!Wdlor... | [
"\n }\n"
] |
HumanEval_87_get_row | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a 2 dimensional data, as a nested lists,
// which is similar to matrix, however, unlike matrices,
// each row may contain a different number of columns.
// Given lst, and integer x, find integers x in the list,
/... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_87_get_row.py | reworded | }
def main(args: Array[String]) = {
assert(getRow((List[List[Long]](List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 5l.toLong, 6l.toLong), List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 1l.toLong, 6l.toLong), List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 5l.toLong, 1l.toLong))), (1l)... | [
"\n }\n"
] |
HumanEval_88_sort_array | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a list of non-negative integers, return a coscala of the given list after sorting,
// you will sort the given list in ascending order if the sum( first index value, last index value) is odd,
// or sort it in descending order if ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_88_sort_array.py | reworded | }
def main(args: Array[String]) = {
assert(sortArray((List[Long]())).equals((List[Long]())));
assert(sortArray((List[Long](5l.toLong))).equals((List[Long](5l.toLong))));
assert(sortArray((List[Long](2l.toLong, 4l.toLong, 3l.toLong, 0l.toLong, 1l.toLong, 5l.toLong))).equals((List[Long](0l.toLong, 1l.... | [
"\n }\n"
] |
HumanEval_89_encrypt | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_89_encrypt.py | reworded | }
def main(args: Array[String]) = {
assert(encrypt(("hi")).equals(("lm")));
assert(encrypt(("asdfghjkl")).equals(("ewhjklnop")));
assert(encrypt(("gf")).equals(("kj")));
assert(encrypt(("et")).equals(("ix")));
assert(encrypt(("faewfawefaewg")).equals(("jeiajeaijeiak")));
assert(encrypt((... | [
"\n }\n"
] |
HumanEval_8_sum_product | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// >>> sumProduct((List[Long]()))
// ((0l, 1l)... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_8_sum_product.py | reworded | }
def main(args: Array[String]) = {
assert(sumProduct((List[Long]())).equals(((0l, 1l))));
assert(sumProduct((List[Long](1l.toLong, 1l.toLong, 1l.toLong))).equals(((3l, 1l))));
assert(sumProduct((List[Long](100l.toLong, 0l.toLong))).equals(((100l, 0l))));
assert(sumProduct((List[Long](3l.toLong,... | [
"\n }\n"
] |
HumanEval_90_next_smallest | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a list of integers.
// Write a function next_smallest() that returns the 2nd smallest element of the list.
// Return None if there is no such element.
// >>> nextSmallest((List[Long](1l.toLong, 2l.toLong, 3l.toLong, ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_90_next_smallest.py | reworded | }
def main(args: Array[String]) = {
assert(nextSmallest((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 5l.toLong))).equals(Some(2l)));
assert(nextSmallest((List[Long](5l.toLong, 1l.toLong, 4l.toLong, 3l.toLong, 2l.toLong))).equals(Some(2l)));
assert(nextSmallest((List[Long]())).equals(None)... | [
"\n }\n"
] |
HumanEval_91_is_bored | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You'll be given a string of words, and your task is to count the number
// of boredoms. A boredom is a sentence that starts with the word "I".
// Sentences are delimited by '.', '?' or '!'.
// For example:
// >>> isBored(("Hel... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_91_is_bored.py | reworded | }
def main(args: Array[String]) = {
assert(isBored(("Hello world")) == (0l));
assert(isBored(("Is the sky blue?")) == (0l));
assert(isBored(("I love It !")) == (1l));
assert(isBored(("bIt")) == (0l));
assert(isBored(("I feel good today. I will be productive. will kill It")) == (2l));
ass... | [
"\n }\n"
] |
HumanEval_92_any_int | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Create a function that takes 3 numbers.
// Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
// Returns false in any other cases.
// Examples
// >>> anyInt(5l, 2l, 7l)
/... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_92_any_int.py | reworded | }
def main(args: Array[String]) = {
assert(anyInt(2l, 3l, 1l) == (true));
assert(anyInt((2.5f), 2l, 3l) == (false));
assert(anyInt((1.5f), 5l, (3.5f)) == (false));
assert(anyInt(2l, 6l, 2l) == (false));
assert(anyInt(4l, 2l, 2l) == (true));
assert(anyInt((2.2f), (2.2f), (2.2f)) == (false... | [
"\n }\n"
] |
HumanEval_93_encode | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Write a function that takes a message, and encodes in such a
// way that it swaps case of all letters, replaces all vowels in
// the message with the letter that appears 2 places ahead of that
// vowel in the english alphabet. ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_93_encode.py | reworded | }
def main(args: Array[String]) = {
assert(encode(("TEST")).equals(("tgst")));
assert(encode(("Mudasir")).equals(("mWDCSKR")));
assert(encode(("YES")).equals(("ygs")));
assert(encode(("This is a message")).equals(("tHKS KS C MGSSCGG")));
assert(encode(("I DoNt KnOw WhAt tO WrItE")).equals(("... | [
"\n }\n"
] |
HumanEval_94_skjkasdkd | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a list of integers.
// You need to find the largest prime value and return the sum of its digits.
// Examples:
// >>> skjkasdkd((List[Long](0l.toLong, 3l.toLong, 2l.toLong, 1l.toLong, 3l.toLong, 5l.toLong, 7l.toLong,... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_94_skjkasdkd.py | reworded | }
def main(args: Array[String]) = {
assert(skjkasdkd((List[Long](0l.toLong, 3l.toLong, 2l.toLong, 1l.toLong, 3l.toLong, 5l.toLong, 7l.toLong, 4l.toLong, 5l.toLong, 5l.toLong, 5l.toLong, 2l.toLong, 181l.toLong, 32l.toLong, 4l.toLong, 32l.toLong, 3l.toLong, 2l.toLong, 32l.toLong, 324l.toLong, 4l.toLong, 3l.to... | [
"\n }\n"
] |
HumanEval_95_check_dict_case | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a map, return true if all keys are strings in lower
// case or all keys are strings in upper case, else return false.
// The function should return false is the given map is empty.
// Examples:
// >>> checkDictCase((Map... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_95_check_dict_case.py | reworded | }
def main(args: Array[String]) = {
assert(checkDictCase((Map[String,String]("p" -> "pineapple", "b" -> "banana"))) == (true));
assert(checkDictCase((Map[String,String]("p" -> "pineapple", "A" -> "banana", "B" -> "banana"))) == (false));
assert(checkDictCase((Map[String,String]("p" -> "pineapple", "... | [
"\n }\n"
] |
HumanEval_96_count_up_to | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Implement a function that takes an non-negative integer and returns a list of the first n
// integers that are prime numbers and less than n.
// for example:
// >>> countUpTo((5l))
// (List[Long](2l.toLong, 3l.toLong))
// ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_96_count_up_to.py | reworded | }
def main(args: Array[String]) = {
assert(countUpTo((5l)).equals((List[Long](2l.toLong, 3l.toLong))));
assert(countUpTo((6l)).equals((List[Long](2l.toLong, 3l.toLong, 5l.toLong))));
assert(countUpTo((7l)).equals((List[Long](2l.toLong, 3l.toLong, 5l.toLong))));
assert(countUpTo((10l)).equals((Li... | [
"\n }\n"
] |
HumanEval_97_multiply | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Complete the function that takes two integers and returns
// the product of their unit digits.
// Assume the input is always valid.
// Examples:
// >>> multiply((148l), (412l))
// (16l)
// >>> multiply((19l), (28l))
... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_97_multiply.py | reworded | }
def main(args: Array[String]) = {
assert(multiply((148l), (412l)) == (16l));
assert(multiply((19l), (28l)) == (72l));
assert(multiply((2020l), (1851l)) == (0l));
assert(multiply((14l), (-15l)) == (20l));
assert(multiply((76l), (67l)) == (42l));
assert(multiply((17l), (27l)) == (49l));
... | [
"\n }\n"
] |
HumanEval_98_count_upper | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a string s, count the number of uppercase vowels in even indices.
// For example:
// >>> countUpper(("aBCdEf"))
// (1l)
// >>> countUpper(("abcdefg"))
// (0l)
// >>> countUpper(("dBBE"))
// (0l)
def count... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_98_count_upper.py | reworded | }
def main(args: Array[String]) = {
assert(countUpper(("aBCdEf")) == (1l));
assert(countUpper(("abcdefg")) == (0l));
assert(countUpper(("dBBE")) == (0l));
assert(countUpper(("B")) == (0l));
assert(countUpper(("U")) == (1l));
assert(countUpper(("")) == (0l));
assert(countUpper(("EEEE"... | [
"\n }\n"
] |
HumanEval_99_closest_integer | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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
// >>> closestInteger(("10")... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_99_closest_integer.py | reworded | }
def main(args: Array[String]) = {
assert(closestInteger(("10")) == (10l));
assert(closestInteger(("14.5")) == (15l));
assert(closestInteger(("-15.5")) == (-16l));
assert(closestInteger(("15.3")) == (15l));
assert(closestInteger(("0")) == (0l));
}
}
| [
"\n }\n"
] |
HumanEval_9_rolling_max | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// From a given list of integers, generate a list of rolling maximum element found until given moment
// in the sequence.
// >>> rollingMax((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 2l.toLong)))
//... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_9_rolling_max.py | reworded | }
def main(args: Array[String]) = {
assert(rollingMax((List[Long]())).equals((List[Long]())));
assert(rollingMax((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong))).equals((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong))));
assert(rollingMax((List[Long](4l.toLong, 3l.toLong, 2l.toLong,... | [
"\n }\n"
] |
HumanEval_0_has_close_elements | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Check if in given list of numbers, are any two numbers closer to each other than
// given threshold.
// >>> hasCloseElements((List[Float](1.0f.toFloat, 2.0f.toFloat, 3.0f.toFloat)), (0.5f))
// (false)
// >>> hasCloseElements((... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_0_has_close_elements.py | verbatim | }
def main(args: Array[String]) = {
assert(hasCloseElements((List[Float](1.0f.toFloat, 2.0f.toFloat, 3.9f.toFloat, 4.0f.toFloat, 5.0f.toFloat, 2.2f.toFloat)), (0.3f)) == (true));
assert(hasCloseElements((List[Float](1.0f.toFloat, 2.0f.toFloat, 3.9f.toFloat, 4.0f.toFloat, 5.0f.toFloat, 2.2f.toFloat)), (0... | [
"\n }\n"
] |
HumanEval_100_make_a_pile | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a positive integer n, you have to make a pile of n levels of stones.
// The first level has n stones.
// The number of stones in the next level is:
// - the next odd number if n is odd.
// - the next even number if n is ... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_100_make_a_pile.py | verbatim | }
def main(args: Array[String]) = {
assert(makeAPile((3l)).equals((List[Long](3l.toLong, 5l.toLong, 7l.toLong))));
assert(makeAPile((4l)).equals((List[Long](4l.toLong, 6l.toLong, 8l.toLong, 10l.toLong))));
assert(makeAPile((5l)).equals((List[Long](5l.toLong, 7l.toLong, 9l.toLong, 11l.toLong, 13l.toL... | [
"\n }\n"
] |
HumanEval_101_words_string | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You will be given a string of words separated by commas or spaces. Your task is
// to split the string into words and return an array of the words.
// For example:
// >>> wordsString(("Hi, my name is John"))
// (List[String]("... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_101_words_string.py | verbatim | }
def main(args: Array[String]) = {
assert(wordsString(("Hi, my name is John")).equals((List[String]("Hi", "my", "name", "is", "John"))));
assert(wordsString(("One, two, three, four, five, six")).equals((List[String]("One", "two", "three", "four", "five", "six"))));
assert(wordsString(("Hi, my name"... | [
"\n }\n"
] |
HumanEval_102_choose_num | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// This function takes two positive numbers x and y and returns the
// biggest even integer number that is in the range [x, y] inclusive. If
// there's no such number, then the function should return -1.
// For example:
// >>> c... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_102_choose_num.py | verbatim | }
def main(args: Array[String]) = {
assert(chooseNum((12l), (15l)) == (14l));
assert(chooseNum((13l), (12l)) == (-1l));
assert(chooseNum((33l), (12354l)) == (12354l));
assert(chooseNum((5234l), (5233l)) == (-1l));
assert(chooseNum((6l), (29l)) == (28l));
assert(chooseNum((27l), (10l)) ==... | [
"\n }\n"
] |
HumanEval_103_rounded_avg | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given two positive integers n and m, and your task is to compute the
// average of the integers from n through m (including n and m).
// Round the answer to the nearest integer and convert that to binary.
// If n is great... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_103_rounded_avg.py | verbatim | }
def main(args: Array[String]) = {
assert(roundedAvg((1l), (5l)).equals("0b11"));
assert(roundedAvg((7l), (13l)).equals("0b1010"));
assert(roundedAvg((964l), (977l)).equals("0b1111001010"));
assert(roundedAvg((996l), (997l)).equals("0b1111100100"));
assert(roundedAvg((560l), (851l)).equals(... | [
"\n }\n"
] |
HumanEval_104_unique_digits | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a list of positive integers x. return a sorted list of all
// elements that hasn't any even digit.
// Note: Returned list should be sorted in increasing order.
// For example:
// >>> uniqueDigits((List[Long](15l.toLong,... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_104_unique_digits.py | verbatim | }
def main(args: Array[String]) = {
assert(uniqueDigits((List[Long](15l.toLong, 33l.toLong, 1422l.toLong, 1l.toLong))).equals((List[Long](1l.toLong, 15l.toLong, 33l.toLong))));
assert(uniqueDigits((List[Long](152l.toLong, 323l.toLong, 1422l.toLong, 10l.toLong))).equals((List[Long]())));
assert(uniqu... | [
"\n }\n"
] |
HumanEval_105_by_length | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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", "Ei... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_105_by_length.py | verbatim | }
def main(args: Array[String]) = {
assert(byLength((List[Long](2l.toLong, 1l.toLong, 1l.toLong, 4l.toLong, 5l.toLong, 8l.toLong, 2l.toLong, 3l.toLong))).equals((List[String]("Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"))));
assert(byLength((List[Long]())).equals((List[String]())));
... | [
"\n }\n"
] |
HumanEval_106_f | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Implement the function f that takes n as a parameter,
// and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
// or the sum of numbers from 1 to i otherwise.
// i starts fr... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_106_f.py | verbatim | }
def main(args: Array[String]) = {
assert(f((5l)).equals((List[Long](1l.toLong, 2l.toLong, 6l.toLong, 24l.toLong, 15l.toLong))));
assert(f((7l)).equals((List[Long](1l.toLong, 2l.toLong, 6l.toLong, 24l.toLong, 15l.toLong, 720l.toLong, 28l.toLong))));
assert(f((1l)).equals((List[Long](1l.toLong))));
... | [
"\n }\n"
] |
HumanEval_107_even_odd_palindrome | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a positive integer n, return a tuple that has the number of even and odd
// integer palindromes that fall within the range(1, n), inclusive.
// Example 1:
// >>> evenOddPalindrome((3l))
// ((1l, 2l))
// Explanation:
... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_107_even_odd_palindrome.py | verbatim | }
def main(args: Array[String]) = {
assert(evenOddPalindrome((123l)).equals(((8l, 13l))));
assert(evenOddPalindrome((12l)).equals(((4l, 6l))));
assert(evenOddPalindrome((3l)).equals(((1l, 2l))));
assert(evenOddPalindrome((63l)).equals(((6l, 8l))));
assert(evenOddPalindrome((25l)).equals(((5l... | [
"\n }\n"
] |
HumanEval_108_count_nums | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 di... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_108_count_nums.py | verbatim | }
def main(args: Array[String]) = {
assert(countNums((List[Long]())) == (0l));
assert(countNums((List[Long](-1l.toLong, -2l.toLong, 0l.toLong))) == (0l));
assert(countNums((List[Long](1l.toLong, 1l.toLong, 2l.toLong, -2l.toLong, 3l.toLong, 4l.toLong, 5l.toLong))) == (6l));
assert(countNums((List... | [
"\n }\n"
] |
HumanEval_109_move_one_ball | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
// numbers in the array will be randomly ordered. Your task is to determine if
// it is possible to get an array sorted in non-decreasing order by performing
//... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_109_move_one_ball.py | verbatim | }
def main(args: Array[String]) = {
assert(moveOneBall((List[Long](3l.toLong, 4l.toLong, 5l.toLong, 1l.toLong, 2l.toLong))) == (true));
assert(moveOneBall((List[Long](3l.toLong, 5l.toLong, 10l.toLong, 1l.toLong, 2l.toLong))) == (true));
assert(moveOneBall((List[Long](4l.toLong, 3l.toLong, 1l.toLong,... | [
"\n }\n"
] |
HumanEval_10_make_palindrome | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 t... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_10_make_palindrome.py | verbatim | }
def main(args: Array[String]) = {
assert(makePalindrome(("")).equals(("")));
assert(makePalindrome(("x")).equals(("x")));
assert(makePalindrome(("xyz")).equals(("xyzyx")));
assert(makePalindrome(("xyx")).equals(("xyx")));
assert(makePalindrome(("jerry")).equals(("jerryrrej")));
}
}
| [
"\n }\n"
] |
HumanEval_110_exchange | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 l... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_110_exchange.py | verbatim | }
def main(args: Array[String]) = {
assert(exchange((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong)), (List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong))).equals(("YES")));
assert(exchange((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong)), (List[Long](1l.toLong, 5l.toLong, 3l.toLong,... | [
"\n }\n"
] |
HumanEval_111_histogram | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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.... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_111_histogram.py | verbatim | }
def main(args: Array[String]) = {
assert(histogram(("a b b a")).equals((Map[String,Long]("a" -> 2l, "b" -> 2l))));
assert(histogram(("a b c a b")).equals((Map[String,Long]("a" -> 2l, "b" -> 2l))));
assert(histogram(("a b c d g")).equals((Map[String,Long]("a" -> 1l, "b" -> 1l, "c" -> 1l, "d" -> 1l,... | [
"\n }\n"
] |
HumanEval_112_reverse_delete | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Task
// We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
// then check if the result string is palindrome.
// A string is called palindrome if it reads the same bac... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_112_reverse_delete.py | verbatim | }
def main(args: Array[String]) = {
assert(reverseDelete(("abcde"), ("ae")).equals((("bcd", false))));
assert(reverseDelete(("abcdef"), ("b")).equals((("acdef", false))));
assert(reverseDelete(("abcdedcba"), ("ab")).equals((("cdedc", true))));
assert(reverseDelete(("dwik"), ("w")).equals((("dik"... | [
"\n }\n"
] |
HumanEval_113_odd_count | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a list of strings, where each string consists of only digits, return a list.
// Each element i of the output should be "the number of odd elements in the
// string i of the input." where all the i's should be replaced by the num... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_113_odd_count.py | verbatim | }
def main(args: Array[String]) = {
assert(oddCount((List[String]("1234567"))).equals((List[String]("the number of odd elements 4n the str4ng 4 of the 4nput."))));
assert(oddCount((List[String]("3", "11111111"))).equals((List[String]("the number of odd elements 1n the str1ng 1 of the 1nput.", "the numbe... | [
"\n }\n"
] |
HumanEval_114_minSubArraySum | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given an array of integers nums, find the minimum sum of any non-empty sub-array
// of nums.
// Example
// >>> minSubArraySum((List[Long](2l.toLong, 3l.toLong, 4l.toLong, 1l.toLong, 2l.toLong, 4l.toLong)))
// (1l)
// >>> m... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_114_minSubArraySum.py | verbatim | }
def main(args: Array[String]) = {
assert(minSubArraySum((List[Long](2l.toLong, 3l.toLong, 4l.toLong, 1l.toLong, 2l.toLong, 4l.toLong))) == (1l));
assert(minSubArraySum((List[Long](-1l.toLong, -2l.toLong, -3l.toLong))) == (-6l));
assert(minSubArraySum((List[Long](-1l.toLong, -2l.toLong, -3l.toLong,... | [
"\n }\n"
] |
HumanEval_115_max_fill | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a rectangular grid of wells. Each row represents a single well,
// and each 1 in a row represents a single unit of water.
// Each well has a corresponding bucket that can be used to extract water from it,
// and all... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_115_max_fill.py | verbatim | }
def main(args: Array[String]) = {
assert(maxFill((List[List[Long]](List[Long](0l.toLong, 0l.toLong, 1l.toLong, 0l.toLong), List[Long](0l.toLong, 1l.toLong, 0l.toLong, 0l.toLong), List[Long](1l.toLong, 1l.toLong, 1l.toLong, 1l.toLong))), (1l)) == (6l));
assert(maxFill((List[List[Long]](List[Long](0l.to... | [
"\n }\n"
] |
HumanEval_116_sort_array | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// In this Kata, you have to sort an array of non-negative integers according to
// number of ones in their binary representation in ascending order.
// For similar number of ones, sort based on decimal value.
// It must be implement... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_116_sort_array.py | verbatim | }
def main(args: Array[String]) = {
assert(sortArray((List[Long](1l.toLong, 5l.toLong, 2l.toLong, 3l.toLong, 4l.toLong))).equals((List[Long](1l.toLong, 2l.toLong, 4l.toLong, 3l.toLong, 5l.toLong))));
assert(sortArray((List[Long](-2l.toLong, -3l.toLong, -4l.toLong, -5l.toLong, -6l.toLong))).equals((List[... | [
"\n }\n"
] |
HumanEval_117_select_words | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a string s and a natural number n, you have been tasked to implement
// a function that returns a list of all words from string s that contain exactly
// n consonants, in order these words appear in the string s.
// If the... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_117_select_words.py | verbatim | }
def main(args: Array[String]) = {
assert(selectWords(("Mary had a little lamb"), (4l)).equals((List[String]("little"))));
assert(selectWords(("Mary had a little lamb"), (3l)).equals((List[String]("Mary", "lamb"))));
assert(selectWords(("simple white space"), (2l)).equals((List[String]())));
as... | [
"\n }\n"
] |
HumanEval_118_get_closest_vowel | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_118_get_closest_vowel.py | verbatim | }
def main(args: Array[String]) = {
assert(getClosestVowel(("yogurt")).equals(("u")));
assert(getClosestVowel(("full")).equals(("u")));
assert(getClosestVowel(("easy")).equals(("")));
assert(getClosestVowel(("eAsy")).equals(("")));
assert(getClosestVowel(("ali")).equals(("")));
assert(ge... | [
"\n }\n"
] |
HumanEval_119_match_parens | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a list of two strings, both strings consist of open
// parentheses '(' or close parentheses ')' only.
// Your job is to check if it is possible to concatenate the two strings in
// some order, that the resulting stri... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_119_match_parens.py | verbatim | }
def main(args: Array[String]) = {
assert(matchParens((List[String]("()(", ")"))).equals(("Yes")));
assert(matchParens((List[String](")", ")"))).equals(("No")));
assert(matchParens((List[String]("(()(())", "())())"))).equals(("No")));
assert(matchParens((List[String](")())", "(()()("))).equals(... | [
"\n }\n"
] |
HumanEval_11_string_xor | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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.
// >>> stringXor(("010"), ("110"))
// ("100")
def stringXor(a : String, b : String) : String... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_11_string_xor.py | verbatim | }
def main(args: Array[String]) = {
assert(stringXor(("111000"), ("101010")).equals(("010010")));
assert(stringXor(("1"), ("1")).equals(("0")));
assert(stringXor(("0101"), ("0000")).equals(("0101")));
}
}
| [
"\n }\n"
] |
HumanEval_120_maximum | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given an array arr of integers and a positive integer k, return a sorted list
// of length k with the maximum k numbers in arr.
// Example 1:
// >>> maximum((List[Long](-3l.toLong, -4l.toLong, 5l.toLong)), (3l))
// (List[Long... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_120_maximum.py | verbatim | }
def main(args: Array[String]) = {
assert(maximum((List[Long](-3l.toLong, -4l.toLong, 5l.toLong)), (3l)).equals((List[Long](-4l.toLong, -3l.toLong, 5l.toLong))));
assert(maximum((List[Long](4l.toLong, -4l.toLong, 4l.toLong)), (2l)).equals((List[Long](4l.toLong, 4l.toLong))));
assert(maximum((List[L... | [
"\n }\n"
] |
HumanEval_121_solution | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
// Examples
// >>> solution((List[Long](5l.toLong, 8l.toLong, 7l.toLong, 1l.toLong)))
// (12l)
// >>> solution((List[Lon... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_121_solution.py | verbatim | }
def main(args: Array[String]) = {
assert(solution((List[Long](5l.toLong, 8l.toLong, 7l.toLong, 1l.toLong))) == (12l));
assert(solution((List[Long](3l.toLong, 3l.toLong, 3l.toLong, 3l.toLong, 3l.toLong))) == (9l));
assert(solution((List[Long](30l.toLong, 13l.toLong, 24l.toLong, 321l.toLong))) == (0... | [
"\n }\n"
] |
HumanEval_122_add_elements | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a non-empty array of integers arr and an integer k, return
// the sum of the elements with at most two digits from the first k elements of arr.
// Example:
// >>> addElements((List[Long](111l.toLong, 21l.toLong, 3l.toLong, 4... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_122_add_elements.py | verbatim | }
def main(args: Array[String]) = {
assert(addElements((List[Long](1l.toLong, -2l.toLong, -3l.toLong, 41l.toLong, 57l.toLong, 76l.toLong, 87l.toLong, 88l.toLong, 99l.toLong)), (3l)) == (-4l));
assert(addElements((List[Long](111l.toLong, 121l.toLong, 3l.toLong, 4000l.toLong, 5l.toLong, 6l.toLong)), (2l))... | [
"\n }\n"
] |
HumanEval_123_get_odd_collatz | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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.... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_123_get_odd_collatz.py | verbatim | }
def main(args: Array[String]) = {
assert(getOddCollatz((14l)).equals((List[Long](1l.toLong, 5l.toLong, 7l.toLong, 11l.toLong, 13l.toLong, 17l.toLong))));
assert(getOddCollatz((5l)).equals((List[Long](1l.toLong, 5l.toLong))));
assert(getOddCollatz((12l)).equals((List[Long](1l.toLong, 3l.toLong, 5l.... | [
"\n }\n"
] |
HumanEval_124_valid_date | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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.
/... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_124_valid_date.py | verbatim | }
def main(args: Array[String]) = {
assert(validDate(("03-11-2000")) == (true));
assert(validDate(("15-01-2012")) == (false));
assert(validDate(("04-0-2040")) == (false));
assert(validDate(("06-04-2020")) == (true));
assert(validDate(("01-01-2007")) == (true));
assert(validDate(("03-32-2... | [
"\n }\n"
] |
HumanEval_125_split_words | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
// should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
/... | transform | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals-with-cleaned-doctests/HumanEval_125_split_words.py | verbatim | }
def main(args: Array[String]) = {
assert(splitWords(("Hello world!")).equals(List[String]("Hello", "world!")));
assert(splitWords(("Hello,world!")).equals(List[String]("Hello", "world!")));
assert(splitWords(("Hello world,!")).equals(List[String]("Hello", "world,!")));
assert(splitWords(("Hell... | [
"\n }\n"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.