id stringlengths 28 30 | content stringlengths 701 6k |
|---|---|
humaneval-x-java_data_Java_100 | Given a positive integer n, you have to make a pile of n levels of stones.
The first level has n stones.
The number of stones in the next level is:
- the next odd number if n is odd.
- the next even number if n is even.
Return the number of stones in each level in a list, where element a... |
humaneval-x-java_data_Java_101 | You will be given a string of words separated by commas or spaces. Your task is
to split the string into words and return an array of the words.
For example:
words_string("Hi, my name is John").equals(Arrays.asList("Hi", "my", "name", "is", "John"]
words_string("One, two, three, four, five, six... |
humaneval-x-java_data_Java_102 | This function takes two positive numbers x and y and returns the
biggest even integer number that is in the range [x, y] inclusive. If
there's no such number, then the function should return -1.
For example:
chooseNum(12, 15) = 14
chooseNum(13, 12) = -1
public class Main {
public stati... |
humaneval-x-java_data_Java_103 | You are given two positive integers n and m, and your task is to compute the
average of the integers from n through m (including n and m).
Round the answer to the nearest integer and convert that to binary.
If n is greater than m, return -1.
Example:
roundedAvg(1, 5) => "11"
roundedAvg(7, 5)... |
humaneval-x-java_data_Java_104 | Given a list of positive integers x. return a sorted list of all
elements that hasn't any even digit.
Note: Returned list should be sorted in increasing order.
For example:
>>> uniqueDigits(Arrays.asList(15, 33, 1422, 1))
[1, 15, 33]
>>> uniqueDigits(Arrays.asList(152, 323, 1422, 10))
... |
humaneval-x-java_data_Java_105 | Given an array of integers, sort the integers that are between 1 and 9 inclusive,
reverse the resulting array, and then replace each digit by its corresponding name from
"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
For example:
arr = [2, 1, 1, 4, 5, 8, 2, 3]
... |
humaneval-x-java_data_Java_106 | Implement the function f that takes n as a parameter,
and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
or the sum of numbers from 1 to i otherwise.
i starts from 1.
the factorial of i is the multiplication of the numbers from 1 to i (1 * ... |
humaneval-x-java_data_Java_107 | 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 palindrome are 1, 2, 3. one of them is even, and two of them are odd.
... |
humaneval-x-java_data_Java_108 | Write a function countNums which takes an array of integers and returns
the number of elements which has a sum of digits > 0.
If a number is negative, then its first signed digit will be negative:
e.g. -123 has signed digits -1, 2, and 3.
>>> countNums(Arrays.asList()) == 0
>>> countNums(Arrays.... |
humaneval-x-java_data_Java_109 | We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
numbers in the array will be randomly ordered. Your task is to determine if
it is possible to get an array sorted in non-decreasing order by performing
the following operation on the given array:
You are allowed to perform righ... |
humaneval-x-java_data_Java_110 | In this problem, you will implement a function that takes two lists of numbers,
and determines whether it is possible to perform an exchange of elements
between them to make lst1 a list of only even numbers.
There is no limit on the number of exchanged elements between lst1 and lst2.
If it is possib... |
humaneval-x-java_data_Java_111 | Given a string representing a space separated lowercase letters, return a dictionary
of the letter with the most repetition and containing the corresponding count.
If several letters have the same occurrence, return all of them.
Example:
histogram("a b c") == {"a": 1, "b": 1, "c": 1}
histogram(... |
humaneval-x-java_data_Java_112 | Task
We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
then check if the result string is palindrome.
A string is called palindrome if it reads the same backward as forward.
You should return a tuple containing the result string and tr... |
humaneval-x-java_data_Java_113 | Given a list of strings, where each string consists of only digits, return a list.
Each element i of the output should be "the number of odd elements in the
string i of the input." where all the i's should be replaced by the number
of odd digits in the i"th string of the input.
>>> oddCount(Arrays.... |
humaneval-x-java_data_Java_114 | Given an array of integers nums, find the minimum sum of any non-empty sub-array
of nums.
Example
minSubArraySum(Arrays.asList(2, 3, 4, 1, 2, 4)) == 1
minSubArraySum(Arrays.asList(-1, -2, -3)) == -6
public class Main {
public static void main(String[] args) {
Solution s = new Solution()... |
humaneval-x-java_data_Java_115 | You are given a rectangular grid of wells. Each row represents a single well,
and each 1 in a row represents a single unit of water.
Each well has a corresponding bucket that can be used to extract water from it,
and all buckets have the same capacity.
Your task is to use the buckets to empty the we... |
humaneval-x-java_data_Java_116 | 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.
<p>
It must be implemented like this:
>>> sortArray(Arrays.asList(1, 5, 2, 3, 4)).equals(Arrays... |
humaneval-x-java_data_Java_117 | Given a string s and a natural number n, you have been tasked to implement
a function that returns a list of all words from string s that contain exactly
n consonants, in order these words appear in the string s.
If the string s is empty then the function should return an empty list.
Note: you may a... |
humaneval-x-java_data_Java_118 | You are given a word. Your task is to find the closest vowel that stands between
two consonants from the right side of the word (case sensitive).
Vowels in the beginning and ending doesn't count. Return empty string if you didn't
find any vowel met the above condition.
You may assume that the give... |
humaneval-x-java_data_Java_119 | You are given a list of two strings, both strings consist of open
parentheses "(" or close parentheses ")" only.
Your job is to check if it is possible to concatenate the two strings in
some order, that the resulting string will be good.
A string S is considered to be good if and only if all parenth... |
humaneval-x-java_data_Java_120 | 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:
Input: arr = [4, -4, 4], k = 2
Output: [4, 4]
Example 3:
... |
humaneval-x-java_data_Java_121 | Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
Examples
solution(Arrays.asList(5, 8, 7, 1)) ==> 12
solution(Arrays.asList(3, 3, 3, 3, 3)) ==> 9
solution(Arrays.asList(30, 13, 24, 321)) ==>0
public class Main {
public static void main(S... |
humaneval-x-java_data_Java_122 | 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 # sum of 21 + 3
Constraints:
1. 1 <= len(arr) <= 100
2. ... |
humaneval-x-java_data_Java_123 | Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
as follows: start with any positive integer n. Then each term is obtained from the
previous term as follows: if the previ... |
humaneval-x-java_data_Java_124 | You have to write a function which validates a given date string and
returns true if the date is valid otherwise false.
The date is valid if all of the following rules are satisfied:
1. The date string is not empty.
2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8... |
humaneval-x-java_data_Java_125 | Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
Examples
split... |
humaneval-x-java_data_Java_126 | 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
isSorted(Arrays.asList(5)) -> true
isSorted(Arrays.asList(1, 2, 3, 4, 5)) -> true
isS... |
humaneval-x-java_data_Java_127 | You are given two intervals,
where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
The given intervals are closed which means that the interval (start, end)
includes both start and end.
For each given interval, it is assumed that its start is less or equal its end... |
humaneval-x-java_data_Java_128 | You are given an array arr of integers and you need to return
sum of magnitudes of integers multiplied by product of all signs
of each number in the array, represented by 1, -1 or 0.
Note: return None for empty arr.
Example:
>>> prodSigns(Arrays.asList(1, 2, 2, -4)) == -9
>>> prodSigns(Arra... |
humaneval-x-java_data_Java_129 | Given a grid with N rows and N columns (N >= 2) and a positive integer k,
each cell of the grid contains a value. Every integer in the range [1, N * N]
inclusive appears exactly once on the cells of the grid.
You have to find the minimum path of length k in the grid. You can start
from any cell, an... |
humaneval-x-java_data_Java_130 | Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
the last couple centuries. However, what people don't know is Tribonacci sequence.
Tribonacci sequence is defined by the recurrence:
tri(1) = 3
tri(n) = 1 + n / 2, if n is even.
tri(n) = tri(n - 1) + tri(n - 2) + tri(... |
humaneval-x-java_data_Java_131 | 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
public class Main {
public static void main(String[] args) {
Solution s = new Solution();
List<Boolean> correct =... |
humaneval-x-java_data_Java_132 | 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.
isNested("[[]]") -> true
isNested("[]]]]]]][[[[[]") -> false
isNes... |
humaneval-x-java_data_Java_133 | 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
For lst = [1,4,9] the output should be 98
For lst = [1,3,5,7] the output shoul... |
humaneval-x-java_data_Java_134 | Create a function that returns true if the last character
of a given string is an alphabetical character and is not
a part of a word, and false otherwise.
Note: "word" is a group of characters separated by space.
Examples:
checkIfLastCharIsALetter("apple pie") -> false
checkIfLastCharIsALet... |
humaneval-x-java_data_Java_135 | 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:
canArrange(Arrays.asList(1,2,4,3,5)) = 3
canArra... |
humaneval-x-java_data_Java_136 | Create a function that returns a tuple (a, b), where 'a' is
the largest of negative integers, and 'b' is the smallest
of positive integers in a list.
If there is no negative or positive integers, return them as None.
Examples:
largestSmallestIntegers(Arrays.asList(2, 4, 1, 3, 5, 7)) == (Optiona... |
humaneval-x-java_data_Java_137 | 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 ,
compareOne(1, 2.5) -> Optional.o... |
humaneval-x-java_data_Java_138 | Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
Example
isEqualToSumEven(4) == false
isEqualToSumEven(6) == false
isEqualToSumEven(8) == true
public class Main {
public static void main(String[] args) {
Solution s = new Solution();
... |
humaneval-x-java_data_Java_139 | The Brazilian factorial is defined as:
brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
where n > 0
For example:
>>> specialFactorial(4)
288
The function will receive an integer as input and should return the special
factorial of this integer.
public class Main {
public st... |
humaneval-x-java_data_Java_140 | 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 -
fixSpaces("Example") == "Example"
fixSpaces("Example 1") == "Example_1"
fixSpaces(" Example 2") == "_Example_2"
fixSpaces(" Example ... |
humaneval-x-java_data_Java_141 | Create a function which takes a string representing a file's name, and returns
"Yes" if the the file's name is valid, and returns "No" otherwise.
A file's name is considered to be valid if and only if all the following conditions
are met:
- There should not be more than three digits ('0'-'9') in the... |
humaneval-x-java_data_Java_142 | 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 multiple of 3. The function will not
change the entries in the list whose indexes are... |
humaneval-x-java_data_Java_143 | You are given a string representing a sentence,
the sentence contains some words separated by a space,
and you have to return a string that contains the words from the original sentence,
whose lengths are prime numbers,
the order of the words in the new string should be the same as the original one.... |
humaneval-x-java_data_Java_144 | Your task is to implement a function that will simplify the expression
x * n. The function returns true if x * n evaluates to a whole number and false
otherwise. Both x and n, are string representation of a fraction, and have the following format,
<numerator>/<denominator> where both numerator and denom... |
humaneval-x-java_data_Java_145 | Write a function which sorts the given list of integers
in ascending order according to the sum of their digits.
Note: if there are several items with similar sum of their digits,
order them based on their index in original list.
For example:
>>> orderByPoints(Arrays.asList(1, 11, -1, -11, -12)... |
humaneval-x-java_data_Java_146 | Write a function that takes an array of numbers as input and returns
the number of elements in the array that are greater than 10 and both
first and last digits of a number are odd (1, 3, 5, 7, 9).
For example:
specialFilter(Arrays.asList(15, -73, 14, -15)) => 1
specialFilter(Arrays.asList(33, -... |
humaneval-x-java_data_Java_147 | You are given a positive integer n. You have to create an integer array a of length n.
For each i (1 <= i <= n), the value of a[i] = i * i - i + 1.
Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
and a[i] + a[j] + a[k] is a multiple of 3.
Example :
Input: n = 5... |
humaneval-x-java_data_Java_148 | 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.
The function should return a tuple containing all planets whose orb... |
humaneval-x-java_data_Java_149 | Write a function that accepts a list of strings as a parameter,
deletes the strings that have odd lengths from it,
and returns the resulted list with a sorted order,
The list is always a list of strings and never an array of numbers,
and it may contain duplicates.
The order of the list should be... |
humaneval-x-java_data_Java_150 | 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 xOrY(7, 34, 12) == 34
for xOrY(15, 8, 5) == 5
public class Main {
public static void main(String[] args) {
Solution s = new Solution();
List<Bool... |
humaneval-x-java_data_Java_151 | 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.
doubleTheDifference(Arrays.asList(1, 3, 2, 0)) == 1 + 9 + 0 + 0 = 10
doubleTheDifference(Arrays.asList(-1, -2, 0)) == 0
doubleTheDifference(Arrays.asList(9, ... |
humaneval-x-java_data_Java_152 | I think we all remember that feeling when the result of some long-awaited
event is finally known. The feelings and thoughts you have at that moment are
definitely worth noting down and comparing.
Your task is to determine if a person correctly guessed the results of a number of matches.
You are give... |
humaneval-x-java_data_Java_153 | You will be given the name of a class (a string) and a list of extensions.
The extensions are to be used to load additional classes to the class. The
strength of the extension is as follows: Let CAP be the number of the uppercase
letters in the extension's name, and let SM be the number of lowercase let... |
humaneval-x-java_data_Java_154 | 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
cycpatternCheck("abcd","abd") => false
cycpatternCheck("hello","ell") => true
cycpatternCheck("whassup","psus") => false
cycpatternCheck("abab","baa") => true
cycpatternChec... |
humaneval-x-java_data_Java_155 | Given an integer. return a tuple that has the number of even and odd digits respectively.
Example:
evenOddCount(-12) ==> (1, 1)
evenOddCount(123) ==> (1, 2)
public class Main {
public static void main(String[] args) {
Solution s = new Solution();
List<Boolean> correct ... |
humaneval-x-java_data_Java_156 | Given a positive integer, obtain its roman numeral equivalent as a string,
and return it in lowercase.
Restrictions: 1 <= num <= 1000
Examples:
>>> intToMiniRoman(19) == "xix"
>>> intToMiniRoman(152) == "clii"
>>> intToMiniRoman(426) == "cdxxvi"
public class Main {
public static void m... |
humaneval-x-java_data_Java_157 | Given the lengths of the three sides of a triangle. Return true if the three
sides form a right-angled triangle, false otherwise.
A right-angled triangle is a triangle in which one angle is right angle or
90 degree.
Example:
rightAngleTriangle(3, 4, 5) == true
rightAngleTriangle(1, 2, 3) == ... |
humaneval-x-java_data_Java_158 | Write a function that accepts a list of strings.
The list contains different words. Return the word with maximum number
of unique characters. If multiple strings have maximum number of unique
characters, return the one which comes first in lexicographical order.
findMax(["name", "of", "string"]) ==... |
humaneval-x-java_data_Java_159 | 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 left after your meals ]
... |
humaneval-x-java_data_Java_160 | Given two lists operator, and operand. The first list has basic algebra operations, and
the second list is a list of integers. Use the two given lists to build the algebric
expression and return the evaluation of this expression.
The basic algebra operations:
Addition ( + )
Subtraction ( - )
... |
humaneval-x-java_data_Java_161 | 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 resulted string.
Examples
solve("1234") = "4321"
solve("ab") = "AB"
sol... |
humaneval-x-java_data_Java_162 | Given a string "text", return its md5 hash equivalent string with length being 32.
If "text" is an empty string, return Optional.empty().
>>> stringToMd5("Hello world") == "3e25960a79dbc69b674cd4ec67a72c62"
public class Main {
public static void main(String[] args) throws NoSuchAlgorithmException ... |
humaneval-x-java_data_Java_163 | Given two positive integers a and b, return the even digits between a
and b, in ascending order.
For example:
generateIntegers(2, 8) => [2, 4, 6, 8]
generateIntegers(8, 2) => [2, 4, 6, 8]
generateIntegers(10, 14) => []
public class Main {
public static void main(String[] args) {
So... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.