Prompt:
# Return length of given string
# >>> strlen('')
# 0
# >>> strlen('abc')
# 3
strlen <- function(string) {

test_humaneval <- function() {
    candidate <- strlen
    stopifnot(isTRUE(all.equal(candidate(''), 0)))
    stopifnot(isTRUE(all.equal(candidate('x'), 1)))
    stopifnot(isTRUE(all.equal(candidate('asdasnakj'), 9)))
}
test_humaneval()


Prompt:
# Create a function encrypt that takes a string as an argument and
# returns a string encrypted with the alphabet being rotated.
# The alphabet should be rotated in a manner such that the letters
# shift down by two multiplied to two places.
# For example:
# >>> encrypt('hi')
# 'lm'
# >>> encrypt('asdfghjkl')
# 'ewhjklnop'
# >>> encrypt('gf')
# 'kj'
# >>> encrypt('et')
# 'ix'
encrypt <- function(s) {

test_humaneval <- function() {
    candidate <- encrypt
    stopifnot(isTRUE(all.equal(candidate('hi'), 'lm')))
    stopifnot(isTRUE(all.equal(candidate('asdfghjkl'), 'ewhjklnop')))
    stopifnot(isTRUE(all.equal(candidate('gf'), 'kj')))
    stopifnot(isTRUE(all.equal(candidate('et'), 'ix')))
    stopifnot(isTRUE(all.equal(candidate('faewfawefaewg'), 'jeiajeaijeiak')))
    stopifnot(isTRUE(all.equal(candidate('hellomyfriend'), 'lippsqcjvmirh')))
    stopifnot(isTRUE(all.equal(candidate('dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh'), 'hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl')))
    stopifnot(isTRUE(all.equal(candidate('a'), 'e')))
}
test_humaneval()


Prompt:
# Given a named list, return TRUE if all keys are strings in lower
# case or all keys are strings in upper case, else return FALSE.
# The function should return FALSE is the given named list is empty.
# Examples:
# >>> check_dict_case(list('a' = 'apple', 'b' = 'banana'))
# TRUE
# >>> check_dict_case(list('a' = 'apple', 'A' = 'banana', 'B' = 'banana'))
# FALSE
# >>> check_dict_case(list('a' = 'apple', 8 = 'banana', 'a' = 'apple'))
# FALSE
# >>> check_dict_case(list('Name' = 'John', 'Age' = '36', 'City' = 'Houston'))
# FALSE
# >>> check_dict_case(list('STATE' = 'NC', 'ZIP' = '12345'))
# TRUE
check_dict_case <- function(dict) {

test_humaneval <- function() {
    candidate <- check_dict_case
    stopifnot(isTRUE(all.equal(candidate(list('p' = 'pineapple', 'b' = 'banana')), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(list('p' = 'pineapple', 'A' = 'banana', 'B' = 'banana')), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(list('p' = 'pineapple', '5' = 'banana', 'a' = 'apple')), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(list('Name' = 'John', 'Age' = '36', 'City' = 'Houston')), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(list('STATE' = 'NC', 'ZIP' = '12345')), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(list('fruit' = 'Orange', 'taste' = 'Sweet')), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(list()), FALSE)))
}
test_humaneval()


Prompt:
# Given a non-empty list of integers lst. add the even elements that are at odd indices..
# Examples:
# >>> add(c(4, 2, 6, 7))
# 2
add <- function(lst) {

test_humaneval <- function() {
    candidate <- add
    stopifnot(isTRUE(all.equal(candidate(c(4, 88)), 88)))
    stopifnot(isTRUE(all.equal(candidate(c(4, 5, 6, 7, 2, 122)), 122)))
    stopifnot(isTRUE(all.equal(candidate(c(4, 0, 6, 7)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(4, 4, 6, 8)), 12)))
}
test_humaneval()


Prompt:
# Given a string text, replace all spaces in it with underscores,
# and if a string has more than 2 consecutive spaces,
# then replace all consecutive spaces with -
# >>> fix_spaces(' Example')
# 'Example'
# >>> fix_spaces(' Example 1')
# 'Example_1'
# >>> fix_spaces(' Example 2')
# '_Example_2'
# >>> fix_spaces(' Example 3')
# '_Example-3'
fix_spaces <- function(text) {

test_humaneval <- function() {
    candidate <- fix_spaces
    stopifnot(isTRUE(all.equal(candidate('Example'), 'Example')))
    stopifnot(isTRUE(all.equal(candidate('Mudasir Hanif '), 'Mudasir_Hanif_')))
    stopifnot(isTRUE(all.equal(candidate('Yellow Yellow  Dirty  Fellow'), 'Yellow_Yellow__Dirty__Fellow')))
    stopifnot(isTRUE(all.equal(candidate('Exa   mple'), 'Exa-mple')))
    stopifnot(isTRUE(all.equal(candidate('   Exa 1 2 2 mple'), '-Exa_1_2_2_mple')))
}
test_humaneval()


Prompt:
# The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
# fibfib(0) == 0
# fibfib(1) == 0
# fibfib(2) == 1
# fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
# Please write a function to efficiently compute the n-th element of the fibfib number sequence.
# >>> fibfib(1)
# 0
# >>> fibfib(5)
# 4
# >>> fibfib(8)
# 24
fibfib <- function(n) {

test_humaneval <- function() {
    candidate <- fibfib
    stopifnot(isTRUE(all.equal(candidate(2), 1)))
    stopifnot(isTRUE(all.equal(candidate(1), 0)))
    stopifnot(isTRUE(all.equal(candidate(5), 4)))
    stopifnot(isTRUE(all.equal(candidate(8), 24)))
    stopifnot(isTRUE(all.equal(candidate(10), 81)))
    stopifnot(isTRUE(all.equal(candidate(12), 274)))
    stopifnot(isTRUE(all.equal(candidate(14), 927)))
}
test_humaneval()


Prompt:
# 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(c(1, 3, 2, 0))
# 10
# >>> double_the_difference(c(-1, -2, 0))
# 0
# >>> double_the_difference(c(9, -2))
# 81
# >>> double_the_difference(c(0))
# 0
# If the input list is empty, return 0.
double_the_difference <- function(lst) {

test_humaneval <- function() {
    candidate <- double_the_difference
    stopifnot(isTRUE(all.equal(candidate(c()), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(5.0, 4.0)), 25)))
    stopifnot(isTRUE(all.equal(candidate(c(0.1, 0.2, 0.3)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(-10.0, -20.0, -30.0)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(-1.0, -2.0, 8.0)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(0.2, 3.0, 5.0)), 34)))
    stopifnot(isTRUE(all.equal(candidate(c(-9.0, -7.0, -5.0, -3.0, -1.0, 1.0, 3.0, 5.0, 7.0, 9.0)), 165)))
}
test_humaneval()


Prompt:
# Filter given list of any rthon values only for integers
# >>> filter_integers(list('a', 3.14, 5))
# c(5)
# >>> filter_integers(list(1, 2, 3, 'abc', list(), c()))
# c(1, 2, 3)
filter_integers <- function(values) {

test_humaneval <- function() {
    candidate <- filter_integers
    stopifnot(isTRUE(all.equal(candidate(c()), c())))
    stopifnot(isTRUE(all.equal(candidate(list(4, list(), c(), 23.2, 9, 'adasd')), c(4, 9))))
    stopifnot(isTRUE(all.equal(candidate(list(3, 'c', 3, 3, 'a', 'b')), c(3, 3, 3))))
}
test_humaneval()


Prompt:
# 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
# each other.  All cars move in the same speed.  Two cars are said to collide
# when a car that's moving left to right hits a car that's moving right to left.
# However, the cars are infinitely sturdy and strong; as a result, they continue moving
# in their trajectory as if they did not collide.
# This function outputs the number of such collisions.
car_race_collision <- function(n) {

test_humaneval <- function() {
    candidate <- car_race_collision
    stopifnot(isTRUE(all.equal(candidate(2), 4)))
    stopifnot(isTRUE(all.equal(candidate(3), 9)))
    stopifnot(isTRUE(all.equal(candidate(4), 16)))
    stopifnot(isTRUE(all.equal(candidate(8), 64)))
    stopifnot(isTRUE(all.equal(candidate(10), 100)))
}
test_humaneval()


Prompt:
# 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:
# 'o' - whole note, lasts four beats
# 'o|' - half note, lasts two beats
# '.|' - quater note, lasts one beat
# >>> parse_music('o o| .| o| o| .| .| .| .| o o')
# c(4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4)
parse_music <- function(music_string) {

test_humaneval <- function() {
    candidate <- parse_music
    stopifnot(isTRUE(all.equal(candidate(''), c())))
    stopifnot(isTRUE(all.equal(candidate('o o o o'), c(4, 4, 4, 4))))
    stopifnot(isTRUE(all.equal(candidate('.| .| .| .|'), c(1, 1, 1, 1))))
    stopifnot(isTRUE(all.equal(candidate('o| o| .| .| o o o o'), c(2, 2, 1, 1, 4, 4, 4, 4))))
    stopifnot(isTRUE(all.equal(candidate('o| .| o| .| o o| o o|'), c(2, 1, 2, 1, 4, 2, 4, 2))))
}
test_humaneval()


Prompt:
# You will be given a number in decimal form and your task is to convert it to
# binary format. The function should return a string, with each character representing a binary
# number. Each character in the string will be '0' or '1'.
# There will be an extra couple of characters 'db' at the beginning and at the end of the string.
# The extra characters are there to help with the format.
# Examples:
# >>> decimal_to_binary(15)
# 'db1111db'
# >>> decimal_to_binary(32)
# 'db100000db'
decimal_to_binary <- function(decimal) {

test_humaneval <- function() {
    candidate <- decimal_to_binary
    stopifnot(isTRUE(all.equal(candidate(0), 'db0db')))
    stopifnot(isTRUE(all.equal(candidate(32), 'db100000db')))
    stopifnot(isTRUE(all.equal(candidate(103), 'db1100111db')))
    stopifnot(isTRUE(all.equal(candidate(15), 'db1111db')))
}
test_humaneval()


Prompt:
# Return list of all prefixes from shortest to longest of the input string
# >>> all_prefixes('abc')
# c('a', 'ab', 'abc')
all_prefixes <- function(string) {

test_humaneval <- function() {
    candidate <- all_prefixes
    stopifnot(isTRUE(all.equal(candidate(''), c())))
    stopifnot(isTRUE(all.equal(candidate('asdfgh'), c('a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh'))))
    stopifnot(isTRUE(all.equal(candidate('WWW'), c('W', 'WW', 'WWW'))))
}
test_humaneval()


Prompt:
# Add two numbers x and y
# >>> add(2, 3)
# 5
# >>> add(5, 7)
# 12
add <- function(x, y) {

test_humaneval <- function() {
    candidate <- add
    stopifnot(isTRUE(all.equal(candidate(0, 1), 1)))
    stopifnot(isTRUE(all.equal(candidate(1, 0), 1)))
    stopifnot(isTRUE(all.equal(candidate(2, 3), 5)))
    stopifnot(isTRUE(all.equal(candidate(5, 7), 12)))
    stopifnot(isTRUE(all.equal(candidate(7, 5), 12)))
}
test_humaneval()


Prompt:
# 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 a vector of [ total number of eaten carrots after your meals,
# the number of carrots left after your meals ]
# if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
# Example:
# >>> eat(5, 6, 10)
# c(11, 4)
# >>> eat(4, 8, 9)
# c(12, 1)
# >>> eat(1, 10, 10)
# c(11, 0)
# >>> eat(2, 11, 5)
# c(7, 0)
# Variables:
# @number : integer
# the number of carrots that you have eaten.
# @need : integer
# the number of carrots that you need to eat.
# @remaining : integer
# the number of remaining carrots thet exist in stock
# Constrain:
# * 0 <= number <= 1000
# * 0 <= need <= 1000
# * 0 <= remaining <= 1000
# Have fun :)
eat <- function(number, need, remaining) {

test_humaneval <- function() {
    candidate <- eat
    stopifnot(isTRUE(all.equal(candidate(5, 6, 10), c(11, 4))))
    stopifnot(isTRUE(all.equal(candidate(4, 8, 9), c(12, 1))))
    stopifnot(isTRUE(all.equal(candidate(1, 10, 10), c(11, 0))))
    stopifnot(isTRUE(all.equal(candidate(2, 11, 5), c(7, 0))))
    stopifnot(isTRUE(all.equal(candidate(4, 5, 7), c(9, 2))))
    stopifnot(isTRUE(all.equal(candidate(4, 5, 1), c(5, 0))))
}
test_humaneval()


Prompt:
# 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 wells.
# Output the number of times you need to lower the buckets.
# Example 1:
# >>> max_fill(list(c(0, 0, 1, 0), c(0, 1, 0, 0), c(1, 1, 1, 1)), 1)
# 6
# Example 2:
# >>> max_fill(list(c(0, 0, 1, 1), c(0, 0, 0, 0), c(1, 1, 1, 1), c(0, 1, 1, 1)), 2)
# 5
# Example 3:
# >>> max_fill(list(c(0, 0, 0), c(0, 0, 0)), 5)
# 0
# Constraints:
# * all wells have the same length
# * 1 <= grid.length <= 10^2
# * 1 <= grid[:,1].length <= 10^2
# * grid[i][j] -> 0 | 1
# * 1 <= capacity <= 10
max_fill <- function(grid, capacity) {

test_humaneval <- function() {
    candidate <- max_fill
    stopifnot(isTRUE(all.equal(candidate(list(c(0, 0, 1, 0), c(0, 1, 0, 0), c(1, 1, 1, 1)), 1), 6)))
    stopifnot(isTRUE(all.equal(candidate(list(c(0, 0, 1, 1), c(0, 0, 0, 0), c(1, 1, 1, 1), c(0, 1, 1, 1)), 2), 5)))
    stopifnot(isTRUE(all.equal(candidate(list(c(0, 0, 0), c(0, 0, 0)), 5), 0)))
    stopifnot(isTRUE(all.equal(candidate(list(c(1, 1, 1, 1), c(1, 1, 1, 1)), 2), 4)))
    stopifnot(isTRUE(all.equal(candidate(list(c(1, 1, 1, 1), c(1, 1, 1, 1)), 9), 2)))
}
test_humaneval()


Prompt:
# Given two lists operator, and operand. The first list has basic algebra operations, and
# the second list is a list of integers. Use the two given lists to build the algebric
# expression and return the evaluation of this expression.
# The basic algebra operations:
# Addition ( + )
# Subtraction ( - )
# Multiplication ( * )
# Floor division ( // )
# Exponentiation ( ** )
# Example:
# operator['+', '*', '-']
# vector = [2, 3, 4, 5]
# result = 2 + 3 * 4 - 5
# => result = 9
# Note:
# The length of operator list is equal to the length of operand list minus one.
# Operand is a list of of non-negative integers.
# Operator list has at least one operator, and operand list has at least two operands.
do_algebra <- function(operator, operand) {

test_humaneval <- function() {
    candidate <- do_algebra
    stopifnot(isTRUE(all.equal(candidate(c('**', '*', '+'), c(2, 3, 4, 5)), 37)))
    stopifnot(isTRUE(all.equal(candidate(c('+', '*', '-'), c(2, 3, 4, 5)), 9)))
    stopifnot(isTRUE(all.equal(candidate(c('//', '*'), c(7, 3, 4)), 8)))
}
test_humaneval()


Prompt:
# For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
# >>> flip_case('Hello')
# 'hELLO'
flip_case <- function(string) {

test_humaneval <- function() {
    candidate <- flip_case
    stopifnot(isTRUE(all.equal(candidate(''), '')))
    stopifnot(isTRUE(all.equal(candidate('Hello!'), 'hELLO!')))
    stopifnot(isTRUE(all.equal(candidate('These violent delights have violent ends'), 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS')))
}
test_humaneval()


Prompt:
# Given a vector of integers, sort the integers that are between 1 and 9 inclusive,
# reverse the resulting vector, and then replace each digit by its corresponding name from
# "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
# For example:
# >>> by_length(c(2, 1, 1, 4, 5, 8, 2, 3))
# c('Eight', 'Five', 'Four', 'Three', 'Two', 'Two', 'One', 'One')
# If the vector is empty, return an empty vector:
# >>> by_length(c())
# c()
# If the vector has any strange number ignore it:
# >>> by_length(c(1, -1, 55))
# c('One')
by_length <- function(arr) {

test_humaneval <- function() {
    candidate <- by_length
    stopifnot(isTRUE(all.equal(candidate(c(2, 1, 1, 4, 5, 8, 2, 3)), c('Eight', 'Five', 'Four', 'Three', 'Two', 'Two', 'One', 'One'))))
    stopifnot(isTRUE(all.equal(candidate(c()), c())))
    stopifnot(isTRUE(all.equal(candidate(c(1, -1, 55)), c('One'))))
    stopifnot(isTRUE(all.equal(candidate(c(1, -1, 3, 2)), c('Three', 'Two', 'One'))))
    stopifnot(isTRUE(all.equal(candidate(c(9, 4, 8)), c('Nine', 'Eight', 'Four'))))
}
test_humaneval()


Prompt:
# Return list of prime factors of given integer in the order from smallest to largest.
# Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
# Input number should be equal to the product of all factors
# >>> factorize(8)
# c(2, 2, 2)
# >>> factorize(25)
# c(5, 5)
# >>> factorize(70)
# c(2, 5, 7)
factorize <- function(n) {

test_humaneval <- function() {
    candidate <- factorize
    stopifnot(isTRUE(all.equal(candidate(2), c(2))))
    stopifnot(isTRUE(all.equal(candidate(4), c(2, 2))))
    stopifnot(isTRUE(all.equal(candidate(8), c(2, 2, 2))))
    stopifnot(isTRUE(all.equal(candidate(57), c(3, 19))))
    stopifnot(isTRUE(all.equal(candidate(3249), c(3, 3, 19, 19))))
    stopifnot(isTRUE(all.equal(candidate(185193), c(3, 3, 3, 19, 19, 19))))
    stopifnot(isTRUE(all.equal(candidate(20577), c(3, 19, 19, 19))))
    stopifnot(isTRUE(all.equal(candidate(18), c(2, 3, 3))))
}
test_humaneval()


Prompt:
# Implement a function that takes an non-negative integer and returns a vector of the first n
# integers that are prime numbers and less than n.
# for example:
# >>> count_up_to(5)
# c(2, 3)
# >>> count_up_to(11)
# c(2, 3, 5, 7)
# >>> count_up_to(0)
# c()
# >>> count_up_to(20)
# c(2, 3, 5, 7, 11, 13, 17, 19)
# >>> count_up_to(1)
# c()
# >>> count_up_to(18)
# c(2, 3, 5, 7, 11, 13, 17)
count_up_to <- function(n) {

test_humaneval <- function() {
    candidate <- count_up_to
    stopifnot(isTRUE(all.equal(candidate(5), c(2, 3))))
    stopifnot(isTRUE(all.equal(candidate(6), c(2, 3, 5))))
    stopifnot(isTRUE(all.equal(candidate(7), c(2, 3, 5))))
    stopifnot(isTRUE(all.equal(candidate(10), c(2, 3, 5, 7))))
    stopifnot(isTRUE(all.equal(candidate(0), c())))
    stopifnot(isTRUE(all.equal(candidate(22), c(2, 3, 5, 7, 11, 13, 17, 19))))
    stopifnot(isTRUE(all.equal(candidate(1), c())))
    stopifnot(isTRUE(all.equal(candidate(18), c(2, 3, 5, 7, 11, 13, 17))))
    stopifnot(isTRUE(all.equal(candidate(47), c(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43))))
    stopifnot(isTRUE(all.equal(candidate(101), c(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97))))
}
test_humaneval()


Prompt:
# Return sorted unique elements in a list
# >>> unique(c(5, 3, 5, 2, 3, 3, 9, 0, 123))
# c(0, 2, 3, 5, 9, 123)
unique <- function(l) {

test_humaneval <- function() {
    candidate <- unique
    stopifnot(isTRUE(all.equal(candidate(c(5, 3, 5, 2, 3, 3, 9, 0, 123)), c(0, 2, 3, 5, 9, 123))))
}
test_humaneval()


Prompt:
# Write a function that accepts two lists of strings and returns the list that has
# total number of chars in the all strings of the list less than the other list.
# if the two lists have the same number of chars, return the first list.
# Examples
# >>> total_match(c(), c())
# c()
# >>> total_match(c('hi', 'admin'), c('hI', 'Hi'))
# c('hI', 'Hi')
# >>> total_match(c('hi', 'admin'), c('hi', 'hi', 'admin', 'project'))
# c('hi', 'admin')
# >>> total_match(c('hi', 'admin'), c('hI', 'hi', 'hi'))
# c('hI', 'hi', 'hi')
# >>> total_match(c('4'), c('1', '2', '3', '4', '5'))
# c('4')
total_match <- function(lst1, lst2) {

test_humaneval <- function() {
    candidate <- total_match
    stopifnot(isTRUE(all.equal(candidate(c(), c()), c())))
    stopifnot(isTRUE(all.equal(candidate(c('hi', 'admin'), c('hi', 'hi')), c('hi', 'hi'))))
    stopifnot(isTRUE(all.equal(candidate(c('hi', 'admin'), c('hi', 'hi', 'admin', 'project')), c('hi', 'admin'))))
    stopifnot(isTRUE(all.equal(candidate(c('4'), c('1', '2', '3', '4', '5')), c('4'))))
    stopifnot(isTRUE(all.equal(candidate(c('hi', 'admin'), c('hI', 'Hi')), c('hI', 'Hi'))))
    stopifnot(isTRUE(all.equal(candidate(c('hi', 'admin'), c('hI', 'hi', 'hi')), c('hI', 'hi', 'hi'))))
    stopifnot(isTRUE(all.equal(candidate(c('hi', 'admin'), c('hI', 'hi', 'hii')), c('hi', 'admin'))))
    stopifnot(isTRUE(all.equal(candidate(c(), c('this')), c())))
    stopifnot(isTRUE(all.equal(candidate(c('this'), c()), c())))
}
test_humaneval()


Prompt:
# Return maximum element in the list.
# >>> max_element(c(1, 2, 3))
# 3
# >>> max_element(c(5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10))
# 123
max_element <- function(l) {

test_humaneval <- function() {
    candidate <- max_element
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3)), 3)))
    stopifnot(isTRUE(all.equal(candidate(c(5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10)), 124)))
}
test_humaneval()


Prompt:
# 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.
# >>> is_nested('[[]]')
# TRUE
# >>> is_nested('[]]]]]]][[[[[]')
# FALSE
# >>> is_nested('[][]')
# FALSE
# >>> is_nested('[]')
# FALSE
# >>> is_nested('[[][]]')
# TRUE
# >>> is_nested('[[]][[')
# TRUE
is_nested <- function(string) {

test_humaneval <- function() {
    candidate <- is_nested
    stopifnot(isTRUE(all.equal(candidate('[[]]'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('[]]]]]]][[[[[]'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('[][]'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('[]'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('[[[[]]]]'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('[]]]]]]]]]]'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('[][][[]]'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('[[]'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('[]]'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('[[]][['), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('[[][]]'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(''), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('[[[[[[[['), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(']]]]]]]]'), FALSE)))
}
test_humaneval()


Prompt:
# 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:
# >>> rounded_avg(1, 5)
# '0b11'
# >>> rounded_avg(7, 5)
# -1
# >>> rounded_avg(10, 20)
# '0b1111'
# >>> rounded_avg(20, 33)
# '0b11010'
rounded_avg <- function(n, m) {

test_humaneval <- function() {
    candidate <- rounded_avg
    stopifnot(isTRUE(all.equal(candidate(1, 5), '0b11')))
    stopifnot(isTRUE(all.equal(candidate(7, 13), '0b1010')))
    stopifnot(isTRUE(all.equal(candidate(964, 977), '0b1111001010')))
    stopifnot(isTRUE(all.equal(candidate(996, 997), '0b1111100100')))
    stopifnot(isTRUE(all.equal(candidate(560, 851), '0b1011000010')))
    stopifnot(isTRUE(all.equal(candidate(185, 546), '0b101101110')))
    stopifnot(isTRUE(all.equal(candidate(362, 496), '0b110101101')))
    stopifnot(isTRUE(all.equal(candidate(350, 902), '0b1001110010')))
    stopifnot(isTRUE(all.equal(candidate(197, 233), '0b11010111')))
    stopifnot(isTRUE(all.equal(candidate(7, 5), -1)))
    stopifnot(isTRUE(all.equal(candidate(5, 1), -1)))
    stopifnot(isTRUE(all.equal(candidate(5, 5), '0b101')))
}
test_humaneval()


Prompt:
# 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.
# >>> odd_count(c('1234567'))
# c('the number of odd elements 4n the str4ng 4 of the 4nput.')
# >>> odd_count(c('3', '11111111'))
# c('the number of odd elements 1n the str1ng 1 of the 1nput.', 'the number of odd elements 8n the str8ng 8 of the 8nput.')
odd_count <- function(lst) {

test_humaneval <- function() {
    candidate <- odd_count
    stopifnot(isTRUE(all.equal(candidate(c('1234567')), c('the number of odd elements 4n the str4ng 4 of the 4nput.'))))
    stopifnot(isTRUE(all.equal(candidate(c('3', '11111111')), c('the number of odd elements 1n the str1ng 1 of the 1nput.', 'the number of odd elements 8n the str8ng 8 of the 8nput.'))))
    stopifnot(isTRUE(all.equal(candidate(c('271', '137', '314')), c('the number of odd elements 2n the str2ng 2 of the 2nput.', 'the number of odd elements 3n the str3ng 3 of the 3nput.', 'the number of odd elements 2n the str2ng 2 of the 2nput.'))))
}
test_humaneval()


Prompt:
# We have a vector 'arr' of N integers arr[1], arr[2], ..., arr[N].The
# numbers in the vector will be randomly ordered. Your task is to determine if
# it is possible to get a vector sorted in non-decreasing order by performing
# the following operation on the given vector:
# You are allowed to perform right shift operation any number of times.
# One right shift operation means shifting all elements of the vector by one
# position in the right direction. The last element of the vector will be moved to
# the starting position in the vector i.e. 0th index.
# If it is possible to obtain the sorted vector by performing the above operation
# then return TRUE else return FALSE.
# If the given vector is empty then return TRUE.
# Note: The given list is guaranteed to have unique elements.
# For Example:
# >>> move_one_ball(c(3, 4, 5, 1, 2))
# TRUE
# Explanation: By performin 2 right shift operations, non-decreasing order can
# be achieved for the given vector.
# >>> move_one_ball(c(3, 5, 4, 1, 2))
# FALSE
# Explanation:It is not possible to get non-decreasing order for the given
# vector by performing any number of right shift operations.
move_one_ball <- function(arr) {

test_humaneval <- function() {
    candidate <- move_one_ball
    stopifnot(isTRUE(all.equal(candidate(c(3, 4, 5, 1, 2)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(3, 5, 10, 1, 2)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(4, 3, 1, 2)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(3, 5, 4, 1, 2)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c()), TRUE)))
}
test_humaneval()


Prompt:
# Given a positive integer n, return a list that has the number of even and odd
# integer palindromes that fall within the range(1, n), inclusive.
# Example 1:
# >>> even_odd_palindrome(3)
# c(1, 2)
# Explanation:
# Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
# Example 2:
# >>> even_odd_palindrome(12)
# c(4, 6)
# Explanation:
# Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
# Note:
# 1. 1 <= n <= 10^3
# 2. returned list has the number of even and odd integer palindromes respectively.
even_odd_palindrome <- function(n) {

test_humaneval <- function() {
    candidate <- even_odd_palindrome
    stopifnot(isTRUE(all.equal(candidate(123), c(8, 13))))
    stopifnot(isTRUE(all.equal(candidate(12), c(4, 6))))
    stopifnot(isTRUE(all.equal(candidate(3), c(1, 2))))
    stopifnot(isTRUE(all.equal(candidate(63), c(6, 8))))
    stopifnot(isTRUE(all.equal(candidate(25), c(5, 6))))
    stopifnot(isTRUE(all.equal(candidate(19), c(4, 6))))
    stopifnot(isTRUE(all.equal(candidate(9), c(4, 5))))
    stopifnot(isTRUE(all.equal(candidate(1), c(0, 1))))
}
test_humaneval()


Prompt:
# 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
is_equal_to_sum_even <- function(n) {

test_humaneval <- function() {
    candidate <- is_equal_to_sum_even
    stopifnot(isTRUE(all.equal(candidate(4), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(6), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(8), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(10), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(11), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(12), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(13), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(16), TRUE)))
}
test_humaneval()


Prompt:
# xs represent coefficients of a polynomial.
# xs[0] + xs[1] * x + xs[2] * x^2 + ....
# Return derivative of this polynomial in the same form.
# >>> derivative(c(3, 1, 2, 4, 5))
# c(1, 4, 12, 20)
# >>> derivative(c(1, 2, 3))
# c(2, 6)
derivative <- function(xs) {

test_humaneval <- function() {
    candidate <- derivative
    stopifnot(isTRUE(all.equal(candidate(c(3, 1, 2, 4, 5)), c(1, 4, 12, 20))))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3)), c(2, 6))))
    stopifnot(isTRUE(all.equal(candidate(c(3, 2, 1)), c(2, 2))))
    stopifnot(isTRUE(all.equal(candidate(c(3, 2, 1, 0, 4)), c(2, 2, 0, 16))))
    stopifnot(isTRUE(all.equal(candidate(c(1)), c())))
}
test_humaneval()


Prompt:
# 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(c(5))
# TRUE
# >>> is_sorted(c(1, 2, 3, 4, 5))
# TRUE
# >>> is_sorted(c(1, 3, 2, 4, 5))
# FALSE
# >>> is_sorted(c(1, 2, 3, 4, 5, 6))
# TRUE
# >>> is_sorted(c(1, 2, 3, 4, 5, 6, 7))
# TRUE
# >>> is_sorted(c(1, 3, 2, 4, 5, 6, 7))
# FALSE
# >>> is_sorted(c(1, 2, 2, 3, 3, 4))
# TRUE
# >>> is_sorted(c(1, 2, 2, 2, 3, 4))
# FALSE
is_sorted <- function(lst) {

test_humaneval <- function() {
    candidate <- is_sorted
    stopifnot(isTRUE(all.equal(candidate(c(5)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4, 5)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 3, 2, 4, 5)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4, 5, 6)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4, 5, 6, 7)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 3, 2, 4, 5, 6, 7)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c()), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(3, 2, 1)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 2, 2, 3, 4)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 3, 3, 4)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 2, 3, 3, 4)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4)), TRUE)))
}
test_humaneval()


Prompt:
# 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'
# >>> solve('#a@C')
# '#A@c'
solve <- function(s) {

test_humaneval <- function() {
    candidate <- solve
    stopifnot(isTRUE(all.equal(candidate('AsDf'), 'aSdF')))
    stopifnot(isTRUE(all.equal(candidate('1234'), '4321')))
    stopifnot(isTRUE(all.equal(candidate('ab'), 'AB')))
    stopifnot(isTRUE(all.equal(candidate('#a@C'), '#A@c')))
    stopifnot(isTRUE(all.equal(candidate('#AsdfW^45'), '#aSDFw^45')))
    stopifnot(isTRUE(all.equal(candidate('#6@2'), '2@6#')))
    stopifnot(isTRUE(all.equal(candidate('#$a^D'), '#$A^d')))
    stopifnot(isTRUE(all.equal(candidate('#ccc'), '#CCC')))
}
test_humaneval()


Prompt:
# 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(n + 1), if n is odd.
# For example:
# tri(2) = 1 + (2 / 2) = 2
# tri(4) = 3
# tri(3) = tri(2) + tri(1) + tri(4)
# = 2 + 3 + 3 = 8
# You are given a non-negative integer number n, you have to a return a list of the
# first n + 1 numbers of the Tribonacci sequence.
# Examples:
# >>> tri(3)
# c(1, 3, 2, 8)
tri <- function(n) {

test_humaneval <- function() {
    candidate <- tri
    stopifnot(isTRUE(all.equal(candidate(3), c(1, 3, 2, 8))))
    stopifnot(isTRUE(all.equal(candidate(4), c(1, 3, 2, 8, 3))))
    stopifnot(isTRUE(all.equal(candidate(5), c(1, 3, 2, 8, 3, 15))))
    stopifnot(isTRUE(all.equal(candidate(6), c(1, 3, 2, 8, 3, 15, 4))))
    stopifnot(isTRUE(all.equal(candidate(7), c(1, 3, 2, 8, 3, 15, 4, 24))))
    stopifnot(isTRUE(all.equal(candidate(8), c(1, 3, 2, 8, 3, 15, 4, 24, 5))))
    stopifnot(isTRUE(all.equal(candidate(9), c(1, 3, 2, 8, 3, 15, 4, 24, 5, 35))))
    stopifnot(isTRUE(all.equal(candidate(20), c(1, 3, 2, 8, 3, 15, 4, 24, 5, 35, 6, 48, 7, 63, 8, 80, 9, 99, 10, 120, 11))))
    stopifnot(isTRUE(all.equal(candidate(0), c(1))))
    stopifnot(isTRUE(all.equal(candidate(1), c(1, 3))))
}
test_humaneval()


Prompt:
# 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
fizz_buzz <- function(n) {

test_humaneval <- function() {
    candidate <- fizz_buzz
    stopifnot(isTRUE(all.equal(candidate(50), 0)))
    stopifnot(isTRUE(all.equal(candidate(78), 2)))
    stopifnot(isTRUE(all.equal(candidate(79), 3)))
    stopifnot(isTRUE(all.equal(candidate(100), 3)))
    stopifnot(isTRUE(all.equal(candidate(200), 6)))
    stopifnot(isTRUE(all.equal(candidate(4000), 192)))
    stopifnot(isTRUE(all.equal(candidate(10000), 639)))
    stopifnot(isTRUE(all.equal(candidate(100000), 8026)))
}
test_humaneval()


Prompt:
# Filter an input list of strings only for ones that start with a given prefix.
# >>> filter_by_prefix(c(), 'a')
# c()
# >>> filter_by_prefix(c('abc', 'bcd', 'cde', 'array'), 'a')
# c('abc', 'array')
filter_by_prefix <- function(strings, prefix) {

test_humaneval <- function() {
    candidate <- filter_by_prefix
    stopifnot(isTRUE(all.equal(candidate(c(), 'john'), c())))
    stopifnot(isTRUE(all.equal(candidate(c('xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'), 'xxx'), c('xxx', 'xxxAAA', 'xxx'))))
}
test_humaneval()


Prompt:
# Given a positive integer N, return the total sum of its digits in binary.
# Example
# >>> solve(1000)
# '1'
# >>> solve(150)
# '110'
# >>> solve(147)
# '1100'
# Variables:
# @N integer
# Constraints: 0 ≤ N ≤ 10000.
# Output:
# a string of binary number
solve <- function(N) {

test_humaneval <- function() {
    candidate <- solve
    stopifnot(isTRUE(all.equal(candidate(1000), '1')))
    stopifnot(isTRUE(all.equal(candidate(150), '110')))
    stopifnot(isTRUE(all.equal(candidate(147), '1100')))
    stopifnot(isTRUE(all.equal(candidate(333), '1001')))
    stopifnot(isTRUE(all.equal(candidate(963), '10010')))
}
test_humaneval()


Prompt:
# 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, and in each step you can move to any of the neighbor cells,
# in other words, you can go to cells which share an edge with you current
# cell.
# Please note that a path of length k means visiting exactly k cells (not
# necessarily distinct).
# You CANNOT go off the grid.
# A path A (of length k) is considered less than a path B (of length k) if
# after making the ordered lists of the values on the cells that A and B go
# through (let's call them lst_A and lst_B), lst_A is lexicographically less
# than lst_B, in other words, there exist an integer index i (1 <= i <= k)
# such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
# lst_A[j] = lst_B[j].
# It is guaranteed that the answer is unique.
# Return an ordered list of the values on the cells that the minimum path go through.
# Examples:
# >>> minPath(list(c(1, 2, 3), c(4, 5, 6), c(7, 8, 9)), 3)
# c(1, 2, 1)
# >>> minPath(list(c(5, 9, 3), c(4, 1, 6), c(7, 8, 2)), 1)
# c(1)
minPath <- function(grid, k) {


Prompt:
# Given a string s, count the number of uppercase vowels in even indices.
# For example:
# >>> count_upper('aBCdEf')
# 1
# >>> count_upper('abcdefg')
# 0
# >>> count_upper('dBBE')
# 0
count_upper <- function(s) {

test_humaneval <- function() {
    candidate <- count_upper
    stopifnot(isTRUE(all.equal(candidate('aBCdEf'), 1)))
    stopifnot(isTRUE(all.equal(candidate('abcdefg'), 0)))
    stopifnot(isTRUE(all.equal(candidate('dBBE'), 0)))
    stopifnot(isTRUE(all.equal(candidate('B'), 0)))
    stopifnot(isTRUE(all.equal(candidate('U'), 1)))
    stopifnot(isTRUE(all.equal(candidate(''), 0)))
    stopifnot(isTRUE(all.equal(candidate('EEEE'), 2)))
}
test_humaneval()


Prompt:
# Given a vector arr of integers and a positive integer k, return a sorted list
# of length k with the maximum k numbers in arr.
# Example 1:
# >>> maximum(c(-3, -4, 5), 3)
# c(-4, -3, 5)
# Example 2:
# >>> maximum(c(4, -4, 4), 2)
# c(4, 4)
# Example 3:
# >>> maximum(c(-3, 2, 1, 2, -1, -2, 1), 1)
# c(2)
# Note:
# 1. The length of the vector will be in the range of [1, 1000].
# 2. The elements in the vector will be in the range of [-1000, 1000].
# 3. 0 <= k <= len(arr)
maximum <- function(arr, k) {

test_humaneval <- function() {
    candidate <- maximum
    stopifnot(isTRUE(all.equal(candidate(c(-3, -4, 5), 3), c(-4, -3, 5))))
    stopifnot(isTRUE(all.equal(candidate(c(4, -4, 4), 2), c(4, 4))))
    stopifnot(isTRUE(all.equal(candidate(c(-3, 2, 1, 2, -1, -2, 1), 1), c(2))))
    stopifnot(isTRUE(all.equal(candidate(c(123, -123, 20, 0, 1, 2, -3), 3), c(2, 20, 123))))
    stopifnot(isTRUE(all.equal(candidate(c(-123, 20, 0, 1, 2, -3), 4), c(0, 1, 2, 20))))
    stopifnot(isTRUE(all.equal(candidate(c(5, 15, 0, 3, -13, -8, 0), 7), c(-13, -8, 0, 0, 3, 5, 15))))
    stopifnot(isTRUE(all.equal(candidate(c(-1, 0, 2, 5, 3, -10), 2), c(3, 5))))
    stopifnot(isTRUE(all.equal(candidate(c(1, 0, 5, -7), 1), c(5))))
    stopifnot(isTRUE(all.equal(candidate(c(4, -4), 2), c(-4, 4))))
    stopifnot(isTRUE(all.equal(candidate(c(-10, 10), 2), c(-10, 10))))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, -23, 243, -400, 0), 0), c())))
}
test_humaneval()


Prompt:
# For a given number n, find the largest number that divides n evenly, smaller than n
# >>> largest_divisor(15)
# 5
largest_divisor <- function(n) {

test_humaneval <- function() {
    candidate <- largest_divisor
    stopifnot(isTRUE(all.equal(candidate(3), 1)))
    stopifnot(isTRUE(all.equal(candidate(7), 1)))
    stopifnot(isTRUE(all.equal(candidate(10), 5)))
    stopifnot(isTRUE(all.equal(candidate(100), 50)))
    stopifnot(isTRUE(all.equal(candidate(49), 7)))
}
test_humaneval()


Prompt:
# Given a vector of non-negative integers, return a cor of the given vector after sorting,
# you will sort the given vector in ascending order if the sum( first index value, last index value) is odd,
# or sort it in descending order if the sum( first index value, last index value) is even.
# Note:
# * don't change the given vector.
# Examples:
# >>> sort_array(c())
# c()
# >>> sort_array(c(5))
# c(5)
# >>> sort_array(c(2, 4, 3, 0, 1, 5))
# c(0, 1, 2, 3, 4, 5)
# >>> sort_array(c(2, 4, 3, 0, 1, 5, 6))
# c(6, 5, 4, 3, 2, 1, 0)
sort_array <- function(array) {

test_humaneval <- function() {
    candidate <- sort_array
    stopifnot(isTRUE(all.equal(candidate(c()), c())))
    stopifnot(isTRUE(all.equal(candidate(c(5)), c(5))))
    stopifnot(isTRUE(all.equal(candidate(c(2, 4, 3, 0, 1, 5)), c(0, 1, 2, 3, 4, 5))))
    stopifnot(isTRUE(all.equal(candidate(c(2, 4, 3, 0, 1, 5, 6)), c(6, 5, 4, 3, 2, 1, 0))))
    stopifnot(isTRUE(all.equal(candidate(c(2, 1)), c(1, 2))))
    stopifnot(isTRUE(all.equal(candidate(c(15, 42, 87, 32, 11, 0)), c(0, 11, 15, 32, 42, 87))))
    stopifnot(isTRUE(all.equal(candidate(c(21, 14, 23, 11)), c(23, 21, 14, 11))))
}
test_humaneval()


Prompt:
# 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 * 2 * ... * i).
# Example:
# >>> f(5)
# c(1, 2, 6, 24, 15)
f <- function(n) {

test_humaneval <- function() {
    candidate <- f
    stopifnot(isTRUE(all.equal(candidate(5), c(1, 2, 6, 24, 15))))
    stopifnot(isTRUE(all.equal(candidate(7), c(1, 2, 6, 24, 15, 720, 28))))
    stopifnot(isTRUE(all.equal(candidate(1), c(1))))
    stopifnot(isTRUE(all.equal(candidate(3), c(1, 2, 6))))
}
test_humaneval()


Prompt:
# Write a function that takes an integer a and returns TRUE
# if this ingeger is a cube of some integer number.
# Note: you may assume the input is always valid.
# Examples:
# >>> iscube(1)
# TRUE
# >>> iscube(2)
# FALSE
# >>> iscube(-1)
# TRUE
# >>> iscube(64)
# TRUE
# >>> iscube(0)
# TRUE
# >>> iscube(180)
# FALSE
iscube <- function(a) {

test_humaneval <- function() {
    candidate <- iscube
    stopifnot(isTRUE(all.equal(candidate(1), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(2), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(-1), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(64), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(180), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(1000), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(0), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(1729), FALSE)))
}
test_humaneval()


Prompt:
# Write a function that takes a message, and encodes in such a
# way that it swaps case of all letters, replaces all vowels in
# the message with the letter that appears 2 places ahead of that
# vowel in the english alphabet.
# Assume only letters.
# Examples:
# >>> encode('test')
# 'TGST'
# >>> encode('This is a message')
# 'tHKS KS C MGSSCGG'
encode <- function(message) {

test_humaneval <- function() {
    candidate <- encode
    stopifnot(isTRUE(all.equal(candidate('TEST'), 'tgst')))
    stopifnot(isTRUE(all.equal(candidate('Mudasir'), 'mWDCSKR')))
    stopifnot(isTRUE(all.equal(candidate('YES'), 'ygs')))
    stopifnot(isTRUE(all.equal(candidate('This is a message'), 'tHKS KS C MGSSCGG')))
    stopifnot(isTRUE(all.equal(candidate('I DoNt KnOw WhAt tO WrItE'), 'k dQnT kNqW wHcT Tq wRkTg')))
}
test_humaneval()


Prompt:
# You'll be given a string of words, and your task is to count the number
# of boredoms. A boredom is a sentence that starts with the word "I".
# Sentences are delimited by '.', '?' or '!'.
# For example:
# >>> is_bored('Hello world')
# 0
# >>> is_bored('The sky is blue. The sun is shining. I love this weather')
# 1
is_bored <- function(S) {

test_humaneval <- function() {
    candidate <- is_bored
    stopifnot(isTRUE(all.equal(candidate('Hello world'), 0)))
    stopifnot(isTRUE(all.equal(candidate('Is the sky blue?'), 0)))
    stopifnot(isTRUE(all.equal(candidate('I love It !'), 1)))
    stopifnot(isTRUE(all.equal(candidate('bIt'), 0)))
    stopifnot(isTRUE(all.equal(candidate('I feel good today. I will be productive. will kill It'), 2)))
    stopifnot(isTRUE(all.equal(candidate('You and I are going for a walk'), 0)))
}
test_humaneval()


Prompt:
# 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(c(1, 3, 5, 0))
# FALSE
# >>> pairs_sum_to_zero(c(1, 3, -2, 1))
# FALSE
# >>> pairs_sum_to_zero(c(1, 2, 3, 7))
# FALSE
# >>> pairs_sum_to_zero(c(2, 4, -5, 3, 5, 7))
# TRUE
# >>> pairs_sum_to_zero(c(1))
# FALSE
pairs_sum_to_zero <- function(l) {

test_humaneval <- function() {
    candidate <- pairs_sum_to_zero
    stopifnot(isTRUE(all.equal(candidate(c(1, 3, 5, 0)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 3, -2, 1)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 7)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(2, 4, -5, 3, 5, 7)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(-3, 9, -1, 3, 2, 30)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(-3, 9, -1, 3, 2, 31)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(-3, 9, -1, 4, 2, 30)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(-3, 9, -1, 4, 2, 31)), FALSE)))
}
test_humaneval()


Prompt:
# 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 two sides is greater
# than the third side.
# Example:
# >>> triangle_area(3, 4, 5)
# 6.0
# >>> triangle_area(1, 2, 10)
# -1
triangle_area <- function(a, b, c) {

test_humaneval <- function() {
    candidate <- triangle_area
    stopifnot(isTRUE(all.equal(candidate(3, 4, 5), 6.0)))
    stopifnot(isTRUE(all.equal(candidate(1, 2, 10), -1)))
    stopifnot(isTRUE(all.equal(candidate(4, 8, 5), 8.18)))
    stopifnot(isTRUE(all.equal(candidate(2, 2, 2), 1.73)))
    stopifnot(isTRUE(all.equal(candidate(1, 2, 3), -1)))
    stopifnot(isTRUE(all.equal(candidate(10, 5, 7), 16.25)))
    stopifnot(isTRUE(all.equal(candidate(2, 6, 3), -1)))
    stopifnot(isTRUE(all.equal(candidate(1, 1, 1), 0.43)))
    stopifnot(isTRUE(all.equal(candidate(2, 2, 10), -1)))
}
test_humaneval()


Prompt:
# 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 list containing all planets whose orbits are
# located between the orbit of planet1 and the orbit of planet2, sorted by
# the proximity to the sun.
# The function should return an empty list if planet1 or planet2
# are not correct planet names.
# Examples
# >>> bf('Jupiter', 'Neptune')
# c('Saturn', 'Uranus')
# >>> bf('Earth', 'Mercury')
# 'Venus'
# >>> bf('Mercury', 'Uranus')
# c('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn')
bf <- function(planet1, planet2) {

test_humaneval <- function() {
    candidate <- bf
    stopifnot(isTRUE(all.equal(candidate('Jupiter', 'Neptune'), c('Saturn', 'Uranus'))))
    stopifnot(isTRUE(all.equal(candidate('Earth', 'Mercury'), c('Venus'))))
    stopifnot(isTRUE(all.equal(candidate('Mercury', 'Uranus'), c('Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn'))))
    stopifnot(isTRUE(all.equal(candidate('Neptune', 'Venus'), c('Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus'))))
    stopifnot(isTRUE(all.equal(candidate('Earth', 'Earth'), c())))
    stopifnot(isTRUE(all.equal(candidate('Mars', 'Earth'), c())))
    stopifnot(isTRUE(all.equal(candidate('Jupiter', 'Makemake'), c())))
}
test_humaneval()


Prompt:
# 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
digits <- function(n) {

test_humaneval <- function() {
    candidate <- digits
    stopifnot(isTRUE(all.equal(candidate(5), 5)))
    stopifnot(isTRUE(all.equal(candidate(54), 5)))
    stopifnot(isTRUE(all.equal(candidate(120), 1)))
    stopifnot(isTRUE(all.equal(candidate(5014), 5)))
    stopifnot(isTRUE(all.equal(candidate(98765), 315)))
    stopifnot(isTRUE(all.equal(candidate(5576543), 2625)))
    stopifnot(isTRUE(all.equal(candidate(2468), 0)))
}
test_humaneval()


Prompt:
# You will be given a string of words separated by commas or spaces. Your task is
# to split the string into words and return a vector of the words.
# For example:
# >>> words_string('Hi, my name is John')
# c('Hi', 'my', 'name', 'is', 'John')
# >>> words_string('One, two, three, four, five, six')
# c('One', 'two', 'three', 'four', 'five', 'six')
words_string <- function(s) {

test_humaneval <- function() {
    candidate <- words_string
    stopifnot(isTRUE(all.equal(candidate('Hi, my name is John'), c('Hi', 'my', 'name', 'is', 'John'))))
    stopifnot(isTRUE(all.equal(candidate('One, two, three, four, five, six'), c('One', 'two', 'three', 'four', 'five', 'six'))))
    stopifnot(isTRUE(all.equal(candidate('Hi, my name'), c('Hi', 'my', 'name'))))
    stopifnot(isTRUE(all.equal(candidate('One,, two, three, four, five, six,'), c('One', 'two', 'three', 'four', 'five', 'six'))))
    stopifnot(isTRUE(all.equal(candidate(''), c())))
    stopifnot(isTRUE(all.equal(candidate('ahmed     , gamal'), c('ahmed', 'gamal'))))
}
test_humaneval()


Prompt:
# 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
how_many_times <- function(string, substring) {

test_humaneval <- function() {
    candidate <- how_many_times
    stopifnot(isTRUE(all.equal(candidate('', 'x'), 0)))
    stopifnot(isTRUE(all.equal(candidate('xyxyxyx', 'x'), 4)))
    stopifnot(isTRUE(all.equal(candidate('cacacacac', 'cac'), 4)))
    stopifnot(isTRUE(all.equal(candidate('john doe', 'john'), 1)))
}
test_humaneval()


Prompt:
# Create a function that takes integers, floats, or strings representing
# real numbers, and returns the larger variable in its given variable type.
# Return NULL if the values are equal.
# Note: If a real number is represented as a string, the floating point might be . or ,
# >>> compare_one(1, 2.5)
# 2.5
# >>> compare_one(1, '2,3')
# '2,3'
# >>> compare_one('5,1', '6')
# '6'
# >>> compare_one('1', 1)
# NULL
compare_one <- function(a, b) {

test_humaneval <- function() {
    candidate <- compare_one
    stopifnot(isTRUE(all.equal(candidate(1, 2), 2)))
    stopifnot(isTRUE(all.equal(candidate(1, 2.5), 2.5)))
    stopifnot(isTRUE(all.equal(candidate(2, 3), 3)))
    stopifnot(isTRUE(all.equal(candidate(5, 6), 6)))
    stopifnot(isTRUE(all.equal(candidate(1, '2,3'), '2,3')))
    stopifnot(isTRUE(all.equal(candidate('5,1', '6'), '6')))
    stopifnot(isTRUE(all.equal(candidate('1', '2'), '2')))
    stopifnot(isTRUE(all.equal(candidate('1', 1), NULL)))
}
test_humaneval()


Prompt:
# remove_vowels is a function that takes string and returns string without vowels.
# >>> remove_vowels('')
# ''
# >>> remove_vowels('abcdef')
# 'bcdf'
# >>> remove_vowels('aaaaa')
# ''
# >>> remove_vowels('aaBAA')
# 'B'
# >>> remove_vowels('zbcd')
# 'zbcd'
remove_vowels <- function(text) {

test_humaneval <- function() {
    candidate <- remove_vowels
    stopifnot(isTRUE(all.equal(candidate(''), '')))
    stopifnot(isTRUE(all.equal(candidate('abcdef\nghijklm'), 'bcdf\nghjklm')))
    stopifnot(isTRUE(all.equal(candidate('fedcba'), 'fdcb')))
    stopifnot(isTRUE(all.equal(candidate('eeeee'), '')))
    stopifnot(isTRUE(all.equal(candidate('acBAA'), 'cB')))
    stopifnot(isTRUE(all.equal(candidate('EcBOO'), 'cB')))
    stopifnot(isTRUE(all.equal(candidate('ybcd'), 'ybcd')))
}
test_humaneval()


Prompt:
# 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(c(1, 2, 3, 4))
# c(1, 4, 2, 3)
# >>> strange_sort_list(c(5, 5, 5, 5))
# c(5, 5, 5, 5)
# >>> strange_sort_list(c())
# c()
strange_sort_list <- function(lst) {

test_humaneval <- function() {
    candidate <- strange_sort_list
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4)), c(1, 4, 2, 3))))
    stopifnot(isTRUE(all.equal(candidate(c(5, 6, 7, 8, 9)), c(5, 9, 6, 8, 7))))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4, 5)), c(1, 5, 2, 4, 3))))
    stopifnot(isTRUE(all.equal(candidate(c(5, 6, 7, 8, 9, 1)), c(1, 9, 5, 8, 6, 7))))
    stopifnot(isTRUE(all.equal(candidate(c(5, 5, 5, 5)), c(5, 5, 5, 5))))
    stopifnot(isTRUE(all.equal(candidate(c()), c())))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4, 5, 6, 7, 8)), c(1, 8, 2, 7, 3, 6, 4, 5))))
    stopifnot(isTRUE(all.equal(candidate(c(0, 2, 2, 2, 5, 5, -5, -5)), c(-5, 5, -5, 5, 0, 2, 2, 2))))
    stopifnot(isTRUE(all.equal(candidate(c(111111)), c(111111))))
}
test_humaneval()


Prompt:
# 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(c(1.0, 2.0, 3.0, 4.0, 5.0, 2.2))
# c(2.0, 2.2)
# >>> find_closest_elements(c(1.0, 2.0, 3.0, 4.0, 5.0, 2.0))
# c(2.0, 2.0)
find_closest_elements <- function(numbers) {

test_humaneval <- function() {
    candidate <- find_closest_elements
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 3.9, 4.0, 5.0, 2.2)), c(3.9, 4.0))))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 5.9, 4.0, 5.0)), c(5.0, 5.9))))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 3.0, 4.0, 5.0, 2.2)), c(2.0, 2.2))))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 3.0, 4.0, 5.0, 2.0)), c(2.0, 2.0))))
    stopifnot(isTRUE(all.equal(candidate(c(1.1, 2.2, 3.1, 4.1, 5.1)), c(2.2, 3.1))))
}
test_humaneval()


Prompt:
# Your task is to write a function that returns true if a number x is a simple
# power of n and false in other cases.
# x is a simple power of n if n**int=x
# For example:
# >>> is_simple_power(1, 4)
# TRUE
# >>> is_simple_power(2, 2)
# TRUE
# >>> is_simple_power(8, 2)
# TRUE
# >>> is_simple_power(3, 2)
# FALSE
# >>> is_simple_power(3, 1)
# FALSE
# >>> is_simple_power(5, 3)
# FALSE
is_simple_power <- function(x, n) {

test_humaneval <- function() {
    candidate <- is_simple_power
    stopifnot(isTRUE(all.equal(candidate(16, 2), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(143214, 16), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(4, 2), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(9, 3), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(16, 4), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(24, 2), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(128, 4), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(12, 6), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(1, 1), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(1, 12), TRUE)))
}
test_humaneval()


Prompt:
# prime_fib returns n-th number that is a Fibonacci number and it's also prime.
# >>> prime_fib(1)
# 2
# >>> prime_fib(2)
# 3
# >>> prime_fib(3)
# 5
# >>> prime_fib(4)
# 13
# >>> prime_fib(5)
# 89
prime_fib <- function(n) {

test_humaneval <- function() {
    candidate <- prime_fib
    stopifnot(isTRUE(all.equal(candidate(1), 2)))
    stopifnot(isTRUE(all.equal(candidate(2), 3)))
    stopifnot(isTRUE(all.equal(candidate(3), 5)))
    stopifnot(isTRUE(all.equal(candidate(4), 13)))
    stopifnot(isTRUE(all.equal(candidate(5), 89)))
    stopifnot(isTRUE(all.equal(candidate(6), 233)))
    stopifnot(isTRUE(all.equal(candidate(7), 1597)))
    stopifnot(isTRUE(all.equal(candidate(8), 28657)))
    stopifnot(isTRUE(all.equal(candidate(9), 514229)))
    stopifnot(isTRUE(all.equal(candidate(10), 433494437)))
}
test_humaneval()


Prompt:
# 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:
# >>> order_by_points(c(1, 11, -1, -11, -12))
# c(-1, -11, 1, -12, 11)
# >>> order_by_points(c())
# c()
order_by_points <- function(nums) {


Prompt:
# Check if in given list of numbers, are any two numbers closer to each other than
# given threshold.
# >>> has_close_elements(c(1.0, 2.0, 3.0), 0.5)
# FALSE
# >>> has_close_elements(c(1.0, 2.8, 3.0, 4.0, 5.0, 2.0), 0.3)
# TRUE
has_close_elements <- function(numbers, threshold) {

test_humaneval <- function() {
    candidate <- has_close_elements
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 3.9, 4.0, 5.0, 2.2), 0.3), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 3.9, 4.0, 5.0, 2.2), 0.05), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 5.9, 4.0, 5.0), 0.95), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 5.9, 4.0, 5.0), 0.8), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 3.0, 4.0, 5.0, 2.0), 0.1), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1.1, 2.2, 3.1, 4.1, 5.1), 1.0), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1.1, 2.2, 3.1, 4.1, 5.1), 0.5), FALSE)))
}
test_humaneval()


Prompt:
# Find the shortest palindrome that begins with a supplied string.
# Algorithm idea is simple:
# - Find the longest postfix of supplied string that is a palindrome.
# - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
# >>> make_palindrome('')
# ''
# >>> make_palindrome('cat')
# 'catac'
# >>> make_palindrome('cata')
# 'catac'
make_palindrome <- function(string) {

test_humaneval <- function() {
    candidate <- make_palindrome
    stopifnot(isTRUE(all.equal(candidate(''), '')))
    stopifnot(isTRUE(all.equal(candidate('x'), 'x')))
    stopifnot(isTRUE(all.equal(candidate('xyz'), 'xyzyx')))
    stopifnot(isTRUE(all.equal(candidate('xyx'), 'xyx')))
    stopifnot(isTRUE(all.equal(candidate('jerry'), 'jerryrrej')))
}
test_humaneval()


Prompt:
# 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'
string_xor <- function(a, b) {

test_humaneval <- function() {
    candidate <- string_xor
    stopifnot(isTRUE(all.equal(candidate('111000', '101010'), '010010')))
    stopifnot(isTRUE(all.equal(candidate('1', '1'), '0')))
    stopifnot(isTRUE(all.equal(candidate('0101', '0000'), '0101')))
}
test_humaneval()


Prompt:
# 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 should return the special
# factorial of this integer.
special_factorial <- function(n) {

test_humaneval <- function() {
    candidate <- special_factorial
    stopifnot(isTRUE(all.equal(candidate(4), 288)))
    stopifnot(isTRUE(all.equal(candidate(5), 34560)))
    stopifnot(isTRUE(all.equal(candidate(7), 125411328000)))
    stopifnot(isTRUE(all.equal(candidate(1), 1)))
}
test_humaneval()


Prompt:
# Given a non-empty vector 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:
# >>> add_elements(c(111, 21, 3, 4000, 5, 6, 7, 8, 9), 4)
# 24
# Constraints:
# 1. 1 <= len(arr) <= 100
# 2. 1 <= k <= len(arr)
add_elements <- function(arr, k) {

test_humaneval <- function() {
    candidate <- add_elements
    stopifnot(isTRUE(all.equal(candidate(c(1, -2, -3, 41, 57, 76, 87, 88, 99), 3), -4)))
    stopifnot(isTRUE(all.equal(candidate(c(111, 121, 3, 4000, 5, 6), 2), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(11, 21, 3, 90, 5, 6, 7, 8, 9), 4), 125)))
    stopifnot(isTRUE(all.equal(candidate(c(111, 21, 3, 4000, 5, 6, 7, 8, 9), 4), 24)))
    stopifnot(isTRUE(all.equal(candidate(c(1), 1), 1)))
}
test_humaneval()


Prompt:
# The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
# fib4(0) -> 0
# fib4(1) -> 0
# fib4(2) -> 2
# fib4(3) -> 0
# fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
# Please write a function to efficiently compute the n-th element of the fib4 number sequence.  Do not use recursion.
# >>> fib4(5)
# 4
# >>> fib4(6)
# 8
# >>> fib4(7)
# 14
fib4 <- function(n) {

test_humaneval <- function() {
    candidate <- fib4
    stopifnot(isTRUE(all.equal(candidate(5), 4)))
    stopifnot(isTRUE(all.equal(candidate(8), 28)))
    stopifnot(isTRUE(all.equal(candidate(10), 104)))
    stopifnot(isTRUE(all.equal(candidate(12), 386)))
}
test_humaneval()


Prompt:
# 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:
# >>> unique_digits(c(15, 33, 1422, 1))
# c(1, 15, 33)
# >>> unique_digits(c(152, 323, 1422, 10))
# c()
unique_digits <- function(x) {

test_humaneval <- function() {
    candidate <- unique_digits
    stopifnot(isTRUE(all.equal(candidate(c(15, 33, 1422, 1)), c(1, 15, 33))))
    stopifnot(isTRUE(all.equal(candidate(c(152, 323, 1422, 10)), c())))
    stopifnot(isTRUE(all.equal(candidate(c(12345, 2033, 111, 151)), c(111, 151))))
    stopifnot(isTRUE(all.equal(candidate(c(135, 103, 31)), c(31, 135))))
}
test_humaneval()


Prompt:
# 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 assume the input string contains only letters and spaces.
# Examples:
# >>> select_words('Mary had a little lamb', 4)
# c('little')
# >>> select_words('Mary had a little lamb', 3)
# c('Mary', 'lamb')
# >>> select_words('simple white space', 2)
# c()
# >>> select_words('Hello world', 4)
# c('world')
# >>> select_words('Uncle sam', 3)
# c('Uncle')
select_words <- function(s, n) {

test_humaneval <- function() {
    candidate <- select_words
    stopifnot(isTRUE(all.equal(candidate('Mary had a little lamb', 4), c('little'))))
    stopifnot(isTRUE(all.equal(candidate('Mary had a little lamb', 3), c('Mary', 'lamb'))))
    stopifnot(isTRUE(all.equal(candidate('simple white space', 2), c())))
    stopifnot(isTRUE(all.equal(candidate('Hello world', 4), c('world'))))
    stopifnot(isTRUE(all.equal(candidate('Uncle sam', 3), c('Uncle'))))
    stopifnot(isTRUE(all.equal(candidate('', 4), c())))
    stopifnot(isTRUE(all.equal(candidate('a b c d e f', 1), c('b', 'c', 'd', 'f'))))
}
test_humaneval()


Prompt:
# 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(c(1, 2), 5)
# FALSE
# # 1+2 is less than the maximum possible weight, but it's unbalanced.
# >>> will_it_fly(c(3, 2, 3), 1)
# FALSE
# # it's balanced, but 3+2+3 is more than the maximum possible weight.
# >>> will_it_fly(c(3, 2, 3), 9)
# TRUE
# # 3+2+3 is less than the maximum possible weight, and it's balanced.
# >>> will_it_fly(c(3), 5)
# TRUE
# # 3 is less than the maximum possible weight, and it's balanced.
will_it_fly <- function(q, w) {

test_humaneval <- function() {
    candidate <- will_it_fly
    stopifnot(isTRUE(all.equal(candidate(c(3, 2, 3), 9), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2), 5), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(3), 5), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(3, 2, 3), 1), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3), 6), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(5), 5), TRUE)))
}
test_humaneval()


Prompt:
# Return n-th Fibonacci number.
# >>> fib(10)
# 55
# >>> fib(1)
# 1
# >>> fib(8)
# 21
fib <- function(n) {

test_humaneval <- function() {
    candidate <- fib
    stopifnot(isTRUE(all.equal(candidate(10), 55)))
    stopifnot(isTRUE(all.equal(candidate(1), 1)))
    stopifnot(isTRUE(all.equal(candidate(8), 21)))
    stopifnot(isTRUE(all.equal(candidate(11), 89)))
    stopifnot(isTRUE(all.equal(candidate(12), 144)))
}
test_humaneval()


Prompt:
# 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 letters
# in the extension's name, the strength is given by the fraction CAP - SM.
# You should find the strongest extension and return a string in this
# format: ClassName.StrongestExtensionName.
# If there are two or more extensions with the same strength, you should
# choose the one that comes first in the list.
# For example, if you are given "Slices" as the class and a list of the
# extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
# return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
# (its strength is -1).
# Example:
# >>> Strongest_Extension('my_class', c('AA', 'Be', 'CC'))
# 'my_class.AA'
Strongest_Extension <- function(class_name, extensions) {

test_humaneval <- function() {
    candidate <- Strongest_Extension
    stopifnot(isTRUE(all.equal(candidate('Watashi', c('tEN', 'niNE', 'eIGHt8OKe')), 'Watashi.eIGHt8OKe')))
    stopifnot(isTRUE(all.equal(candidate('Boku123', c('nani', 'NazeDa', 'YEs.WeCaNe', '32145tggg')), 'Boku123.YEs.WeCaNe')))
    stopifnot(isTRUE(all.equal(candidate('__YESIMHERE', c('t', 'eMptY', 'nothing', 'zeR00', 'NuLl__', '123NoooneB321')), '__YESIMHERE.NuLl__')))
    stopifnot(isTRUE(all.equal(candidate('K', c('Ta', 'TAR', 't234An', 'cosSo')), 'K.TAR')))
    stopifnot(isTRUE(all.equal(candidate('__HAHA', c('Tab', '123', '781345', '-_-')), '__HAHA.123')))
    stopifnot(isTRUE(all.equal(candidate('YameRore', c('HhAas', 'okIWILL123', 'WorkOut', 'Fails', '-_-')), 'YameRore.okIWILL123')))
    stopifnot(isTRUE(all.equal(candidate('finNNalLLly', c('Die', 'NowW', 'Wow', 'WoW')), 'finNNalLLly.WoW')))
    stopifnot(isTRUE(all.equal(candidate('_', c('Bb', '91245')), '_.Bb')))
    stopifnot(isTRUE(all.equal(candidate('Sp', c('671235', 'Bb')), 'Sp.671235')))
}
test_humaneval()


Prompt:
# 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 parentheses in S
# are balanced. For example: the string '(())()' is good, while the string
# '())' is not.
# Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
# Examples:
# >>> match_parens(c('()(', ')'))
# 'Yes'
# >>> match_parens(c(')', ')'))
# 'No'
match_parens <- function(lst) {

test_humaneval <- function() {
    candidate <- match_parens
    stopifnot(isTRUE(all.equal(candidate(c('()(', ')')), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate(c(')', ')')), 'No')))
    stopifnot(isTRUE(all.equal(candidate(c('(()(())', '())())')), 'No')))
    stopifnot(isTRUE(all.equal(candidate(c(')())', '(()()(')), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate(c('(())))', '(()())((')), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate(c('()', '())')), 'No')))
    stopifnot(isTRUE(all.equal(candidate(c('(()(', '()))()')), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate(c('((((', '((())')), 'No')))
    stopifnot(isTRUE(all.equal(candidate(c(')(()', '(()(')), 'No')))
    stopifnot(isTRUE(all.equal(candidate(c(')(', ')(')), 'No')))
    stopifnot(isTRUE(all.equal(candidate(c('(', ')')), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate(c(')', '(')), 'Yes')))
}
test_humaneval()


Prompt:
# You are given a list of integers.
# Write a function next_smallest() that returns the 2nd smallest element of the list.
# Return NULL if there is no such element.
# >>> next_smallest(c(1, 2, 3, 4, 5))
# 2
# >>> next_smallest(c(5, 1, 4, 3, 2))
# 2
# >>> next_smallest(c())
# NULL
# >>> next_smallest(c(1, 1))
# NULL
next_smallest <- function(lst) {

test_humaneval <- function() {
    candidate <- next_smallest
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4, 5)), 2)))
    stopifnot(isTRUE(all.equal(candidate(c(5, 1, 4, 3, 2)), 2)))
    stopifnot(isTRUE(all.equal(candidate(c()), NULL)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 1)), NULL)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 1, 1, 1, 0)), 1)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 1)), NULL)))
    stopifnot(isTRUE(all.equal(candidate(c(-35, 34, 12, -45)), -35)))
}
test_humaneval()


Prompt:
# Create a function that takes 3 numbers.
# Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
# Returns false in any other cases.
# Examples
# >>> any_int(5, 2, 7)
# TRUE
# >>> any_int(3, 2, 2)
# FALSE
# >>> any_int(3, -2, 1)
# TRUE
# >>> any_int(3.6, -2.2, 2)
# FALSE
any_int <- function(x, y, z) {

test_humaneval <- function() {
    candidate <- any_int
    stopifnot(isTRUE(all.equal(candidate(2, 3, 1), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(2.5, 2, 3), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(1.5, 5, 3.5), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(2, 6, 2), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(4, 2, 2), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(2.2, 2.2, 2.2), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(-4, 6, 2), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(2, 1, 1), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(3, 4, 7), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(3.0, 4, 7), FALSE)))
}
test_humaneval()


Prompt:
# 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.
# >>> truncate_number(3.5)
# 0.5
truncate_number <- function(number) {

test_humaneval <- function() {
    candidate <- truncate_number
    stopifnot(isTRUE(all.equal(candidate(3.5), 0.5)))
    stopifnot(isTRUE(all.equal(candidate(1.25), 0.25)))
    stopifnot(isTRUE(all.equal(candidate(123.0), 0.0)))
}
test_humaneval()


Prompt:
# Return list with elements incremented by 1.
# >>> incr_list(c(1, 2, 3))
# c(2, 3, 4)
# >>> incr_list(c(5, 3, 5, 2, 3, 3, 9, 0, 123))
# c(6, 4, 6, 3, 4, 4, 10, 1, 124)
incr_list <- function(l) {

test_humaneval <- function() {
    candidate <- incr_list
    stopifnot(isTRUE(all.equal(candidate(c()), c())))
    stopifnot(isTRUE(all.equal(candidate(c(3, 2, 1)), c(4, 3, 2))))
    stopifnot(isTRUE(all.equal(candidate(c(5, 2, 5, 2, 3, 3, 9, 0, 123)), c(6, 3, 6, 3, 4, 4, 10, 1, 124))))
}
test_humaneval()


Prompt:
# 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:
# >>> x_or_y(7, 34, 12)
# 34
# >>> x_or_y(15, 8, 5)
# 5
x_or_y <- function(n, x, y) {

test_humaneval <- function() {
    candidate <- x_or_y
    stopifnot(isTRUE(all.equal(candidate(7, 34, 12), 34)))
    stopifnot(isTRUE(all.equal(candidate(15, 8, 5), 5)))
    stopifnot(isTRUE(all.equal(candidate(3, 33, 5212), 33)))
    stopifnot(isTRUE(all.equal(candidate(1259, 3, 52), 3)))
    stopifnot(isTRUE(all.equal(candidate(7919, -1, 12), -1)))
    stopifnot(isTRUE(all.equal(candidate(3609, 1245, 583), 583)))
    stopifnot(isTRUE(all.equal(candidate(91, 56, 129), 129)))
    stopifnot(isTRUE(all.equal(candidate(6, 34, 1234), 1234)))
    stopifnot(isTRUE(all.equal(candidate(1, 2, 0), 0)))
    stopifnot(isTRUE(all.equal(candidate(2, 2, 0), 2)))
}
test_humaneval()


Prompt:
# 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
modp <- function(n, p) {

test_humaneval <- function() {
    candidate <- modp
    stopifnot(isTRUE(all.equal(candidate(3, 5), 3)))
    stopifnot(isTRUE(all.equal(candidate(1101, 101), 2)))
    stopifnot(isTRUE(all.equal(candidate(0, 101), 1)))
    stopifnot(isTRUE(all.equal(candidate(3, 11), 8)))
    stopifnot(isTRUE(all.equal(candidate(100, 101), 1)))
    stopifnot(isTRUE(all.equal(candidate(30, 5), 4)))
    stopifnot(isTRUE(all.equal(candidate(31, 5), 3)))
}
test_humaneval()


Prompt:
# Given an integer. return a list that has the number of even and odd digits respectively.
# Example:
# >>> even_odd_count(-12)
# c(1, 1)
# >>> even_odd_count(123)
# c(1, 2)
even_odd_count <- function(num) {

test_humaneval <- function() {
    candidate <- even_odd_count
    stopifnot(isTRUE(all.equal(candidate(7), c(0, 1))))
    stopifnot(isTRUE(all.equal(candidate(-78), c(1, 1))))
    stopifnot(isTRUE(all.equal(candidate(3452), c(2, 2))))
    stopifnot(isTRUE(all.equal(candidate(346211), c(3, 3))))
    stopifnot(isTRUE(all.equal(candidate(-345821), c(3, 3))))
    stopifnot(isTRUE(all.equal(candidate(-2), c(1, 0))))
    stopifnot(isTRUE(all.equal(candidate(-45347), c(2, 3))))
    stopifnot(isTRUE(all.equal(candidate(0), c(1, 0))))
}
test_humaneval()


Prompt:
# You are given a string s.
# Your task is to check if the string is hapr or not.
# A string is hapr if its length is at least 3 and every 3 consecutive letters are distinct
# For example:
# >>> is_happy('a')
# FALSE
# >>> is_happy('aa')
# FALSE
# >>> is_happy('abcd')
# TRUE
# >>> is_happy('aabb')
# FALSE
# >>> is_happy('adb')
# TRUE
# >>> is_happy('xyy')
# FALSE
is_happy <- function(s) {

test_humaneval <- function() {
    candidate <- is_happy
    stopifnot(isTRUE(all.equal(candidate('a'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('aa'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('abcd'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('aabb'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('adb'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('xyy'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('iopaxpoi'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('iopaxioi'), FALSE)))
}
test_humaneval()


Prompt:
# 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
largest_prime_factor <- function(n) {

test_humaneval <- function() {
    candidate <- largest_prime_factor
    stopifnot(isTRUE(all.equal(candidate(15), 5)))
    stopifnot(isTRUE(all.equal(candidate(27), 3)))
    stopifnot(isTRUE(all.equal(candidate(63), 7)))
    stopifnot(isTRUE(all.equal(candidate(330), 11)))
    stopifnot(isTRUE(all.equal(candidate(13195), 29)))
}
test_humaneval()


Prompt:
# Task
# Write a function that takes a string as input and returns the sum of the upper characters only'
# ASCII codes.
# Examples:
# >>> digitSum('')
# 0
# >>> digitSum('abAB')
# 131
# >>> digitSum('abcCd')
# 67
# >>> digitSum('helloE')
# 69
# >>> digitSum('woArBld')
# 131
# >>> digitSum('aAaaaXa')
# 153
digitSum <- function(s) {

test_humaneval <- function() {
    candidate <- digitSum
    stopifnot(isTRUE(all.equal(candidate(''), 0)))
    stopifnot(isTRUE(all.equal(candidate('abAB'), 131)))
    stopifnot(isTRUE(all.equal(candidate('abcCd'), 67)))
    stopifnot(isTRUE(all.equal(candidate('helloE'), 69)))
    stopifnot(isTRUE(all.equal(candidate('woArBld'), 131)))
    stopifnot(isTRUE(all.equal(candidate('aAaaaXa'), 153)))
    stopifnot(isTRUE(all.equal(candidate(' How are yOu?'), 151)))
    stopifnot(isTRUE(all.equal(candidate('You arE Very Smart'), 327)))
}
test_humaneval()


Prompt:
# 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(c(1.0, 2.0, 3.0, 4.0, 5.0))
# c(0.0, 0.25, 0.5, 0.75, 1.0)
rescale_to_unit <- function(numbers) {


Prompt:
# Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
# Examples
# >>> solution(c(5, 8, 7, 1))
# 12
# >>> solution(c(3, 3, 3, 3, 3))
# 9
# >>> solution(c(30, 13, 24, 321))
# 0
solution <- function(lst) {

test_humaneval <- function() {
    candidate <- solution
    stopifnot(isTRUE(all.equal(candidate(c(5, 8, 7, 1)), 12)))
    stopifnot(isTRUE(all.equal(candidate(c(3, 3, 3, 3, 3)), 9)))
    stopifnot(isTRUE(all.equal(candidate(c(30, 13, 24, 321)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(5, 9)), 5)))
    stopifnot(isTRUE(all.equal(candidate(c(2, 4, 8)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(30, 13, 23, 32)), 23)))
    stopifnot(isTRUE(all.equal(candidate(c(3, 13, 2, 9)), 3)))
}
test_humaneval()


Prompt:
# "Given a vector 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 smallest index.
# The plucked node should be returned in a list, [ smalest_value, its index ],
# If there are no even values or the given vector is empty, return [].
# Example 1:
# >>> pluck(c(4, 2, 3))
# c(2, 1)
# Explanation: 2 has the smallest even value, and 2 has the smallest index.
# Example 2:
# >>> pluck(c(1, 2, 3))
# c(2, 1)
# Explanation: 2 has the smallest even value, and 2 has the smallest index.
# Example 3:
# >>> pluck(c())
# c()
# Example 4:
# >>> pluck(c(5, 0, 3, 0, 4, 2))
# c(0, 1)
# Explanation: 0 is the smallest value, but  there are two zeros,
# so we will choose the first zero, which has the smallest index.
# Constraints:
# * 1 <= nodes.length <= 10000
# * 0 <= node.value
pluck <- function(arr) {

test_humaneval <- function() {
    candidate <- pluck
    stopifnot(isTRUE(all.equal(candidate(c(4, 2, 3)), c(2, 1))))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3)), c(2, 1))))
    stopifnot(isTRUE(all.equal(candidate(c()), c())))
    stopifnot(isTRUE(all.equal(candidate(c(5, 0, 3, 0, 4, 2)), c(0, 1))))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 0, 5, 3)), c(0, 3))))
    stopifnot(isTRUE(all.equal(candidate(c(5, 4, 8, 4, 8)), c(4, 1))))
    stopifnot(isTRUE(all.equal(candidate(c(7, 6, 7, 1)), c(6, 1))))
    stopifnot(isTRUE(all.equal(candidate(c(7, 9, 7, 1)), c())))
}
test_humaneval()


Prompt:
# You are given a positive integer n. You have to create an integer vector 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 :
# >>> get_max_triples(5)
# 1
# Explanation:
# a = [1, 3, 7, 13, 21]
# The only valid triple is (1, 7, 13).
get_max_triples <- function(n) {

test_humaneval <- function() {
    candidate <- get_max_triples
    stopifnot(isTRUE(all.equal(candidate(5), 1)))
    stopifnot(isTRUE(all.equal(candidate(6), 4)))
    stopifnot(isTRUE(all.equal(candidate(10), 36)))
    stopifnot(isTRUE(all.equal(candidate(100), 53361)))
}
test_humaneval()


Prompt:
# In this problem, you will implement a function that takes two lists of numbers,
# and determines whether it is possible to perform an exchange of elements
# between them to make lst1 a list of only even numbers.
# There is no limit on the number of exchanged elements between lst1 and lst2.
# If it is possible to exchange elements between the lst1 and lst2 to make
# all the elements of lst1 to be even, return "YES".
# Otherwise, return "NO".
# For example:
# >>> exchange(c(1, 2, 3, 4), c(1, 2, 3, 4))
# 'YES'
# >>> exchange(c(1, 2, 3, 4), c(1, 5, 3, 4))
# 'NO'
# It is assumed that the input lists will be non-empty.
exchange <- function(lst1, lst2) {

test_humaneval <- function() {
    candidate <- exchange
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4), c(1, 2, 3, 4)), 'YES')))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4), c(1, 5, 3, 4)), 'NO')))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4), c(2, 1, 4, 3)), 'YES')))
    stopifnot(isTRUE(all.equal(candidate(c(5, 7, 3), c(2, 6, 4)), 'YES')))
    stopifnot(isTRUE(all.equal(candidate(c(5, 7, 3), c(2, 6, 3)), 'NO')))
    stopifnot(isTRUE(all.equal(candidate(c(3, 2, 6, 1, 8, 9), c(3, 5, 5, 1, 1, 1)), 'NO')))
    stopifnot(isTRUE(all.equal(candidate(c(100, 200), c(200, 200)), 'YES')))
}
test_humaneval()


Prompt:
# Return median of elements in the list l.
# >>> median(c(3, 1, 2, 4, 5))
# 3
# >>> median(c(-10, 4, 6, 1000, 10, 20))
# 15.0
median <- function(l) {

test_humaneval <- function() {
    candidate <- median
    stopifnot(isTRUE(all.equal(candidate(c(3, 1, 2, 4, 5)), 3)))
    stopifnot(isTRUE(all.equal(candidate(c(-10, 4, 6, 1000, 10, 20)), 8.0)))
    stopifnot(isTRUE(all.equal(candidate(c(5)), 5)))
    stopifnot(isTRUE(all.equal(candidate(c(6, 5)), 5.5)))
    stopifnot(isTRUE(all.equal(candidate(c(8, 1, 3, 9, 9, 2, 7)), 7)))
}
test_humaneval()


Prompt:
# Write a function that takes a string and returns TRUE if the string
# length is a prime number or FALSE otherwise
# Examples
# >>> prime_length('Hello')
# TRUE
# >>> prime_length('abcdcba')
# TRUE
# >>> prime_length('kittens')
# TRUE
# >>> prime_length('orange')
# FALSE
prime_length <- function(string) {

test_humaneval <- function() {
    candidate <- prime_length
    stopifnot(isTRUE(all.equal(candidate('Hello'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('abcdcba'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('kittens'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('orange'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('wow'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('world'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('MadaM'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('Wow'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(''), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('HI'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('go'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('gogo'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('aaaaaaaaaaaaaaa'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('Madam'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('M'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('0'), FALSE)))
}
test_humaneval()


Prompt:
# Given a vector arr of integers, find the minimum number of elements that
# need to be changed to make the vector palindromic. A palindromic vector is a vector that
# is read the same backwards and forwards. In one change, you can change one element to any other element.
# For example:
# >>> smallest_change(c(1, 2, 3, 5, 4, 7, 9, 6))
# 4
# >>> smallest_change(c(1, 2, 3, 4, 3, 2, 2))
# 1
# >>> smallest_change(c(1, 2, 3, 2, 1))
# 0
smallest_change <- function(arr) {

test_humaneval <- function() {
    candidate <- smallest_change
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 5, 4, 7, 9, 6)), 4)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4, 3, 2, 2)), 1)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 4, 2)), 1)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 4, 4, 2)), 1)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 2, 1)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(3, 1, 1, 3)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(1)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(0, 1)), 1)))
}
test_humaneval()


Prompt:
# 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:
# >>> lst(c(1.0, 2.0, 3.0))
# 14
# >>> lst(c(1.0, 4.0, 9.0))
# 98
# >>> lst(c(1.0, 3.0, 5.0, 7.0))
# 84
# >>> lst(c(1.4, 4.2, 0.0))
# 29
# >>> lst(c(-2.4, 1.0, 1.0))
# 6
sum_squares <- function(lst) {

test_humaneval <- function() {
    candidate <- sum_squares
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 3.0)), 14)))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 2.0, 3.0)), 14)))
    stopifnot(isTRUE(all.equal(candidate(c(1.0, 3.0, 5.0, 7.0)), 84)))
    stopifnot(isTRUE(all.equal(candidate(c(1.4, 4.2, 0.0)), 29)))
    stopifnot(isTRUE(all.equal(candidate(c(-2.4, 1.0, 1.0)), 6)))
    stopifnot(isTRUE(all.equal(candidate(c(100.0, 1.0, 15.0, 2.0)), 10230)))
    stopifnot(isTRUE(all.equal(candidate(c(10000.0, 10000.0)), 200000000)))
    stopifnot(isTRUE(all.equal(candidate(c(-1.4, 4.6, 6.3)), 75)))
    stopifnot(isTRUE(all.equal(candidate(c(-1.4, 17.9, 18.9, 19.9)), 1086)))
    stopifnot(isTRUE(all.equal(candidate(c(0.0)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(-1.0)), 1)))
    stopifnot(isTRUE(all.equal(candidate(c(-1.0, 1.0, 0.0)), 2)))
}
test_humaneval()


Prompt:
# Create a function which takes a string representing a file's name, and returns
# 'Yes' if the the file's name is valid, and returns 'No' otherwise.
# A file's name is considered to be valid if and only if all the following conditions
# are met:
# - There should not be more than three digits ('0'-'9') in the file's name.
# - The file's name contains exactly one dot '.'
# - The substring before the dot should not be empty, and it starts with a letter from
# the latin alphapet ('a'-'z' and 'A'-'Z').
# - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
# Examples:
# >>> file_name_check('example.txt')
# 'Yes'
# >>> file_name_check('1example.dll')
# 'No'
file_name_check <- function(file_name) {

test_humaneval <- function() {
    candidate <- file_name_check
    stopifnot(isTRUE(all.equal(candidate('example.txt'), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate('1example.dll'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('s1sdf3.asd'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('K.dll'), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate('MY16FILE3.exe'), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate('His12FILE94.exe'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('_Y.txt'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('?aREYA.exe'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('/this_is_valid.dll'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('this_is_valid.wow'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('this_is_valid.txt'), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate('this_is_valid.txtexe'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('#this2_i4s_5valid.ten'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('@this1_is6_valid.exe'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('this_is_12valid.6exe4.txt'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('all.exe.txt'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('I563_No.exe'), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate('Is3youfault.txt'), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate('no_one#knows.dll'), 'Yes')))
    stopifnot(isTRUE(all.equal(candidate('1I563_Yes3.exe'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('I563_Yes3.txtt'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('final..txt'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('final132'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('_f4indsartal132.'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('.txt'), 'No')))
    stopifnot(isTRUE(all.equal(candidate('s.'), 'No')))
}
test_humaneval()


Prompt:
# 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(c(1, 3, 5, 0))
# FALSE
# >>> triples_sum_to_zero(c(1, 3, -2, 1))
# TRUE
# >>> triples_sum_to_zero(c(1, 2, 3, 7))
# FALSE
# >>> triples_sum_to_zero(c(2, 4, -5, 3, 9, 7))
# TRUE
# >>> triples_sum_to_zero(c(1))
# FALSE
triples_sum_to_zero <- function(l) {

test_humaneval <- function() {
    candidate <- triples_sum_to_zero
    stopifnot(isTRUE(all.equal(candidate(c(1, 3, 5, 0)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 3, 5, -1)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 3, -2, 1)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 7)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 5, 7)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(2, 4, -5, 3, 9, 7)), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(c(1)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 3, 5, -100)), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(c(100, 3, 5, -100)), FALSE)))
}
test_humaneval()


Prompt:
# 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.
# Your task is to determine whether the length of intersection of these two
# intervals is a prime number.
# Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)
# which its length is 1, which not a prime number.
# If the length of the intersection is a prime number, return "YES",
# otherwise, return "NO".
# If the two intervals don't intersect, return "NO".
# [input/output] samples:
# >>> intersection(c(1, 2), c(2, 3))
# 'NO'
# >>> intersection(c(-1, 1), c(0, 4))
# 'NO'
# >>> intersection(c(-3, -1), c(-5, 5))
# 'YES'
intersection <- function(interval1, interval2) {

test_humaneval <- function() {
    candidate <- intersection
    stopifnot(isTRUE(all.equal(candidate(c(1, 2), c(2, 3)), 'NO')))
    stopifnot(isTRUE(all.equal(candidate(c(-1, 1), c(0, 4)), 'NO')))
    stopifnot(isTRUE(all.equal(candidate(c(-3, -1), c(-5, 5)), 'YES')))
    stopifnot(isTRUE(all.equal(candidate(c(-2, 2), c(-4, 0)), 'YES')))
    stopifnot(isTRUE(all.equal(candidate(c(-11, 2), c(-1, -1)), 'NO')))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2), c(3, 5)), 'NO')))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2), c(1, 2)), 'NO')))
    stopifnot(isTRUE(all.equal(candidate(c(-2, -2), c(-3, -2)), 'NO')))
}
test_humaneval()


Prompt:
# 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 properly closed) and not nested within each other
# Ignore any spaces in the input string.
# >>> separate_paren_groups('( ) (( )) (( )( ))')
# c('()', '(())', '(()())')
separate_paren_groups <- function(paren_string) {


Prompt:
# 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 given two vectors of scores and guesses of equal length, where each index shows a match.
# Return a vector of the same length denoting how far off each guess was. If they have guessed correctly,
# the value is 0, and if not, the value is the absolute difference between the guess and the score.
# example:
# >>> compare(c(1, 2, 3, 4, 5, 1), c(1, 2, 3, 4, 2, -2))
# c(0, 0, 0, 0, 3, 3)
# >>> compare(c(0, 5, 0, 0, 0, 4), c(4, 1, 1, 0, 0, -2))
# c(4, 4, 1, 0, 0, 6)
compare <- function(game, guess) {

test_humaneval <- function() {
    candidate <- compare
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 4, 5, 1), c(1, 2, 3, 4, 2, -2)), c(0, 0, 0, 0, 3, 3))))
    stopifnot(isTRUE(all.equal(candidate(c(0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0)), c(0, 0, 0, 0, 0, 0))))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3), c(-1, -2, -3)), c(2, 4, 6))))
    stopifnot(isTRUE(all.equal(candidate(c(1, 2, 3, 5), c(-1, 2, 3, 4)), c(2, 0, 0, 1))))
}
test_humaneval()


Prompt:
# Given a positive integer n, return the count of the numbers of n-digit
# positive integers that start or end with 1.
starts_one_ends <- function(n) {

test_humaneval <- function() {
    candidate <- starts_one_ends
    stopifnot(isTRUE(all.equal(candidate(1), 1)))
    stopifnot(isTRUE(all.equal(candidate(2), 18)))
    stopifnot(isTRUE(all.equal(candidate(3), 180)))
    stopifnot(isTRUE(all.equal(candidate(4), 1800)))
    stopifnot(isTRUE(all.equal(candidate(5), 18000)))
}
test_humaneval()


Prompt:
# 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:
# >>> check_if_last_char_is_a_letter('apple pie')
# FALSE
# >>> check_if_last_char_is_a_letter('apple pi e')
# TRUE
# >>> check_if_last_char_is_a_letter('apple pi e ')
# FALSE
# >>> check_if_last_char_is_a_letter('')
# FALSE
check_if_last_char_is_a_letter <- function(txt) {

test_humaneval <- function() {
    candidate <- check_if_last_char_is_a_letter
    stopifnot(isTRUE(all.equal(candidate('apple'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('apple pi e'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('eeeee'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('A'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('Pumpkin pie '), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('Pumpkin pie 1'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(''), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('eeeee e '), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('apple pie'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('apple pi e '), FALSE)))
}
test_humaneval()


Prompt:
# You have to write a function which validates a given date string and
# returns TRUE if the date is valid otherwise FALSE.
# The date is valid if all of the following rules are satisfied:
# 1. The date string is not empty.
# 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
# 3. The months should not be less than 1 or higher than 12.
# 4. The date should be in the format: mm-dd-yyyy
# >>> valid_date('03-11-2000')
# TRUE
# >>> valid_date('15-01-2012')
# FALSE
# >>> valid_date('04-0-2040')
# FALSE
# >>> valid_date('06-04-2020')
# TRUE
# >>> valid_date('06/04/2020')
# FALSE
valid_date <- function(date) {

test_humaneval <- function() {
    candidate <- valid_date
    stopifnot(isTRUE(all.equal(candidate('03-11-2000'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('15-01-2012'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('04-0-2040'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('06-04-2020'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('01-01-2007'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('03-32-2011'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(''), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('04-31-3000'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('06-06-2005'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('21-31-2000'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('04-12-2003'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('04122003'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('20030412'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('2003-04'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('2003-04-12'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('04-2003'), FALSE)))
}
test_humaneval()


Prompt:
# Write a function count_nums which takes a vector of integers and returns
# the number of elements which has a sum of digits > 0.
# If a number is negative, then its first signed digit will be negative:
# e.g. -123 has signed digits -1, 2, and 3.
# >>> count_nums(c())
# 0
# >>> count_nums(c(-1, 11, -11))
# 1
# >>> count_nums(c(1, 1, 2))
# 3
count_nums <- function(arr) {

test_humaneval <- function() {
    candidate <- count_nums
    stopifnot(isTRUE(all.equal(candidate(c()), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(-1, -2, 0)), 0)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 1, 2, -2, 3, 4, 5)), 6)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 6, 9, -6, 0, 1, 5)), 5)))
    stopifnot(isTRUE(all.equal(candidate(c(1, 100, 98, -7, 1, -1)), 4)))
    stopifnot(isTRUE(all.equal(candidate(c(12, 23, 34, -45, -56, 0)), 5)))
    stopifnot(isTRUE(all.equal(candidate(c(0, 1)), 1)))
    stopifnot(isTRUE(all.equal(candidate(c(1)), 1)))
}
test_humaneval()


Prompt:
# Write a function that takes a string and returns an ordered version of it.
# Ordered version of string, is a string where all words (separated by space)
# are replaced by a new word where all the characters arranged in
# ascending order based on ascii value.
# Note: You should keep the order of words and blank spaces in the sentence.
# For example:
# >>> anti_shuffle('Hi')
# 'Hi'
# >>> anti_shuffle('hello')
# 'ehllo'
# >>> anti_shuffle('Hello World!!!')
# 'Hello !!!Wdlor'
anti_shuffle <- function(s) {

test_humaneval <- function() {
    candidate <- anti_shuffle
    stopifnot(isTRUE(all.equal(candidate('Hi'), 'Hi')))
    stopifnot(isTRUE(all.equal(candidate('hello'), 'ehllo')))
    stopifnot(isTRUE(all.equal(candidate('number'), 'bemnru')))
    stopifnot(isTRUE(all.equal(candidate('abcd'), 'abcd')))
    stopifnot(isTRUE(all.equal(candidate('Hello World!!!'), 'Hello !!!Wdlor')))
    stopifnot(isTRUE(all.equal(candidate(''), '')))
    stopifnot(isTRUE(all.equal(candidate('Hi. My name is Mister Robot. How are you?'), '.Hi My aemn is Meirst .Rboot How aer ?ouy')))
}
test_humaneval()


Prompt:
# Checks if given string is a palindrome
# >>> is_palindrome('')
# TRUE
# >>> is_palindrome('aba')
# TRUE
# >>> is_palindrome('aaaaa')
# TRUE
# >>> is_palindrome('zbcd')
# FALSE
is_palindrome <- function(text) {

test_humaneval <- function() {
    candidate <- is_palindrome
    stopifnot(isTRUE(all.equal(candidate(''), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('aba'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('aaaaa'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('zbcd'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('xywyx'), TRUE)))
    stopifnot(isTRUE(all.equal(candidate('xywyz'), FALSE)))
    stopifnot(isTRUE(all.equal(candidate('xywzx'), FALSE)))
}
test_humaneval()


Prompt:
# You are given a word. Your task is to find the closest vowel that stands between
# two consonants from the right side of the word (case sensitive).
# Vowels in the beginning and ending doesn't count. Return empty string if you didn't
# find any vowel met the above condition.
# You may assume that the given string contains English letter only.
# Example:
# >>> get_closest_vowel('yogurt')
# 'u'
# >>> get_closest_vowel('FULL')
# 'U'
# >>> get_closest_vowel('quick')
# ''
# >>> get_closest_vowel('ab')
# ''
get_closest_vowel <- function(word) {

test_humaneval <- function() {
    candidate <- get_closest_vowel
    stopifnot(isTRUE(all.equal(candidate('yogurt'), 'u')))
    stopifnot(isTRUE(all.equal(candidate('full'), 'u')))
    stopifnot(isTRUE(all.equal(candidate('easy'), '')))
    stopifnot(isTRUE(all.equal(candidate('eAsy'), '')))
    stopifnot(isTRUE(all.equal(candidate('ali'), '')))
    stopifnot(isTRUE(all.equal(candidate('bad'), 'a')))
    stopifnot(isTRUE(all.equal(candidate('most'), 'o')))
    stopifnot(isTRUE(all.equal(candidate('ab'), '')))
    stopifnot(isTRUE(all.equal(candidate('ba'), '')))
    stopifnot(isTRUE(all.equal(candidate('quick'), '')))
    stopifnot(isTRUE(all.equal(candidate('anime'), 'i')))
    stopifnot(isTRUE(all.equal(candidate('Asia'), '')))
    stopifnot(isTRUE(all.equal(candidate('Above'), 'o')))
}
test_humaneval()


Prompt:
# Return true if a given number is prime, and false otherwise.
# >>> is_prime(6)
# FALSE
# >>> is_prime(101)
# TRUE
# >>> is_prime(11)
# TRUE
# >>> is_prime(13441)
# TRUE
# >>> is_prime(61)
# TRUE
# >>> is_prime(4)
# FALSE
# >>> is_prime(1)
# FALSE
is_prime <- function(n) {

test_humaneval <- function() {
    candidate <- is_prime
    stopifnot(isTRUE(all.equal(candidate(6), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(101), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(11), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(13441), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(61), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(4), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(1), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(5), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(11), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(17), TRUE)))
    stopifnot(isTRUE(all.equal(candidate(85), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(77), FALSE)))
    stopifnot(isTRUE(all.equal(candidate(255379), FALSE)))
}
test_humaneval()