task_id
stringlengths
2
30
buggy_code
stringlengths
137
2.23k
fixed_code
stringlengths
137
2.23k
unit_tests
stringlengths
549
3.38M
median
package humaneval.buggy; import java.util.Arrays; /* Return median of elements in the list l. >>> median([3, 1, 2, 4, 5]) 3 >>> median([-10, 4, 6, 1000, 10, 20]) 15.0 */ public class MEDIAN { public static double median(int[] list) { Arrays.sort(list); if (list.length % 2 == 1) { ret...
package humaneval.buggy; import java.util.Arrays; /* Return median of elements in the list l. >>> median([3, 1, 2, 4, 5]) 3 >>> median([-10, 4, 6, 1000, 10, 20]) 15.0 */ public class MEDIAN { public static double median(int[] list) { Arrays.sort(list); if (list.length % 2 == 1) { ret...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_MEDIAN { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { double result = humaneval.buggy.MEDIAN.median( new int[] {3,...
select_words
package humaneval.buggy; import java.util.ArrayList; /* * Given a string s and a natural number n, you have been tasked to implement a function that returns a list of all words from string s that contain exactly n consonants, in order these words appear in the string s. If the string s is empty then th...
package humaneval.buggy; import java.util.ArrayList; /* * Given a string s and a natural number n, you have been tasked to implement a function that returns a list of all words from string s that contain exactly n consonants, in order these words appear in the string s. If the string s is empty then th...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_SELECT_WORDS { @org.junit.Test(timeout=1000) public void test_0() throws java.lang.Exception { ArrayList<String> result = humaneval.buggy.SELECT_WORDS.select_words("...
largest_prime_factor
package humaneval.buggy; // Return the largest prime factor of n. Assume n > 1 and is not a prime. // >>> largest_prime_factor(13195) // 29 // >>> largest_prime_factor(2048) // 2 public class LARGEST_PRIME_FACTOR { public static boolean is_prime(int k) { if (k < 2) return false; for (i...
package humaneval.buggy; // Return the largest prime factor of n. Assume n > 1 and is not a prime. // >>> largest_prime_factor(13195) // 29 // >>> largest_prime_factor(2048) // 2 public class LARGEST_PRIME_FACTOR { public static boolean is_prime(int k) { if (k < 2) return false; for (i...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_LARGEST_PRIME_FACTOR { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.LARGEST_PRIME_FACTOR.largest_...
eat
package humaneval.buggy; // You're a hungry rabbit, and you already have eaten a certain number of carrots, // but now you need to eat more carrots to complete the day's meals. // you should return an array of [ total number of eaten carrots after your meals, // the number of carrots le...
package humaneval.buggy; // You're a hungry rabbit, and you already have eaten a certain number of carrots, // but now you need to eat more carrots to complete the day's meals. // you should return an array of [ total number of eaten carrots after your meals, // the number of carrots le...
package humaneval; public class TEST_EAT { @org.junit.Test(timeout = 3000) public void test_0() throws java.lang.Exception { int[] result = humaneval.buggy.EAT.eat(5, 6, 10); org.junit.Assert.assertArrayEquals( result, new int[] {11, 4} ); } @org.junit.Test(timeout ...
factorize
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class FACTORIZE { public static List<Integer> factorize(int n){ List<Integer> result = new ArrayList<Integer>(); int i = 2; while (i <= (int)(Math.sqrt(n) + 1)){ if (n % i == 0){ ...
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class FACTORIZE { public static List<Integer> factorize(int n){ List<Integer> result = new ArrayList<Integer>(); int i = 2; while (i <= (int)(Math.sqrt(n) + 1)){ if (n % i == 0){ ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_FACTORIZE { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<Integer> result = humaneval.buggy.FACTORIZE.factorize(2); ...
largest_divisor
package humaneval.buggy; public class LARGEST_DIVISOR { public static int largest_divisor(int n) { for (int i = n; i >= 0; i -= 1){ if (n % i == 0) return i; } return 1; } }
package humaneval.buggy; public class LARGEST_DIVISOR { public static int largest_divisor(int n) { for (int i = n; i >= 0; i -= 1){ if (n % i == 0) return i; } return 1; } }
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_LARGEST_DIVISOR { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.LARGEST_DIVISOR.largest_divisor(3)...
do_algebra
package humaneval.buggy; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; // 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 ...
package humaneval.buggy; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; // 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 ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_DO_ALGEBRA { @org.junit.Test(timeout = 1000) public void test_1() throws java.lang.Exception { double result = humaneval.buggy.DO_ALGEBRA.do_algebra( n...
triangle_area_2
package humaneval.buggy; import java.math.BigDecimal; import java.math.RoundingMode; /* Given the lengths of the three sides of a triangle. Return the area of the triangle rounded to 2 decimal points if the three sides form a valid triangle. Otherwise return -1 Three sides make a valid triangle when the sum of any t...
package humaneval.buggy; import java.math.BigDecimal; import java.math.RoundingMode; /* Given the lengths of the three sides of a triangle. Return the area of the triangle rounded to 2 decimal points if the three sides form a valid triangle. Otherwise return -1 Three sides make a valid triangle when the sum of any t...
package humaneval; public class TEST_TRIANGLE_AREA_2 { @org.junit.Test(timeout = 3000) public void test_0() throws java.lang.Exception { double result = humaneval.buggy.TRIANGLE_AREA_2.triangle_area_2(3, 4, 5); org.junit.Assert.assertEquals( result, 6, 1e-6 ); } @or...
max_fill
package humaneval.buggy; /* * You are given a rectangular grid of wells. Each row represents a single well, and each 1 in a row represents a single unit of water. Each well has a corresponding bucket that can be used to extract water from it, and all buckets have the same capacity. Your task is to us...
package humaneval.buggy; /* * You are given a rectangular grid of wells. Each row represents a single well, and each 1 in a row represents a single unit of water. Each well has a corresponding bucket that can be used to extract water from it, and all buckets have the same capacity. Your task is to us...
package humaneval; public class TEST_MAX_FILL { @org.junit.Test(timeout=3000) public void test_0() throws java.lang.Exception { int[][] input = {{0,0,1,0}, {0,1,0,0}, {1,1,1,1}}; int result = humaneval.buggy.MAX_FILL.max_fill(input, 1); org.junit.Assert.assertEquals(6, result); } ...
find_max
package humaneval.buggy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; // 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 ...
package humaneval.buggy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; // 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 ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_FIND_MAX { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { String result = humaneval.buggy.FIND_MAX.find_max( new Str...
is_prime
package humaneval.buggy; public class IS_PRIME { public static boolean is_prime(int n){ if (n < 2) return false; for (int k = 0; k < n; k += 1){ if (n % k == 0) return false; } return true; } }
package humaneval.buggy; public class IS_PRIME { public static boolean is_prime(int n){ if (n < 2) return false; for (int k = 0; k < n; k += 1){ if (n % k == 0) return false; } return true; } }
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_IS_PRIME { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { boolean result = humaneval.buggy.IS_PRIME.is_prime(6); org.jun...
prod_signs
package humaneval.buggy; /* * 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 -10 for empty arr. Example: >>> prod_signs([1, 2, 2, -4]) == -9 >>>...
package humaneval.buggy; /* * 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 -10 for empty arr. Example: >>> prod_signs([1, 2, 2, -4]) == -9 >>>...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_PROD_SIGNS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int[] arr = {1,2,2,-4}; org.junit.Assert.assertEquals(-9, huma...
will_it_fly
package humaneval.buggy; /* Write a function that returns True if the object q will fly, and False otherwise. The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w. Example: will_it_fly([1, 2], 5) ➞ False # 1+2 is less than t...
package humaneval.buggy; /* Write a function that returns True if the object q will fly, and False otherwise. The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w. Example: will_it_fly([1, 2], 5) ➞ False # 1+2 is less than t...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_WILL_IT_FLY { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { boolean result = humaneval.buggy.WILL_IT_FLY.will_it_fly(new int[] ...
histogram
package humaneval.buggy; import java.util.HashMap; /* * Given a string representing a space separated lowercase letters, return a dictionary of the letter with the most repetition and containing the corresponding count. If several letters have the same occurrence, return all of them. Example: hi...
package humaneval.buggy; import java.util.HashMap; /* * Given a string representing a space separated lowercase letters, return a dictionary of the letter with the most repetition and containing the corresponding count. If several letters have the same occurrence, return all of them. Example: hi...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_HISTOGRAM { @org.junit.Test(timeout = 3000) public void test_0() throws java.lang.Exception { HashMap<Character, Integer> result = humaneval.buggy.HISTOGRAM.histogram("a b b a")...
strongest_extension
package humaneval.buggy; // You will be given the name of a class (a string) and a list of extensions. // The extensions are to be used to load additional classes to the class. The // strength of the extension is as follows: Let CAP be the number of the uppercase // letters in the extension's name, and let SM be the n...
package humaneval.buggy; // You will be given the name of a class (a string) and a list of extensions. // The extensions are to be used to load additional classes to the class. The // strength of the extension is as follows: Let CAP be the number of the uppercase // letters in the extension's name, and let SM be the n...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_STRONGEST_EXTENSION { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { String result = humaneval.buggy.STRONGEST_EXTENSION.stronge...
fib
package humaneval.buggy; /* Return n-th Fibonacci number. >>> fib(10) 55 >>> fib(1) 1 >>> fib(8) 21 */ public class FIB { public static int fib(int n) { return fib(n - 1) + fib(n - 2); } }
package humaneval.buggy; /* Return n-th Fibonacci number. >>> fib(10) 55 >>> fib(1) 1 >>> fib(8) 21 */ public class FIB { public static int fib(int n) { return fib(n - 1) + fib(n - 2); } }
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_FIB { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.FIB.fib(10); org.junit.Assert.assertEq...
skjkasdkd
package humaneval.buggy; // You are given a list of integers. // You need to find the largest prime value and return the sum of its digits. // Examples: // For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10 // For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be...
package humaneval.buggy; // You are given a list of integers. // You need to find the largest prime value and return the sum of its digits. // Examples: // For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10 // For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_SKJKASDKD { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.SKJKASDKD.skjkasdkd(new int[] {0,3,2,1,3...
find_closest_elements
package humaneval.buggy; public class FIND_CLOSEST_ELEMENTS { public static double[] find_closest_elements(double[] numbers) { double[] result = new double[2]; double distance = Double.MAX_VALUE; for (int i = 0; i < numbers.length; i += 1){ for (int j = 0; j < numbers.length; j...
package humaneval.buggy; public class FIND_CLOSEST_ELEMENTS { public static double[] find_closest_elements(double[] numbers) { double[] result = new double[2]; double distance = Double.MAX_VALUE; for (int i = 0; i < numbers.length; i += 1){ for (int j = 0; j < numbers.length; j...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_FIND_CLOSEST_ELEMENTS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { double[] result = humaneval.buggy.FIND_CLOSEST_ELEMENTS.f...
sort_numbers
package humaneval.buggy; import java.util.*; public class SORT_NUMBERS { public static String sort_numbers(String numbers) { final HashMap<String, Integer> value_map = new HashMap<String, Integer>(); value_map.put("zero", 0); value_map.put("one", 1); value_map.put("two", 2); ...
package humaneval.buggy; import java.util.*; public class SORT_NUMBERS { public static String sort_numbers(String numbers) { final HashMap<String, Integer> value_map = new HashMap<String, Integer>(); value_map.put("zero", 0); value_map.put("one", 1); value_map.put("two", 2); ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_SORT_NUMBERS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { String result = humaneval.buggy.SORT_NUMBERS.sort_numbers(""); ...
reverse_delete
package humaneval.buggy; import java.util.ArrayList; /* * We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c then check if the result string is palindrome. A string is called palindrome if it reads the same backward as forward. You should re...
package humaneval.buggy; import java.util.ArrayList; /* * We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c then check if the result string is palindrome. A string is called palindrome if it reads the same backward as forward. You should re...
package humaneval; import java.util.ArrayList; import java.util.Arrays; public class TEST_REVERSE_DELETE { @org.junit.Test(timeout=3000) public void test_0() throws java.lang.Exception { ArrayList<Object> result = humaneval.buggy.REVERSE_DELETE.reverse_delete("abcde", "ae"); ArrayList<Object> ...
add
package humaneval.buggy; /* Add two numbers x and y >>> add(2, 3) 5 >>> add(5, 7) 12 */ public class ADD { public static int add(int x, int y) { return x | y; } }
package humaneval.buggy; /* Add two numbers x and y >>> add(2, 3) 5 >>> add(5, 7) 12 */ public class ADD { public static int add(int x, int y) { return x | y; } }
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_ADD { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.ADD.add(0, 1); org.junit.Assert.assert...
is_sorted
package humaneval.buggy; import java.util.HashMap; /* * Given a list of numbers, return whether or not they are sorted in ascending order. If list has more than 1 duplicate of the same number, return False. Assume no negative numbers and only integers. Examples is_sorted([5]) ➞ True is_sorted([1...
package humaneval.buggy; import java.util.HashMap; /* * Given a list of numbers, return whether or not they are sorted in ascending order. If list has more than 1 duplicate of the same number, return False. Assume no negative numbers and only integers. Examples is_sorted([5]) ➞ True is_sorted([1...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_IS_SORTED { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int[] input = {5}; org.junit.Assert.assertEquals(true, humane...
count_up_to
package humaneval.buggy; import java.util.ArrayList; import java.util.List; // Implement a function that takes an non-negative integer and returns an array of the first n // integers that are prime numbers and less than n. // for example: // count_up_to(5) => [2,3] // count_up_to(11) => [2,3,5,7] // count_up_to(0) =>...
package humaneval.buggy; import java.util.ArrayList; import java.util.List; // Implement a function that takes an non-negative integer and returns an array of the first n // integers that are prime numbers and less than n. // for example: // count_up_to(5) => [2,3] // count_up_to(11) => [2,3,5,7] // count_up_to(0) =>...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_COUNT_UP_TO { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<Integer> result = humaneval.buggy.COUNT_UP_TO.count_up_to(5); ...
match_parens
package humaneval.buggy; /* * You are given a list of two strings, both strings consist of open parentheses '(' or close parentheses ')' only. Your job is to check if it is possible to concatenate the two strings in some order, that the resulting string will be good. A string S is considered to be goo...
package humaneval.buggy; /* * You are given a list of two strings, both strings consist of open parentheses '(' or close parentheses ')' only. Your job is to check if it is possible to concatenate the two strings in some order, that the resulting string will be good. A string S is considered to be goo...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_MATCH_PARENS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { String[] input = {"()(",")"}; String result = humaneval.bu...
odd_count
package humaneval.buggy; import java.util.ArrayList; /* * Given a list of strings, where each string consists of only digits, return a list. Each element i of the output should be "the number of odd elements in the string i of the input." where all the i's should be replaced by the number of odd digits i...
package humaneval.buggy; import java.util.ArrayList; /* * Given a list of strings, where each string consists of only digits, return a list. Each element i of the output should be "the number of odd elements in the string i of the input." where all the i's should be replaced by the number of odd digits i...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_ODD_COUNT { @org.junit.Test(timeout=1000) public void test_0() throws java.lang.Exception { ArrayList<String> input = new ArrayList<>(Arrays.asList("1234567")); ...
count_nums
package humaneval.buggy; import java.util.ArrayList; public class COUNT_NUMS { public static int count_nums(ArrayList<Integer> arr) { int count = 0; for(int num : arr) { boolean neg = num < 0; if(neg) num *= 1; String num_string = Integer.toString(num); ...
package humaneval.buggy; import java.util.ArrayList; public class COUNT_NUMS { public static int count_nums(ArrayList<Integer> arr) { int count = 0; for(int num : arr) { boolean neg = num < 0; if(neg) num *= 1; String num_string = Integer.toString(num); ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_COUNT_NUMS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { ArrayList<Integer> input = new ArrayList<>(Arrays.asList()); in...
parse_music
package humaneval.buggy; import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class PARSE_MUSIC { public static List<Integer> parse_music(String music_string) { HashMap<String, Integer> note_map = new HashMap<String, Integer>(); note_map.put("o", 4); note_map...
package humaneval.buggy; import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class PARSE_MUSIC { public static List<Integer> parse_music(String music_string) { HashMap<String, Integer> note_map = new HashMap<String, Integer>(); note_map.put("o", 4); note_map...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_PARSE_MUSIC { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<Integer> result = humaneval.buggy.PARSE_MUSIC.parse_music("");...
next_smallest
package humaneval.buggy; import java.util.*; /* You are given a list of integers. Write a function next_smallest() that returns the 2nd smallest element of the list. Return None if there is no such element. next_smallest([1, 2, 3, 4, 5]) == 2 next_smallest([5, 1, 4, 3, 2]) == 2 next_smallest([]) == None next_smalles...
package humaneval.buggy; import java.util.*; /* You are given a list of integers. Write a function next_smallest() that returns the 2nd smallest element of the list. Return None if there is no such element. next_smallest([1, 2, 3, 4, 5]) == 2 next_smallest([5, 1, 4, 3, 2]) == 2 next_smallest([]) == None next_smalles...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_NEXT_SMALLEST { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { Integer result = humaneval.buggy.NEXT_SMALLEST.next_smallest(new in...
filter_by_substring
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class FILTER_BY_SUBSTRING { public static List<String> filter_by_substring(List<String> strings, String substring) { List<String> result = new ArrayList<String>(); for (String string : strings){ result.a...
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class FILTER_BY_SUBSTRING { public static List<String> filter_by_substring(List<String> strings, String substring) { List<String> result = new ArrayList<String>(); for (String string : strings){ result.a...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_FILTER_BY_SUBSTRING { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<String> result = humaneval.buggy.FILTER_BY_SUBSTRING.f...
pluck
package humaneval.buggy; /* Given an array representing a branch of a tree that has non-negative integer nodes your task is to pluck one of the nodes and return it. The plucked node should be the node with the smallest even value. If multiple nodes with the same smallest even value are found return the node that has s...
package humaneval.buggy; /* Given an array representing a branch of a tree that has non-negative integer nodes your task is to pluck one of the nodes and return it. The plucked node should be the node with the smallest even value. If multiple nodes with the same smallest even value are found return the node that has s...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_PLUCK { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int[] result = humaneval.buggy.PLUCK.pluck(new int[] {4,2,3}); or...
even_odd_palindrome
package humaneval.buggy; import java.util.ArrayList; import java.util.Arrays; /* * 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: ...
package humaneval.buggy; import java.util.ArrayList; import java.util.Arrays; /* * 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: ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_EVEN_ODD_PALINDROME { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { ArrayList<Integer> result = humaneval.buggy.EVEN_ODD_PALIND...
strlen
package humaneval.buggy; public class STRLEN { public static int strlen(String string){ return string.length() - 1; } }
package humaneval.buggy; public class STRLEN { public static int strlen(String string){ return string.length() - 1; } }
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_STRLEN { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.STRLEN.strlen(""); org.junit.Assert...
separate_paren_groups
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class SEPARATE_PAREN_GROUPS { public static List<String> separate_paren_groups(String paren_string) { List<String> result = new ArrayList<String>(); String current_string = ""; int current_depth = 0; ...
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class SEPARATE_PAREN_GROUPS { public static List<String> separate_paren_groups(String paren_string) { List<String> result = new ArrayList<String>(); String current_string = ""; int current_depth = 0; ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_SEPARATE_PAREN_GROUPS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<String> result = humaneval.buggy.SEPARATE_PAREN_GROU...
same_chars
package humaneval.buggy; import java.util.*; /* Check if two words have the same characters. >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc') True >>> same_chars('abcd', 'dddddddabc') True >>> same_chars('dddddddabc', 'abcd') True >>> same_chars('eabcd', 'dddddddabc') False >>> same_chars('abcd', 'dddddddabce') Fals...
package humaneval.buggy; import java.util.*; /* Check if two words have the same characters. >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc') True >>> same_chars('abcd', 'dddddddabc') True >>> same_chars('dddddddabc', 'abcd') True >>> same_chars('eabcd', 'dddddddabc') False >>> same_chars('abcd', 'dddddddabce') Fals...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_SAME_CHARS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { boolean result = humaneval.buggy.SAME_CHARS.same_chars("eabcdzzzz", ...
remove_duplicates
package humaneval.buggy; import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class REMOVE_DUPLICATES { public static List<Integer> remove_duplicates(List<Integer> numbers) { List<Integer> result = new ArrayList<Integer>(); HashMap<Integer, Integer> count = new HashM...
package humaneval.buggy; import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class REMOVE_DUPLICATES { public static List<Integer> remove_duplicates(List<Integer> numbers) { List<Integer> result = new ArrayList<Integer>(); HashMap<Integer, Integer> count = new HashM...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_REMOVE_DUPLICATES { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<Integer> result = humaneval.buggy.REMOVE_DUPLICATES.remo...
order_by_points
package humaneval.buggy; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; /* 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 ...
package humaneval.buggy; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; /* 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 ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_ORDER_BY_POINTS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { Integer[] result = humaneval.buggy.ORDER_BY_POINTS.order_by_point...
even_odd_count
package humaneval.buggy; // 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) public class EVEN_ODD_COUNT { public static int[] even_odd_count(int num) { int even_count = 0;...
package humaneval.buggy; // 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) public class EVEN_ODD_COUNT { public static int[] even_odd_count(int num) { int even_count = 0;...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_EVEN_ODD_COUNT { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int[] result = humaneval.buggy.EVEN_ODD_COUNT.even_odd_count(7);...
closest_integer
package humaneval.buggy; // Create a function that takes a value (string) representing a number // and returns the closest integer to it. If the number is equidistant // from two integers, round it away from zero. // Examples // >>> closest_integer("10") // 10 // >>> closest_integer("15.3") // 15 // Note: // Roundin...
package humaneval.buggy; // Create a function that takes a value (string) representing a number // and returns the closest integer to it. If the number is equidistant // from two integers, round it away from zero. // Examples // >>> closest_integer("10") // 10 // >>> closest_integer("15.3") // 15 // Note: // Roundin...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_CLOSEST_INTEGER { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.CLOSEST_INTEGER.closest_integer("1...
filter_integers
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class FILTER_INTEGERS { public static List<Integer> filter_integers(List<Object> values) { List<Integer> result = new ArrayList<Integer>(); for (Object value : values){ result.add((Integer) value); ...
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class FILTER_INTEGERS { public static List<Integer> filter_integers(List<Object> values) { List<Integer> result = new ArrayList<Integer>(); for (Object value : values){ result.add((Integer) value); ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_FILTER_INTEGERS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<Integer> result = humaneval.buggy.FILTER_INTEGERS.filter_int...
tri
package humaneval.buggy; /* * Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in the last couple centuries. However, what people don't know is Tribonacci sequence. Tribonacci sequence is defined by the recurrence: tri(1) = 3 tri(n) = 1 + n / 2, if n is even. tri(n) = t...
package humaneval.buggy; /* * Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in the last couple centuries. However, what people don't know is Tribonacci sequence. Tribonacci sequence is defined by the recurrence: tri(1) = 3 tri(n) = 1 + n / 2, if n is even. tri(n) = t...
package humaneval; public class TEST_TRI { @org.junit.Test(timeout = 3000) public void test_0() throws java.lang.Exception { int[] result = humaneval.buggy.TRI.tri(3); int[] desired = {1, 3, 2, 8}; org.junit.Assert.assertArrayEquals(desired, result); } @org.junit.Test(timeout = ...
bf
package humaneval.buggy; import java.util.ArrayList; import java.util.Arrays; /* There are eight planets in our solar system: the closerst to the Sun is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, Uranus, Neptune. Write a function that takes two planet names as strings planet1 and planet2. T...
package humaneval.buggy; import java.util.ArrayList; import java.util.Arrays; /* There are eight planets in our solar system: the closerst to the Sun is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, Uranus, Neptune. Write a function that takes two planet names as strings planet1 and planet2. T...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_BF { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { ArrayList<String> result = humaneval.buggy.BF.bf("Jupiter", "Neptune"); ...
valid_date
package humaneval.buggy; /* * You have to write a function which validates a given date string and returns True if the date is valid otherwise False. The date is valid if all of the following rules are satisfied: 1. The date string is not empty. 2. The number of days is not less than 1 or higher than ...
package humaneval.buggy; /* * You have to write a function which validates a given date string and returns True if the date is valid otherwise False. The date is valid if all of the following rules are satisfied: 1. The date string is not empty. 2. The number of days is not less than 1 or higher than ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_VALID_DATE { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { org.junit.Assert.assertEquals(true, humaneval.buggy.VALID_DATE.valid_d...
rolling_max
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class ROLLING_MAX { public static List<Integer> rolling_max(List<Integer> numbers) { List<Integer> result = new ArrayList<Integer>(); Integer running_max = null; for (Integer n : numbers){ runni...
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class ROLLING_MAX { public static List<Integer> rolling_max(List<Integer> numbers) { List<Integer> result = new ArrayList<Integer>(); Integer running_max = null; for (Integer n : numbers){ runni...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_ROLLING_MAX { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<Integer> result = humaneval.buggy.ROLLING_MAX.rolling_max( ...
count_upper
package humaneval.buggy; // Given a string s, count the number of uppercase vowels in even indices. // For example: // count_upper('aBCdEf') returns 1 // count_upper('abcdefg') returns 0 // count_upper('dBBE') returns 0 public class COUNT_UPPER { public static int count_upper(String s) { int count = 0; ...
package humaneval.buggy; // Given a string s, count the number of uppercase vowels in even indices. // For example: // count_upper('aBCdEf') returns 1 // count_upper('abcdefg') returns 0 // count_upper('dBBE') returns 0 public class COUNT_UPPER { public static int count_upper(String s) { int count = 0; ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_COUNT_UPPER { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.COUNT_UPPER.count_upper("aBCdEf"); ...
smallest_change
package humaneval.buggy; // Given an array arr of integers, find the minimum number of elements that // need to be changed to make the array palindromic. A palindromic array is an array that // is read the same backwards and forwards. In one change, you can change one element to any other element. // For example: // ...
package humaneval.buggy; // Given an array arr of integers, find the minimum number of elements that // need to be changed to make the array palindromic. A palindromic array is an array that // is read the same backwards and forwards. In one change, you can change one element to any other element. // For example: // ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_SMALLEST_CHANGE { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.SMALLEST_CHANGE.smallest_change(ne...
strange_sort_list
package humaneval.buggy; import java.util.ArrayList; import java.util.Collections; import java.util.List; /* 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: strange_sort_list([1,...
package humaneval.buggy; import java.util.ArrayList; import java.util.Collections; import java.util.List; /* 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: strange_sort_list([1,...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_STRANGE_SORT_LIST { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<Integer> result = humaneval.buggy.STRANGE_SORT_LIST.stra...
is_palindrome
package humaneval.buggy; /* Checks if given string is a palindrome >>> is_palindrome('') True >>> is_palindrome('aba') True >>> is_palindrome('aaaaa') True >>> is_palindrome('zbcd') False */ public class IS_PALINDROME { public static boolean is_palindrome(String text) { for (int i = 0; i < text.length(); ...
package humaneval.buggy; /* Checks if given string is a palindrome >>> is_palindrome('') True >>> is_palindrome('aba') True >>> is_palindrome('aaaaa') True >>> is_palindrome('zbcd') False */ public class IS_PALINDROME { public static boolean is_palindrome(String text) { for (int i = 0; i < text.length(); ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_IS_PALINDROME { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { boolean result = humaneval.buggy.IS_PALINDROME.is_palindrome("");...
add_elements
package humaneval.buggy; import java.util.ArrayList; /* * 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. Assume that the negative sign counts as a digit, e.g. -5 has two digits Example: Input: ar...
package humaneval.buggy; import java.util.ArrayList; /* * 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. Assume that the negative sign counts as a digit, e.g. -5 has two digits Example: Input: ar...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_ADD_ELEMENTS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { ArrayList<Integer> input = new ArrayList<>(Arrays.asList(1,-2,-3,4...
parse_nested_parens
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class PARSE_NESTED_PARENS { public static List<Integer> parse_nested_parens(String paren_string) { String[] paren_groups = paren_string.split(" "); List<Integer> result = new ArrayList<Integer>(); for (Stri...
package humaneval.buggy; import java.util.ArrayList; import java.util.List; public class PARSE_NESTED_PARENS { public static List<Integer> parse_nested_parens(String paren_string) { String[] paren_groups = paren_string.split(" "); List<Integer> result = new ArrayList<Integer>(); for (Stri...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_PARSE_NESTED_PARENS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { List<Integer> result = humaneval.buggy.PARSE_NESTED_PARENS.pa...
compare_one
package humaneval.buggy; /* * Create a function that takes integers, floats, or strings representing real numbers, and returns the larger variable in its given variable type. Return None if the values are equal. Note: If a real number is represented as a string, the floating point might be . or , com...
package humaneval.buggy; /* * Create a function that takes integers, floats, or strings representing real numbers, and returns the larger variable in its given variable type. Return None if the values are equal. Note: If a real number is represented as a string, the floating point might be . or , com...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_COMPARE_ONE { @org.junit.Test(timeout = 1000) public void test_8() throws java.lang.Exception { org.junit.Assert.assertEquals(3, humaneval.buggy.COMPARE_ONE.compar...
remove_vowels
package humaneval.buggy; /* remove_vowels is a function that takes string and returns string without vowels. >>> remove_vowels('') '' >>> remove_vowels("abcdef\nghijklm") 'bcdf\nghjklm' >>> remove_vowels('abcdef') 'bcdf' >>> remove_vowels('aaaaa') '' >>> remove_vowels('aaBAA') 'B' >>> remove_vowels('zbcd') 'zbcd' */ ...
package humaneval.buggy; /* remove_vowels is a function that takes string and returns string without vowels. >>> remove_vowels('') '' >>> remove_vowels("abcdef\nghijklm") 'bcdf\nghjklm' >>> remove_vowels('abcdef') 'bcdf' >>> remove_vowels('aaaaa') '' >>> remove_vowels('aaBAA') 'B' >>> remove_vowels('zbcd') 'zbcd' */ ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_REMOVE_VOWELS { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { String result = humaneval.buggy.REMOVE_VOWELS.remove_vowels(""); ...
double_the_difference
package humaneval.buggy; /* Given a list of numbers, return the sum of squares of the numbers in the list that are odd. Ignore numbers that are negative or not integers. double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10 double_the_difference([-1, -2, 0]) == 0 double_the_difference([9, -2]) == 81 double_the_di...
package humaneval.buggy; /* Given a list of numbers, return the sum of squares of the numbers in the list that are odd. Ignore numbers that are negative or not integers. double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10 double_the_difference([-1, -2, 0]) == 0 double_the_difference([9, -2]) == 81 double_the_di...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_DOUBLE_THE_DIFFERENCE { @org.junit.Test(timeout = 3000) public void test() throws java.lang.Exception { double[] inputs = new double[199]; int sum = 0; ...
add_even_at_odd
package humaneval.buggy; /* Given a non-empty list of integers lst. add the even elements that are at odd indices.. Examples: add([4, 2, 6, 7]) ==> 2 */ public class ADD_EVEN_AT_ODD { public static int add_even_at_odd(int[] lst) { int sum = 0; for (int i = 0; i < lst.length; i += 1) { ...
package humaneval.buggy; /* Given a non-empty list of integers lst. add the even elements that are at odd indices.. Examples: add([4, 2, 6, 7]) ==> 2 */ public class ADD_EVEN_AT_ODD { public static int add_even_at_odd(int[] lst) { int sum = 0; for (int i = 0; i < lst.length; i += 1) { ...
package humaneval; public class TEST_ADD_EVEN_AT_ODD { @org.junit.Test(timeout = 3000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.ADD_EVEN_AT_ODD.add_even_at_odd(new int[] {4, 88}); org.junit.Assert.assertEquals( result, 88 ); } @...
make_palindrome
package humaneval.buggy; public class MAKE_PALINDROME { public static boolean is_palindrome(String str){ for (int i = 0; i < str.length(); i += 1){ if (str.charAt(i) != str.charAt(str.length() - 1 - i)) return false; } return true; } public static String...
package humaneval.buggy; public class MAKE_PALINDROME { public static boolean is_palindrome(String str){ for (int i = 0; i < str.length(); i += 1){ if (str.charAt(i) != str.charAt(str.length() - 1 - i)) return false; } return true; } public static String...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_MAKE_PALINDROME { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { String result = humaneval.buggy.MAKE_PALINDROME.make_palindrome...
below_zero
package humaneval.buggy; import java.util.List; public class BELOW_ZERO { public static boolean below_zero(List<Integer> operations) { int balance = 0; for (Integer op : operations){ balance += op; if (balance > 0){ return false; } } ...
package humaneval.buggy; import java.util.List; public class BELOW_ZERO { public static boolean below_zero(List<Integer> operations) { int balance = 0; for (Integer op : operations){ balance += op; if (balance > 0){ return false; } } ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; public class TEST_BELOW_ZERO { @org.junit.Test(timeout = 3000) public void test_0() throws java.lang.Exception { boolean result = humaneval.buggy.BELOW_ZERO.below_zero( new ArrayList<Integer>() ); org.j...
solve
package humaneval.buggy; /* Given a positive integer N, return the total sum of its digits in binary. Example For N = 1000, the sum of digits will be 1 the output should be "1". For N = 150, the sum of digits will be 6 the output should be "110". For N = 147, the sum of digits will be 12 the output should...
package humaneval.buggy; /* Given a positive integer N, return the total sum of its digits in binary. Example For N = 1000, the sum of digits will be 1 the output should be "1". For N = 150, the sum of digits will be 6 the output should be "110". For N = 147, the sum of digits will be 12 the output should...
package humaneval; public class TEST_SOLVE { @org.junit.Test(timeout = 3000) public void test_0() throws java.lang.Exception { String result = humaneval.buggy.SOLVE.solve(1000); org.junit.Assert.assertEquals( result, "1" ); } @org.junit.Test(timeout = 3000) publ...
correct_bracketing
package humaneval.buggy; /* brackets is a string of "<" and ">". return True if every opening bracket has a corresponding closing bracket. >>> correct_bracketing("<") False >>> correct_bracketing("<>") True >>> correct_bracketing("<<><>>") True >>> correct_bracketing("><<>") False */ public class CORRECT_BRACKETING ...
package humaneval.buggy; /* brackets is a string of "<" and ">". return True if every opening bracket has a corresponding closing bracket. >>> correct_bracketing("<") False >>> correct_bracketing("<>") True >>> correct_bracketing("<<><>>") True >>> correct_bracketing("><<>") False */ public class CORRECT_BRACKETING ...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_CORRECT_BRACKETING { @org.junit.Test(timeout = 1000) public void test_4() throws java.lang.Exception { boolean result = humaneval.buggy.CORRECT_BRACKETING.correct_...
string_to_md5
package humaneval.buggy; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import javax.xml.bind.DatatypeConverter; // Given a string 'text', return its md5 hash equivalent string. // If 'text' is an empty string, return None. // >>> string_to_md5('Hello world') == '3e25960a79dbc69b6...
package humaneval.buggy; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import javax.xml.bind.DatatypeConverter; // Given a string 'text', return its md5 hash equivalent string. // If 'text' is an empty string, return None. // >>> string_to_md5('Hello world') == '3e25960a79dbc69b6...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_STRING_TO_MD5 { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { String result = humaneval.buggy.STRING_TO_MD5.string_to_md5("Hell...
move_one_ball
package humaneval.buggy; import java.util.ArrayList; import java.util.Collections; public class MOVE_ONE_BALL { public static boolean move_one_ball(ArrayList<Integer> arr) { if(arr.size() == 0) return true; ArrayList<Integer> sorted_arr = new ArrayList<>(arr); Collections.sort(sorted_arr);...
package humaneval.buggy; import java.util.ArrayList; import java.util.Collections; public class MOVE_ONE_BALL { public static boolean move_one_ball(ArrayList<Integer> arr) { if(arr.size() == 0) return true; ArrayList<Integer> sorted_arr = new ArrayList<>(arr); Collections.sort(sorted_arr);...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_MOVE_ONE_BALL { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { ArrayList<Integer> input = new ArrayList<>(Arrays.asList(3,4,5,1,...
vowels_count
package humaneval.buggy; /* Write a function vowels_count which takes a string representing a word as input and returns the number of vowels in the string. Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the end of the given word. Example: >>> vowels_count("abcde") 2...
package humaneval.buggy; /* Write a function vowels_count which takes a string representing a word as input and returns the number of vowels in the string. Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the end of the given word. Example: >>> vowels_count("abcde") 2...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_VOWELS_COUNT { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int result = humaneval.buggy.VOWELS_COUNT.vowels_count("abcde"); ...
can_arrange
package humaneval.buggy; /* * Create a function which returns the largest index of an element which is not greater than or equal to the element immediately preceding it. If no such element exists then return -1. The given array will not contain duplicate values. Examples: can_arrange([1,2,4,3,5])...
package humaneval.buggy; /* * Create a function which returns the largest index of an element which is not greater than or equal to the element immediately preceding it. If no such element exists then return -1. The given array will not contain duplicate values. Examples: can_arrange([1,2,4,3,5])...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_CAN_ARRANGE { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int[] arr = {1,2,4,3,5}; org.junit.Assert.assertEquals(3, h...
is_simple_power
package humaneval.buggy; // Your task is to write a function that returns true if a number x is a simple // power of n and false in other cases. // x is a simple power of n if n**int=x // For example: // is_simple_power(1, 4) => true // is_simple_power(2, 2) => true // is_simple_power(8, 2) => true // is_simple_power(...
package humaneval.buggy; // Your task is to write a function that returns true if a number x is a simple // power of n and false in other cases. // x is a simple power of n if n**int=x // For example: // is_simple_power(1, 4) => true // is_simple_power(2, 2) => true // is_simple_power(8, 2) => true // is_simple_power(...
package humaneval; public class TEST_IS_SIMPLE_POWER { @org.junit.Test(timeout = 3000) public void test_0() throws java.lang.Exception { boolean result = humaneval.buggy.IS_SIMPLE_POWER.is_simple_power(16, 2); org.junit.Assert.assertEquals( result, true ); } @org.ju...
intersection
package humaneval.buggy; /* * You are given two intervals, where each interval is a pair of integers. For example, interval = (start, end) = (1, 2). The given intervals are closed which means that the interval (start, end) includes both start and end. For each given interval, it is assumed that its st...
package humaneval.buggy; /* * You are given two intervals, where each interval is a pair of integers. For example, interval = (start, end) = (1, 2). The given intervals are closed which means that the interval (start, end) includes both start and end. For each given interval, it is assumed that its st...
package humaneval; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class TEST_INTERSECTION { @org.junit.Test(timeout = 1000) public void test_0() throws java.lang.Exception { int[] interval1 = {1,2}; int[] interval2 = {2,3}; org.junit....