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_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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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:
// Input: 3
// Output: (1, 2)
// Explanation:
// Integer ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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
//... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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.... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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([2, 3, 4, 1, 2, 4]) == 1
// minSubArraySum([-1, -2, -3]) == -6
def minSubArraySum(nums : List[Long])... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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.
// >>> string_xor('010', '110')
// '100'
def stringXor(a : String, b : String) : String = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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:
// Input: arr = [-3, -4, 5], k = 3
// Output: [-4, -3, 5]
// Example 2:
// ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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([5, 8, 7, 1]) ==> 12
// solution([3, 3, 3, 3, 3]) ==> 9
// solution([30, 13, 24, 321]) ==>0
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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:
// Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
// Output: 24 #... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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.... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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.
/... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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
/... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/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"
] |
HumanEval_126_is_sorted | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a list of numbers, return whether or not they are sorted
// in ascending order. If list has more than 1 duplicate of the same
// number, return False. Assume no negative numbers and only integers.
// Examples
// is_sorte... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_126_is_sorted.py | verbatim | }
def main(args: Array[String]) = {
assert(isSorted((List[Long](5l.toLong))) == (true));
assert(isSorted((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 5l.toLong))) == (true));
assert(isSorted((List[Long](1l.toLong, 3l.toLong, 2l.toLong, 4l.toLong, 5l.toLong))) == (false));
assert(isSor... | [
"\n }\n"
] |
HumanEval_127_intersection | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given two intervals,
// where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
// The given intervals are closed which means that the interval (start, end)
// includes both start and end.... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_127_intersection.py | verbatim | }
def main(args: Array[String]) = {
assert(intersection(((1l, 2l)), ((2l, 3l))).equals(("NO")));
assert(intersection(((-1l, 1l)), ((0l, 4l))).equals(("NO")));
assert(intersection(((-3l, -1l)), ((-5l, 5l))).equals(("YES")));
assert(intersection(((-2l, 2l)), ((-4l, 0l))).equals(("YES")));
asse... | [
"\n }\n"
] |
HumanEval_128_prod_signs | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given an array arr of integers and you need to return
// sum of magnitudes of integers multiplied by product of all signs
// of each number in the array, represented by 1, -1 or 0.
// Note: return None for empty arr.
/... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_128_prod_signs.py | verbatim | }
def main(args: Array[String]) = {
assert(prodSigns((List[Long](1l.toLong, 2l.toLong, 2l.toLong, -4l.toLong))).equals(Some(-9l)));
assert(prodSigns((List[Long](0l.toLong, 1l.toLong))).equals(Some(0l)));
assert(prodSigns((List[Long](1l.toLong, 1l.toLong, 1l.toLong, 2l.toLong, 3l.toLong, -1l.toLong, ... | [
"\n }\n"
] |
HumanEval_129_minPath | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a grid with N rows and N columns (N >= 2) and a positive integer k,
// each cell of the grid contains a value. Every integer in the range [1, N * N]
// inclusive appears exactly once on the cells of the grid.
// You have to... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_129_minPath.py | verbatim | }
def main(args: Array[String]) = {
assert(minPath((List[List[Long]](List[Long](1l.toLong, 2l.toLong, 3l.toLong), List[Long](4l.toLong, 5l.toLong, 6l.toLong), List[Long](7l.toLong, 8l.toLong, 9l.toLong))), (3l)).equals((List[Long](1l.toLong, 2l.toLong, 1l.toLong))));
assert(minPath((List[List[Long]](Lis... | [
"\n }\n"
] |
HumanEval_12_longest | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Out of list of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return None in case the input list is empty.
// >>> longest([])
// >>> longest(['a', 'b', 'c'])
// 'a'
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_12_longest.py | verbatim | }
def main(args: Array[String]) = {
assert(longest((List[String]())).equals(None));
assert(longest((List[String]("x", "y", "z"))).equals(Some("x")));
assert(longest((List[String]("x", "yyy", "zzzz", "www", "kkkk", "abc"))).equals(Some("zzzz")));
}
}
| [
"\n }\n"
] |
HumanEval_130_tri | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
// the last couple centuries. However, what people don't know is Tribonacci sequence.
// Tribonacci sequence is defined by the recurrence:
// tri(1) = ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_130_tri.py | verbatim | }
def main(args: Array[String]) = {
assert(tri((3l)).equals((List[Long](1l.toLong, 3l.toLong, 2l.toLong, 8l.toLong))));
assert(tri((4l)).equals((List[Long](1l.toLong, 3l.toLong, 2l.toLong, 8l.toLong, 3l.toLong))));
assert(tri((5l)).equals((List[Long](1l.toLong, 3l.toLong, 2l.toLong, 8l.toLong, 3l.to... | [
"\n }\n"
] |
HumanEval_131_digits | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a positive integer n, return the product of the odd digits.
// Return 0 if all digits are even.
// For example:
// digits(1) == 1
// digits(4) == 0
// digits(235) == 15
def digits(n : Long) : Long = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_131_digits.py | verbatim | }
def main(args: Array[String]) = {
assert(digits((5l)) == (5l));
assert(digits((54l)) == (5l));
assert(digits((120l)) == (1l));
assert(digits((5014l)) == (5l));
assert(digits((98765l)) == (315l));
assert(digits((5576543l)) == (2625l));
assert(digits((2468l)) == (0l));
}
}
| [
"\n }\n"
] |
HumanEval_132_is_nested | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Create a function that takes a string as input which contains only square brackets.
// The function should return True if and only if there is a valid subsequence of brackets
// where at least one bracket in the subsequence is nested... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_132_is_nested.py | verbatim | }
def main(args: Array[String]) = {
assert(isNested(("[[]]")) == (true));
assert(isNested(("[]]]]]]][[[[[]")) == (false));
assert(isNested(("[][]")) == (false));
assert(isNested(("[]")) == (false));
assert(isNested(("[[[[]]]]")) == (true));
assert(isNested(("[]]]]]]]]]]")) == (false));
... | [
"\n }\n"
] |
HumanEval_133_sum_squares | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a list of numbers.
// You need to return the sum of squared numbers in the given list,
// round each element in the list to the upper int(Ceiling) first.
// Examples:
// For lst = [1,2,3] the output should be 14
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_133_sum_squares.py | verbatim | }
def main(args: Array[String]) = {
assert(sumSquares((List[Float](1.0f.toFloat, 2.0f.toFloat, 3.0f.toFloat))) == (14l));
assert(sumSquares((List[Float](1.0f.toFloat, 2.0f.toFloat, 3.0f.toFloat))) == (14l));
assert(sumSquares((List[Float](1.0f.toFloat, 3.0f.toFloat, 5.0f.toFloat, 7.0f.toFloat))) == ... | [
"\n }\n"
] |
HumanEval_134_check_if_last_char_is_a_letter | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Create a function that returns True if the last character
// of a given string is an alphabetical character and is not
// a part of a word, and False otherwise.
// Note: "word" is a group of characters separated by space.
// E... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_134_check_if_last_char_is_a_letter.py | verbatim | }
def main(args: Array[String]) = {
assert(checkIfLastCharIsALetter(("apple")) == (false));
assert(checkIfLastCharIsALetter(("apple pi e")) == (true));
assert(checkIfLastCharIsALetter(("eeeee")) == (false));
assert(checkIfLastCharIsALetter(("A")) == (true));
assert(checkIfLastCharIsALetter((... | [
"\n }\n"
] |
HumanEval_135_can_arrange | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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
// duplic... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_135_can_arrange.py | verbatim | }
def main(args: Array[String]) = {
assert(canArrange((List[Long](1l.toLong, 2l.toLong, 4l.toLong, 3l.toLong, 5l.toLong))) == (3l));
assert(canArrange((List[Long](1l.toLong, 2l.toLong, 4l.toLong, 5l.toLong))) == (-1l));
assert(canArrange((List[Long](1l.toLong, 4l.toLong, 2l.toLong, 5l.toLong, 6l.toL... | [
"\n }\n"
] |
HumanEval_136_largest_smallest_integers | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Create a function that returns a tuple (a, b), where 'a' is
// the largest of negative integers, and 'b' is the smallest
// of positive integers in a list.
// If there is no negative or positive integers, return them as None.
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_136_largest_smallest_integers.py | verbatim | }
def main(args: Array[String]) = {
assert(largestSmallestIntegers((List[Long](2l.toLong, 4l.toLong, 1l.toLong, 3l.toLong, 5l.toLong, 7l.toLong))).equals((Some(None), Some(1l))));
assert(largestSmallestIntegers((List[Long](2l.toLong, 4l.toLong, 1l.toLong, 3l.toLong, 5l.toLong, 7l.toLong, 0l.toLong))).eq... | [
"\n }\n"
] |
HumanEval_138_is_equal_to_sum_even | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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
def isE... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_138_is_equal_to_sum_even.py | verbatim | }
def main(args: Array[String]) = {
assert(isEqualToSumEven((4l)) == (false));
assert(isEqualToSumEven((6l)) == (false));
assert(isEqualToSumEven((8l)) == (true));
assert(isEqualToSumEven((10l)) == (true));
assert(isEqualToSumEven((11l)) == (false));
assert(isEqualToSumEven((12l)) == (tr... | [
"\n }\n"
] |
HumanEval_139_special_factorial | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// The Brazilian factorial is defined as:
// brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
// where n > 0
// For example:
// >>> special_factorial(4)
// 288
// The function will receive an integer as input and ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_139_special_factorial.py | verbatim | }
def main(args: Array[String]) = {
assert(specialFactorial((4l)) == (288l));
assert(specialFactorial((5l)) == (34560l));
assert(specialFactorial((7l)) == (125411328000l));
assert(specialFactorial((1l)) == (1l));
}
}
| [
"\n }\n"
] |
HumanEval_13_greatest_common_divisor | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return a greatest common divisor of two integers a and b
// >>> greatest_common_divisor(3, 5)
// 1
// >>> greatest_common_divisor(25, 15)
// 5
def greatestCommonDivisor(a : Long, b : Long) : Long = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_13_greatest_common_divisor.py | verbatim | }
def main(args: Array[String]) = {
assert(greatestCommonDivisor((3l), (7l)) == (1l));
assert(greatestCommonDivisor((10l), (15l)) == (5l));
assert(greatestCommonDivisor((49l), (14l)) == (7l));
assert(greatestCommonDivisor((144l), (60l)) == (12l));
}
}
| [
"\n }\n"
] |
HumanEval_140_fix_spaces | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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("Examp... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_140_fix_spaces.py | verbatim | }
def main(args: Array[String]) = {
assert(fixSpaces(("Example")).equals(("Example")));
assert(fixSpaces(("Mudasir Hanif ")).equals(("Mudasir_Hanif_")));
assert(fixSpaces(("Yellow Yellow Dirty Fellow")).equals(("Yellow_Yellow__Dirty__Fellow")));
assert(fixSpaces(("Exa mple")).equals(("Exa-mp... | [
"\n }\n"
] |
HumanEval_141_file_name_check | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 condition... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_141_file_name_check.py | verbatim | }
def main(args: Array[String]) = {
assert(fileNameCheck(("example.txt")).equals(("Yes")));
assert(fileNameCheck(("1example.dll")).equals(("No")));
assert(fileNameCheck(("s1sdf3.asd")).equals(("No")));
assert(fileNameCheck(("K.dll")).equals(("Yes")));
assert(fileNameCheck(("MY16FILE3.exe")).... | [
"\n }\n"
] |
HumanEval_142_sum_squares | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// "
// This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a
// multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a mu... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_142_sum_squares.py | verbatim | }
def main(args: Array[String]) = {
assert(sumSquares((List[Long](1l.toLong, 2l.toLong, 3l.toLong))) == (6l));
assert(sumSquares((List[Long](1l.toLong, 4l.toLong, 9l.toLong))) == (14l));
assert(sumSquares((List[Long]())) == (0l));
assert(sumSquares((List[Long](1l.toLong, 1l.toLong, 1l.toLong, 1l... | [
"\n }\n"
] |
HumanEval_143_words_in_sentence | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a string representing a sentence,
// the sentence contains some words separated by a space,
// and you have to return a string that contains the words from the original sentence,
// whose lengths are prime numbers,
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_143_words_in_sentence.py | verbatim | }
def main(args: Array[String]) = {
assert(wordsInSentence(("This is a test")).equals(("is")));
assert(wordsInSentence(("lets go for swimming")).equals(("go for")));
assert(wordsInSentence(("there is no place available here")).equals(("there is no place")));
assert(wordsInSentence(("Hi I am Huss... | [
"\n }\n"
] |
HumanEval_144_simplify | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Your task is to implement a function that will simplify the expression
// x * n. The function returns True if x * n evaluates to a whole number and False
// otherwise. Both x and n, are string representation of a fraction, and have th... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_144_simplify.py | verbatim | }
def main(args: Array[String]) = {
assert(simplify(("1/5"), ("5/1")) == (true));
assert(simplify(("1/6"), ("2/1")) == (false));
assert(simplify(("5/1"), ("3/1")) == (true));
assert(simplify(("7/10"), ("10/2")) == (false));
assert(simplify(("2/10"), ("50/10")) == (true));
assert(simplify... | [
"\n }\n"
] |
HumanEval_145_order_by_points | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Write a function which sorts the given list of integers
// in ascending order according to the sum of their digits.
// Note: if there are several items with similar sum of their digits,
// order them based on their index in origin... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_145_order_by_points.py | verbatim | }
def main(args: Array[String]) = {
assert(orderByPoints((List[Long](1l.toLong, 11l.toLong, -1l.toLong, -11l.toLong, -12l.toLong))).equals((List[Long](-1l.toLong, -11l.toLong, 1l.toLong, -12l.toLong, 11l.toLong))));
assert(orderByPoints((List[Long](1234l.toLong, 423l.toLong, 463l.toLong, 145l.toLong, 2l... | [
"\n }\n"
] |
HumanEval_146_specialFilter | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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:
// s... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_146_specialFilter.py | verbatim | }
def main(args: Array[String]) = {
assert(specialFilter((List[Long](5l.toLong, -2l.toLong, 1l.toLong, -5l.toLong))) == (0l));
assert(specialFilter((List[Long](15l.toLong, -73l.toLong, 14l.toLong, -15l.toLong))) == (1l));
assert(specialFilter((List[Long](33l.toLong, -2l.toLong, -3l.toLong, 45l.toLon... | [
"\n }\n"
] |
HumanEval_147_get_max_triples | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_147_get_max_triples.py | verbatim | }
def main(args: Array[String]) = {
assert(getMaxTriples((5l)) == (1l));
assert(getMaxTriples((6l)) == (4l));
assert(getMaxTriples((10l)) == (36l));
assert(getMaxTriples((100l)) == (53361l));
}
}
| [
"\n }\n"
] |
HumanEval_148_bf | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// There are eight planets in our solar system: the closerst to the Sun
// is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
// Uranus, Neptune.
// Write a function that takes two planet names as strings planet1... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_148_bf.py | verbatim | }
def main(args: Array[String]) = {
assert(bf(("Jupiter"), ("Neptune")).equals((List[String]("Saturn", "Uranus"))));
assert(bf(("Earth"), ("Mercury")).equals((List[String]("Venus"))));
assert(bf(("Mercury"), ("Uranus")).equals((List[String]("Venus", "Earth", "Mars", "Jupiter", "Saturn"))));
asse... | [
"\n }\n"
] |
HumanEval_149_sorted_list_sum | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_149_sorted_list_sum.py | verbatim | }
def main(args: Array[String]) = {
assert(sortedListSum((List[String]("aa", "a", "aaa"))).equals((List[String]("aa"))));
assert(sortedListSum((List[String]("school", "AI", "asdf", "b"))).equals((List[String]("AI", "asdf", "school"))));
assert(sortedListSum((List[String]("d", "b", "c", "a"))).equals... | [
"\n }\n"
] |
HumanEval_14_all_prefixes | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return list of all prefixes from shortest to longest of the input string
// >>> all_prefixes('abc')
// ['a', 'ab', 'abc']
def allPrefixes(string : String) : List[String] = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_14_all_prefixes.py | verbatim | }
def main(args: Array[String]) = {
assert(allPrefixes(("")).equals((List[String]())));
assert(allPrefixes(("asdfgh")).equals((List[String]("a", "as", "asd", "asdf", "asdfg", "asdfgh"))));
assert(allPrefixes(("WWW")).equals((List[String]("W", "WW", "WWW"))));
}
}
| [
"\n }\n"
] |
HumanEval_150_x_or_y | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// A simple program which should return the value of x if n is
// a prime number and should return the value of y otherwise.
// Examples:
// for x_or_y(7, 34, 12) == 34
// for x_or_y(15, 8, 5) == 5
def xOrY(n : Long, x : Lon... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_150_x_or_y.py | verbatim | }
def main(args: Array[String]) = {
assert(xOrY((7l), (34l), (12l)) == (34l));
assert(xOrY((15l), (8l), (5l)) == (5l));
assert(xOrY((3l), (33l), (5212l)) == (33l));
assert(xOrY((1259l), (3l), (52l)) == (3l));
assert(xOrY((7919l), (-1l), (12l)) == (-1l));
assert(xOrY((3609l), (1245l), (58... | [
"\n }\n"
] |
HumanEval_151_double_the_difference | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_151_double_the_difference.py | verbatim | }
def main(args: Array[String]) = {
assert(doubleTheDifference((List[Float]())) == (0l));
assert(doubleTheDifference((List[Float](5.0f.toFloat, 4.0f.toFloat))) == (25l));
assert(doubleTheDifference((List[Float](0.1f.toFloat, 0.2f.toFloat, 0.3f.toFloat))) == (0l));
assert(doubleTheDifference((Lis... | [
"\n }\n"
] |
HumanEval_152_compare | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// I think we all remember that feeling when the result of some long-awaited
// event is finally known. The feelings and thoughts you have at that moment are
// definitely worth noting down and comparing.
// Your task is to determine... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_152_compare.py | verbatim | }
def main(args: Array[String]) = {
assert(compare((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 5l.toLong, 1l.toLong)), (List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong, 2l.toLong, -2l.toLong))).equals((List[Long](0l.toLong, 0l.toLong, 0l.toLong, 0l.toLong, 3l.toLong, 3l.toLong))));
ass... | [
"\n }\n"
] |
HumanEval_153_Strongest_Extension | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You will be given the name of a class (a string) and a list of extensions.
// The extensions are to be used to load additional classes to the class. The
// strength of the extension is as follows: Let CAP be the number of the uppercas... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_153_Strongest_Extension.py | verbatim | }
def main(args: Array[String]) = {
assert(StrongestExtension(("Watashi"), (List[String]("tEN", "niNE", "eIGHt8OKe"))).equals(("Watashi.eIGHt8OKe")));
assert(StrongestExtension(("Boku123"), (List[String]("nani", "NazeDa", "YEs.WeCaNe", "32145tggg"))).equals(("Boku123.YEs.WeCaNe")));
assert(Strongest... | [
"\n }\n"
] |
HumanEval_154_cycpattern_check | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word
// cycpattern_check("abcd","abd") => False
// cycpattern_check("hello","ell") => True
// cycpattern_check("... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_154_cycpattern_check.py | verbatim | }
def main(args: Array[String]) = {
assert(cycpatternCheck(("xyzw"), ("xyw")) == (false));
assert(cycpatternCheck(("yello"), ("ell")) == (true));
assert(cycpatternCheck(("whattup"), ("ptut")) == (false));
assert(cycpatternCheck(("efef"), ("fee")) == (true));
assert(cycpatternCheck(("abab"), ... | [
"\n }\n"
] |
HumanEval_155_even_odd_count | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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)
def evenOddCount(num : Long) : Tuple2[Long, Long] = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_155_even_odd_count.py | verbatim | }
def main(args: Array[String]) = {
assert(evenOddCount((7l)).equals(((0l, 1l))));
assert(evenOddCount((-78l)).equals(((1l, 1l))));
assert(evenOddCount((3452l)).equals(((2l, 2l))));
assert(evenOddCount((346211l)).equals(((3l, 3l))));
assert(evenOddCount((-345821l)).equals(((3l, 3l))));
a... | [
"\n }\n"
] |
HumanEval_156_int_to_mini_roman | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a positive integer, obtain its roman numeral equivalent as a string,
// and return it in lowercase.
// Restrictions: 1 <= num <= 1000
// Examples:
// >>> int_to_mini_roman(19) == 'xix'
// >>> int_to_mini_roman(152) =... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_156_int_to_mini_roman.py | verbatim | }
def main(args: Array[String]) = {
assert(intToMiniRoman((19l)).equals(("xix")));
assert(intToMiniRoman((152l)).equals(("clii")));
assert(intToMiniRoman((251l)).equals(("ccli")));
assert(intToMiniRoman((426l)).equals(("cdxxvi")));
assert(intToMiniRoman((500l)).equals(("d")));
assert(int... | [
"\n }\n"
] |
HumanEval_157_right_angle_triangle | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given the lengths of the three sides of a triangle. Return True if the three
// sides form a right-angled triangle, False otherwise.
// A right-angled triangle is a triangle in which one angle is right angle or
// 90 degree.
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_157_right_angle_triangle.py | verbatim | }
def main(args: Array[String]) = {
assert(rightAngleTriangle((3l), (4l), (5l)) == (true));
assert(rightAngleTriangle((1l), (2l), (3l)) == (false));
assert(rightAngleTriangle((10l), (6l), (8l)) == (true));
assert(rightAngleTriangle((2l), (2l), (2l)) == (false));
assert(rightAngleTriangle((7l... | [
"\n }\n"
] |
HumanEval_158_find_max | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Write a function that accepts a list of strings.
// The list contains different words. Return the word with maximum number
// of unique characters. If multiple strings have maximum number of unique
// characters, return the one wh... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_158_find_max.py | verbatim | }
def main(args: Array[String]) = {
assert(findMax((List[String]("name", "of", "string"))).equals(("string")));
assert(findMax((List[String]("name", "enam", "game"))).equals(("enam")));
assert(findMax((List[String]("aaaaaaa", "bb", "cc"))).equals(("aaaaaaa")));
assert(findMax((List[String]("abc"... | [
"\n }\n"
] |
HumanEval_159_eat | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You're a hungry rabbit, and you already have eaten a certain number of carrots,
// but now you need to eat more carrots to complete the day's meals.
// you should return an array of [ total number of eaten carrots after your meals,
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_159_eat.py | verbatim | }
def main(args: Array[String]) = {
assert(eat((5l), (6l), (10l)).equals((List[Long](11l.toLong, 4l.toLong))));
assert(eat((4l), (8l), (9l)).equals((List[Long](12l.toLong, 1l.toLong))));
assert(eat((1l), (10l), (10l)).equals((List[Long](11l.toLong, 0l.toLong))));
assert(eat((2l), (11l), (5l)).eq... | [
"\n }\n"
] |
HumanEval_15_string_sequence | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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'
def stringSequence(n : Long) : String = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_15_string_sequence.py | verbatim | }
def main(args: Array[String]) = {
assert(stringSequence((0l)).equals(("0")));
assert(stringSequence((3l)).equals(("0 1 2 3")));
assert(stringSequence((10l)).equals(("0 1 2 3 4 5 6 7 8 9 10")));
}
}
| [
"\n }\n"
] |
HumanEval_160_do_algebra | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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 expressi... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_160_do_algebra.py | verbatim | }
def main(args: Array[String]) = {
assert(doAlgebra((List[String]("**", "*", "+")), (List[Long](2l.toLong, 3l.toLong, 4l.toLong, 5l.toLong))) == (37l));
assert(doAlgebra((List[String]("+", "*", "-")), (List[Long](2l.toLong, 3l.toLong, 4l.toLong, 5l.toLong))) == (9l));
assert(doAlgebra((List[String]... | [
"\n }\n"
] |
HumanEval_161_solve | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// You are given a string s.
// if s[i] is a letter, reverse its case from lower to upper or vise versa,
// otherwise keep it as it is.
// If the string contains no letters, reverse the string.
// The function should return the ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_161_solve.py | verbatim | }
def main(args: Array[String]) = {
assert(solve(("AsDf")).equals(("aSdF")));
assert(solve(("1234")).equals(("4321")));
assert(solve(("ab")).equals(("AB")));
assert(solve(("#a@C")).equals(("#A@c")));
assert(solve(("#AsdfW^45")).equals(("#aSDFw^45")));
assert(solve(("#6@2")).equals(("2@6#... | [
"\n }\n"
] |
HumanEval_162_string_to_md5 | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a string 'text', return its md5 hash equivalent string.
// If 'text' is an empty string, return None.
// >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
def stringToMd5(text : String) : Option[String] ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_162_string_to_md5.py | verbatim | }
def main(args: Array[String]) = {
assert(stringToMd5(("Hello world")).equals(Some("3e25960a79dbc69b674cd4ec67a72c62")));
assert(stringToMd5(("")).equals(None));
assert(stringToMd5(("A B C")).equals(Some("0ef78513b0cb8cef12743f5aeb35f888")));
assert(stringToMd5(("password")).equals(Some("5f4dcc... | [
"\n }\n"
] |
HumanEval_163_generate_integers | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given two positive integers a and b, return the even digits between a
// and b, in ascending order.
// For example:
// generate_integers(2, 8) => [2, 4, 6, 8]
// generate_integers(8, 2) => [2, 4, 6, 8]
// generate_integers... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_163_generate_integers.py | verbatim | }
def main(args: Array[String]) = {
assert(generateIntegers((2l), (10l)).equals((List[Long](2l.toLong, 4l.toLong, 6l.toLong, 8l.toLong))));
assert(generateIntegers((10l), (2l)).equals((List[Long](2l.toLong, 4l.toLong, 6l.toLong, 8l.toLong))));
assert(generateIntegers((132l), (2l)).equals((List[Long]... | [
"\n }\n"
] |
HumanEval_16_count_distinct_characters | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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
def countDistinctCharacters(strin... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_16_count_distinct_characters.py | verbatim | }
def main(args: Array[String]) = {
assert(countDistinctCharacters(("")) == (0l));
assert(countDistinctCharacters(("abcde")) == (5l));
assert(countDistinctCharacters(("abcdecadeCADE")) == (5l));
assert(countDistinctCharacters(("aaaaAAAAaaaa")) == (1l));
assert(countDistinctCharacters(("Jerry... | [
"\n }\n"
] |
HumanEval_17_parse_music | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return list of integers corresponding to how many beats does each
// not last.
// Here is a legend:
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_17_parse_music.py | verbatim | }
def main(args: Array[String]) = {
assert(parseMusic(("")).equals((List[Long]())));
assert(parseMusic(("o o o o")).equals((List[Long](4l.toLong, 4l.toLong, 4l.toLong, 4l.toLong))));
assert(parseMusic((".| .| .| .|")).equals((List[Long](1l.toLong, 1l.toLong, 1l.toLong, 1l.toLong))));
assert(pars... | [
"\n }\n"
] |
HumanEval_18_how_many_times | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// >>> how_many_times('', 'a')
// 0
// >>> how_many_times('aaa', 'a')
// 3
// >>> how_many_times('aaaa', 'aa')
// 3
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_18_how_many_times.py | verbatim | }
def main(args: Array[String]) = {
assert(howManyTimes((""), ("x")) == (0l));
assert(howManyTimes(("xyxyxyx"), ("x")) == (4l));
assert(howManyTimes(("cacacacac"), ("cac")) == (4l));
assert(howManyTimes(("john doe"), ("john")) == (1l));
}
}
| [
"\n }\n"
] |
HumanEval_19_sort_numbers | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to la... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_19_sort_numbers.py | verbatim | }
def main(args: Array[String]) = {
assert(sortNumbers(("")).equals(("")));
assert(sortNumbers(("three")).equals(("three")));
assert(sortNumbers(("three five nine")).equals(("three five nine")));
assert(sortNumbers(("five zero four seven nine eight")).equals(("zero four five seven eight nine")))... | [
"\n }\n"
] |
HumanEval_1_separate_paren_groups | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the list of those.
// Separate groups are balanced (each open brace is prope... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_1_separate_paren_groups.py | verbatim | }
def main(args: Array[String]) = {
assert(separateParenGroups(("(()()) ((())) () ((())()())")).equals((List[String]("(()())", "((()))", "()", "((())()())"))));
assert(separateParenGroups(("() (()) ((())) (((())))")).equals((List[String]("()", "(())", "((()))", "(((())))"))));
assert(separateParenGr... | [
"\n }\n"
] |
HumanEval_20_find_closest_elements | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// From a supplied list of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_20_find_closest_elements.py | verbatim | }
def main(args: Array[String]) = {
assert(findClosestElements((List[Float](1.0f.toFloat, 2.0f.toFloat, 3.9f.toFloat, 4.0f.toFloat, 5.0f.toFloat, 2.2f.toFloat))).equals(((3.9f, 4.0f))));
assert(findClosestElements((List[Float](1.0f.toFloat, 2.0f.toFloat, 5.9f.toFloat, 4.0f.toFloat, 5.0f.toFloat))).equal... | [
"\n }\n"
] |
HumanEval_21_rescale_to_unit | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given list of numbers (of at least two elements), apply a linear transform to that list,
// such that the smallest number will become 0 and the largest will become 1
// >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
// [0.0, 0.25,... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_21_rescale_to_unit.py | verbatim | }
def main(args: Array[String]) = {
assert(rescaleToUnit((List[Float](2.0f.toFloat, 49.9f.toFloat))).equals((List[Float](0.0f.toFloat, 1.0f.toFloat))));
assert(rescaleToUnit((List[Float](100.0f.toFloat, 49.9f.toFloat))).equals((List[Float](1.0f.toFloat, 0.0f.toFloat))));
assert(rescaleToUnit((List[F... | [
"\n }\n"
] |
HumanEval_22_filter_integers | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Filter given list of any python values only for integers
// >>> filter_integers(['a', 3.14, 5])
// [5]
// >>> filter_integers([1, 2, 3, 'abc', {}, []])
// [1, 2, 3]
def filterIntegers(values : List[Any]) : List[Long] = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_22_filter_integers.py | verbatim | }
def main(args: Array[String]) = {
assert(filterIntegers((List[Any]())).equals((List[Long]())));
assert(filterIntegers((List[Any](4l, Map[Long,Long](), List[Long](), 23.2f, 9l, "adasd"))).equals((List[Long](4l.toLong, 9l.toLong))));
assert(filterIntegers((List[Any](3l, "c", 3l, 3l, "a", "b"))).equa... | [
"\n }\n"
] |
HumanEval_23_strlen | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return length of given string
// >>> strlen('')
// 0
// >>> strlen('abc')
// 3
def strlen(string : String) : Long = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_23_strlen.py | verbatim | }
def main(args: Array[String]) = {
assert(strlen(("")) == (0l));
assert(strlen(("x")) == (1l));
assert(strlen(("asdasnakj")) == (9l));
}
}
| [
"\n }\n"
] |
HumanEval_24_largest_divisor | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// For a given number n, find the largest number that divides n evenly, smaller than n
// >>> largest_divisor(15)
// 5
def largestDivisor(n : Long) : Long = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_24_largest_divisor.py | verbatim | }
def main(args: Array[String]) = {
assert(largestDivisor((3l)) == (1l));
assert(largestDivisor((7l)) == (1l));
assert(largestDivisor((10l)) == (5l));
assert(largestDivisor((100l)) == (50l));
assert(largestDivisor((49l)) == (7l));
}
}
| [
"\n }\n"
] |
HumanEval_25_factorize | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_25_factorize.py | verbatim | }
def main(args: Array[String]) = {
assert(factorize((2l)).equals((List[Long](2l.toLong))));
assert(factorize((4l)).equals((List[Long](2l.toLong, 2l.toLong))));
assert(factorize((8l)).equals((List[Long](2l.toLong, 2l.toLong, 2l.toLong))));
assert(factorize((57l)).equals((List[Long](3l.toLong, 19... | [
"\n }\n"
] |
HumanEval_26_remove_duplicates | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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]
def removeDuplicates(numbers : List[Long])... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_26_remove_duplicates.py | verbatim | }
def main(args: Array[String]) = {
assert(removeDuplicates((List[Long]())).equals((List[Long]())));
assert(removeDuplicates((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong))).equals((List[Long](1l.toLong, 2l.toLong, 3l.toLong, 4l.toLong))));
assert(removeDuplicates((List[Long](1l.toLong, 2l.... | [
"\n }\n"
] |
HumanEval_27_flip_case | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// >>> flip_case('Hello')
// 'hELLO'
def flipCase(string : String) : String = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_27_flip_case.py | verbatim | }
def main(args: Array[String]) = {
assert(flipCase(("")).equals(("")));
assert(flipCase(("Hello!")).equals(("hELLO!")));
assert(flipCase(("These violent delights have violent ends")).equals(("tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS")));
}
}
| [
"\n }\n"
] |
HumanEval_28_concatenate | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Concatenate list of strings into a single string
// >>> concatenate([])
// ''
// >>> concatenate(['a', 'b', 'c'])
// 'abc'
def concatenate(strings : List[String]) : String = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_28_concatenate.py | verbatim | }
def main(args: Array[String]) = {
assert(concatenate((List[String]())).equals(("")));
assert(concatenate((List[String]("x", "y", "z"))).equals(("xyz")));
assert(concatenate((List[String]("x", "y", "z", "w", "k"))).equals(("xyzwk")));
}
}
| [
"\n }\n"
] |
HumanEval_29_filter_by_prefix | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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']
def filterByPrefix(strin... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_29_filter_by_prefix.py | verbatim | }
def main(args: Array[String]) = {
assert(filterByPrefix((List[String]()), ("john")).equals((List[String]())));
assert(filterByPrefix((List[String]("xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx")), ("xxx")).equals((List[String]("xxx", "xxxAAA", "xxx"))));
}
}
| [
"\n }\n"
] |
HumanEval_2_truncate_number | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_2_truncate_number.py | verbatim | }
def main(args: Array[String]) = {
assert(truncateNumber((3.5f)) == (0.5f));
assert(truncateNumber((1.25f)) == (0.25f));
assert(truncateNumber((123.0f)) == (0.0f));
}
}
| [
"\n }\n"
] |
HumanEval_30_get_positive | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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]
def getPositive(l : List[Long]) : List[L... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_30_get_positive.py | verbatim | }
def main(args: Array[String]) = {
assert(getPositive((List[Long](-1l.toLong, -2l.toLong, 4l.toLong, 5l.toLong, 6l.toLong))).equals((List[Long](4l.toLong, 5l.toLong, 6l.toLong))));
assert(getPositive((List[Long](5l.toLong, 3l.toLong, -5l.toLong, 2l.toLong, 3l.toLong, 3l.toLong, 9l.toLong, 0l.toLong, 12... | [
"\n }\n"
] |
HumanEval_31_is_prime | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// 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)
// Tr... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_31_is_prime.py | verbatim | }
def main(args: Array[String]) = {
assert(isPrime((6l)) == (false));
assert(isPrime((101l)) == (true));
assert(isPrime((11l)) == (true));
assert(isPrime((13441l)) == (true));
assert(isPrime((61l)) == (true));
assert(isPrime((4l)) == (false));
assert(isPrime((1l)) == (false));
as... | [
"\n }\n"
] |
HumanEval_33_sort_third | 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 indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corre... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_33_sort_third.py | verbatim | }
def main(args: Array[String]) = {
assert(sortThird((List[Long](5l.toLong, 6l.toLong, 3l.toLong, 4l.toLong, 8l.toLong, 9l.toLong, 2l.toLong))).equals((List[Long](2l.toLong, 6l.toLong, 3l.toLong, 4l.toLong, 8l.toLong, 9l.toLong, 5l.toLong))));
assert(sortThird((List[Long](5l.toLong, 8l.toLong, 3l.toLong... | [
"\n }\n"
] |
HumanEval_34_unique | scala | import scala.math._
import scala.collection.mutable._
object Problem {
// Return sorted unique elements in a list
// >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
// [0, 2, 3, 5, 9, 123]
def unique(l : List[Long]) : List[Long] = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_34_unique.py | verbatim | }
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.
// >>> max_element([1, 2, 3])
// 3
// >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
// 123
def maxElement(l : List[Long]) : Long = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_35_max_element.py | verbatim | }
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.
// >>> fizz_buzz(50)
// 0
// >>> fizz_buzz(78)
// 2
// >>> fizz_buzz(79)
// 3
def fizzBuzz(n : Long) : Long = ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_36_fizz_buzz.py | verbatim | }
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.
// >>> sort_even([1,... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_37_sort_even.py | verbatim | }
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.
// >>> prime_fib(1)
// 2
// >>> prime_fib(2)
// 3
// >>> prime_fib(3)
// 5
// >>> prime_fib(4)
// 13
// >>> prime_fib(5)
// ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_39_prime_fib.py | verbatim | }
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 ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_3_below_zero.py | verbatim | }
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.
// >>> triples_sum_to_zero([1, 3, 5, 0])
// False
// >... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_40_triples_sum_to_zero.py | verbatim | }
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
//... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_41_car_race_collision.py | verbatim | }
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.
// >>> incr_list([1, 2, 3])
// [2, 3, 4]
// >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
// [6, 4, 6, 3, 4, 4, 10, 1, 124]
def incrList(l : List[Long]) : List[Long] = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_42_incr_list.py | verbatim | }
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.
// >>> pairs_sum_to_zero([1, 3, 5, 0])
// False
// >>> pai... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_43_pairs_sum_to_zero.py | verbatim | }
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.
// >>> change_base(8, 3)
// '22'
// >>> change_base(8, 2)
// '1000'
// >>> ch... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_44_change_base.py | verbatim | }
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.
// >>> triangle_area(5, 3)
// 7.5
def triangleArea(a : Long, h : Long) : Float = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_45_triangle_area.py | verbatim | }
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-... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_46_fib4.py | verbatim | }
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([3, 1, 2, 4, 5])
// 3
// >>> median([-10, 4, 6, 1000, 10, 20])
// 15.0
def median(l : List[Long]) : Float = {
| keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_47_median.py | verbatim | }
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
// >>> is_palindrome('')
// True
// >>> is_palindrome('aba')
// True
// >>> is_palindrome('aaaaa')
// True
// >>> is_palindrome('zbcd')
// False
def isPalindrome(text ... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_48_is_palindrome.py | verbatim | }
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(3, 5)
// 3
// >>> modp(1101, 101)
// 2
// >>> modp(0, 101)
// 1
// >>> modp(3, 11)
// 8
// >>> modp(100, 101)
// 1
def modp(n : Long, p : Long... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_49_modp.py | verbatim | }
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):
... | keep | /home/arjun/repos/nuprl/MultiPL-E/datasets/../datasets/originals/HumanEval_4_mean_absolute_deviation.py | verbatim | }
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"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.