Prompt:
# Return length of given string
# >>> strlen("")
# 0
# >>> strlen("abc")
# 3
sub strlen {
    my($string) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&strlen;
        if(eq_deeply($candidate->(""),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("x"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("asdasnakj"),9)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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"
sub encrypt {
    my($s) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&encrypt;
        if(eq_deeply($candidate->("hi"),"lm")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("asdfghjkl"),"ewhjklnop")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("gf"),"kj")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("et"),"ix")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("faewfawefaewg"),"jeiajeaijeiak")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("hellomyfriend"),"lippsqcjvmirh")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh"),"hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("a"),"e")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given a hash, return 1 if all keys are strings in lower
# case or all keys are strings in upper case, else return ''.
# The function should return '' is the given hash is empty.
# Examples:
# >>> check_dict_case({"a" => "apple", "b" => "banana"})
# 1
# >>> check_dict_case({"a" => "apple", "A" => "banana", "B" => "banana"})
# ""
# >>> check_dict_case({"a" => "apple", 8 => "banana", "a" => "apple"})
# ""
# >>> check_dict_case({"Name" => "John", "Age" => "36", "City" => "Houston"})
# ""
# >>> check_dict_case({"STATE" => "NC", "ZIP" => "12345"})
# 1
sub check_dict_case {
    my($dict) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&check_dict_case;
        if(eq_deeply($candidate->({"p" => "pineapple", "b" => "banana"}),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->({"p" => "pineapple", "A" => "banana", "B" => "banana"}),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->({"p" => "pineapple", "5" => "banana", "a" => "apple"}),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->({"Name" => "John", "Age" => "36", "City" => "Houston"}),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->({"STATE" => "NC", "ZIP" => "12345"}),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->({"fruit" => "Orange", "taste" => "Sweet"}),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->({}),"")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given a non-empty array of integers lst. add the even elements that are at odd indices..
# Examples:
# >>> add([4, 2, 6, 7])
# 2
sub add {
    my($lst) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&add;
        if(eq_deeply($candidate->([4, 88]),88)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([4, 5, 6, 7, 2, 122]),122)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([4, 0, 6, 7]),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([4, 4, 6, 8]),12)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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"
sub fix_spaces {
    my($text) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&fix_spaces;
        if(eq_deeply($candidate->("Example"),"Example")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Mudasir Hanif "),"Mudasir_Hanif_")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Yellow Yellow  Dirty  Fellow"),"Yellow_Yellow__Dirty__Fellow")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Exa   mple"),"Exa-mple")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("   Exa 1 2 2 mple"),"-Exa_1_2_2_mple")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub fibfib {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&fibfib;
        if(eq_deeply($candidate->(2),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5),4)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(8),24)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10),81)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(12),274)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(14),927)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given an array of numbers, return the sum of squares of the numbers
# in the array that are odd. Ignore numbers that are negative or not integers.
# >>> double_the_difference([1, 3, 2, 0])
# 10
# >>> double_the_difference([-1, -2, 0])
# 0
# >>> double_the_difference([9, -2])
# 81
# >>> double_the_difference([0])
# 0
# If the input array is empty, return 0.
sub double_the_difference {
    my($lst) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&double_the_difference;
        if(eq_deeply($candidate->([]),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5.0, 4.0]),25)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([0.1, 0.2, 0.3]),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-10.0, -20.0, -30.0]),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-1.0, -2.0, 8.0]),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([0.2, 3.0, 5.0]),34)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-9.0, -7.0, -5.0, -3.0, -1.0, 1.0, 3.0, 5.0, 7.0, 9.0]),165)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Filter given array of any plthon values only for integers
# >>> filter_integers(["a", 3.14, 5])
# [5]
# >>> filter_integers([1, 2, 3, "abc", {}, []])
# [1, 2, 3]
sub filter_integers {
    my($values) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&filter_integers;
        if(eq_deeply($candidate->([]),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([4, {}, [], 23.2, 9, "adasd"]),[4, 9])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, "c", 3, 3, "a", "b"]),[3, 3, 3])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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.
sub car_race_collision {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&car_race_collision;
        if(eq_deeply($candidate->(2),4)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3),9)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4),16)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(8),64)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10),100)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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 array 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")
# [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
sub parse_music {
    my($music_string) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&parse_music;
        if(eq_deeply($candidate->(""),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("o o o o"),[4, 4, 4, 4])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(".| .| .| .|"),[1, 1, 1, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("o| o| .| .| o o o o"),[2, 2, 1, 1, 4, 4, 4, 4])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("o| .| o| .| o o| o o|"),[2, 1, 2, 1, 4, 2, 4, 2])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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"
sub decimal_to_binary {
    my($decimal) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&decimal_to_binary;
        if(eq_deeply($candidate->(0),"db0db")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(32),"db100000db")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(103),"db1100111db")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(15),"db1111db")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Return array of all prefixes from shortest to longest of the input string
# >>> all_prefixes("abc")
# ["a", "ab", "abc"]
sub all_prefixes {
    my($string) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&all_prefixes;
        if(eq_deeply($candidate->(""),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("asdfgh"),["a", "as", "asd", "asdf", "asdfg", "asdfgh"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("WWW"),["W", "WW", "WWW"])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Add two numbers x and y
# >>> add(2, 3)
# 5
# >>> add(5, 7)
# 12
sub add {
    my($x, $y) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&add;
        if(eq_deeply($candidate->(0, 1),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 0),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 3),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5, 7),12)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(7, 5),12)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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 an array 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)
# [11, 4]
# >>> eat(4, 8, 9)
# [12, 1]
# >>> eat(1, 10, 10)
# [11, 0]
# >>> eat(2, 11, 5)
# [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 :)
sub eat {
    my($number, $need, $remaining) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&eat;
        if(eq_deeply($candidate->(5, 6, 10),[11, 4])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4, 8, 9),[12, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 10, 10),[11, 0])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 11, 5),[7, 0])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4, 5, 7),[9, 2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4, 5, 1),[5, 0])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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([[0, 0, 1, 0], [0, 1, 0, 0], [1, 1, 1, 1]], 1)
# 6
# Example 2:
# >>> max_fill([[0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 1, 1]], 2)
# 5
# Example 3:
# >>> max_fill([[0, 0, 0], [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
sub max_fill {
    my($grid, $capacity) = @_;


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

use Test::Deep;

sub testhumaneval {
    my $candidate = \&do_algebra;
        if(eq_deeply($candidate->(["**", "*", "+"], [2, 3, 4, 5]),37)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["+", "*", "-"], [2, 3, 4, 5]),9)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["//", "*"], [7, 3, 4]),8)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
# >>> flip_case("Hello")
# "hELLO"
sub flip_case {
    my($string) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&flip_case;
        if(eq_deeply($candidate->(""),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Hello!"),"hELLO!")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("These violent delights have violent ends"),"tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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

use Test::Deep;

sub testhumaneval {
    my $candidate = \&by_length;
        if(eq_deeply($candidate->([2, 1, 1, 4, 5, 8, 2, 3]),["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([]),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, -1, 55]),["One"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, -1, 3, 2]),["Three", "Two", "One"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([9, 4, 8]),["Nine", "Eight", "Four"])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Return array of prime factors of given integer in the order from smallest to largest.
# Each of the factors should be arrayed 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)
# [2, 2, 2]
# >>> factorize(25)
# [5, 5]
# >>> factorize(70)
# [2, 5, 7]
sub factorize {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&factorize;
        if(eq_deeply($candidate->(2),[2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4),[2, 2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(8),[2, 2, 2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(57),[3, 19])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3249),[3, 3, 19, 19])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(185193),[3, 3, 3, 19, 19, 19])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(20577),[3, 19, 19, 19])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(18),[2, 3, 3])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Implement a function that takes an non-negative integer and returns an array of the first n
# integers that are prime numbers and less than n.
# for example:
# >>> count_up_to(5)
# [2, 3]
# >>> count_up_to(11)
# [2, 3, 5, 7]
# >>> count_up_to(0)
# []
# >>> count_up_to(20)
# [2, 3, 5, 7, 11, 13, 17, 19]
# >>> count_up_to(1)
# []
# >>> count_up_to(18)
# [2, 3, 5, 7, 11, 13, 17]
sub count_up_to {
    my($n) = @_;


Prompt:
# Return sorted unique elements in an array
# >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
# [0, 2, 3, 5, 9, 123]
sub unique {
    my($l) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&unique;
        if(eq_deeply($candidate->([5, 3, 5, 2, 3, 3, 9, 0, 123]),[0, 2, 3, 5, 9, 123])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Write a function that accepts two arrays of strings and returns the array that has
# total number of chars in the all strings of the array less than the other array.
# if the two arrays have the same number of chars, return the first array.
# Examples
# >>> total_match([], [])
# []
# >>> total_match(["hi", "admin"], ["hI", "Hi"])
# ["hI", "Hi"]
# >>> total_match(["hi", "admin"], ["hi", "hi", "admin", "project"])
# ["hi", "admin"]
# >>> total_match(["hi", "admin"], ["hI", "hi", "hi"])
# ["hI", "hi", "hi"]
# >>> total_match(["4"], ["1", "2", "3", "4", "5"])
# ["4"]
sub total_match {
    my($lst1, $lst2) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&total_match;
        if(eq_deeply($candidate->([], []),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["hi", "admin"], ["hi", "hi"]),["hi", "hi"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["hi", "admin"], ["hi", "hi", "admin", "project"]),["hi", "admin"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["4"], ["1", "2", "3", "4", "5"]),["4"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["hi", "admin"], ["hI", "Hi"]),["hI", "Hi"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["hi", "admin"], ["hI", "hi", "hi"]),["hI", "hi", "hi"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["hi", "admin"], ["hI", "hi", "hii"]),["hi", "admin"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([], ["this"]),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["this"], []),[])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Return maximum element in the array.
# >>> max_element([1, 2, 3])
# 3
# >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
# 123
sub max_element {
    my($l) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&max_element;
        if(eq_deeply($candidate->([1, 2, 3]),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]),124)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Create a function that takes a string as input which contains only square brackets.
# The function should return 1 if and only if there is a valid subsequence of brackets
# where at least one bracket in the subsequence is nested.
# >>> is_nested("[[]]")
# 1
# >>> is_nested("[]]]]]]][[[[[]")
# ""
# >>> is_nested("[][]")
# ""
# >>> is_nested("[]")
# ""
# >>> is_nested("[[][]]")
# 1
# >>> is_nested("[[]][[")
# 1
sub is_nested {
    my($string) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&is_nested;
        if(eq_deeply($candidate->("[[]]"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[]]]]]]][[[[[]"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[][]"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[]"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[[[[]]]]"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[]]]]]]]]]]"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[][][[]]"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[[]"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[]]"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[[]][["),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[[][]]"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(""),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("[[[[[[[["),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("]]]]]]]]"),"")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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"
sub rounded_avg {
    my($n, $m) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&rounded_avg;
        if(eq_deeply($candidate->(1, 5),"0b11")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(7, 13),"0b1010")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(964, 977),"0b1111001010")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(996, 997),"0b1111100100")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(560, 851),"0b1011000010")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(185, 546),"0b101101110")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(362, 496),"0b110101101")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(350, 902),"0b1001110010")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(197, 233),"0b11010111")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(7, 5),-1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5, 1),-1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5, 5),"0b101")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given an array of strings, where each string consists of only digits, return an array.
# 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(["1234567"])
# ["the number of odd elements 4n the str4ng 4 of the 4nput."]
# >>> odd_count(["3", "11111111"])
# ["the number of odd elements 1n the str1ng 1 of the 1nput.", "the number of odd elements 8n the str8ng 8 of the 8nput."]
sub odd_count {
    my($lst) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&odd_count;
        if(eq_deeply($candidate->(["1234567"]),["the number of odd elements 4n the str4ng 4 of the 4nput."])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["3", "11111111"]),["the number of odd elements 1n the str1ng 1 of the 1nput.", "the number of odd elements 8n the str8ng 8 of the 8nput."])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["271", "137", "314"]),["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."])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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

use Test::Deep;

sub testhumaneval {
    my $candidate = \&move_one_ball;
        if(eq_deeply($candidate->([3, 4, 5, 1, 2]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 5, 10, 1, 2]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([4, 3, 1, 2]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 5, 4, 1, 2]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([]),1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given a positive integer n, return an array that has the number of even and odd
# integer palindromes that fall within the range(1, n), inclusive.
# Example 1:
# >>> even_odd_palindrome(3)
# [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)
# [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 array has the number of even and odd integer palindromes respectively.
sub even_odd_palindrome {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&even_odd_palindrome;
        if(eq_deeply($candidate->(123),[8, 13])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(12),[4, 6])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3),[1, 2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(63),[6, 8])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(25),[5, 6])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(19),[4, 6])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(9),[4, 5])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1),[0, 1])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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)
# ""
# >>> is_equal_to_sum_even(6)
# ""
# >>> is_equal_to_sum_even(8)
# 1
sub is_equal_to_sum_even {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&is_equal_to_sum_even;
        if(eq_deeply($candidate->(4),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(6),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(8),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(11),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(12),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(13),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(16),1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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([3, 1, 2, 4, 5])
# [1, 4, 12, 20]
# >>> derivative([1, 2, 3])
# [2, 6]
sub derivative {
    my($xs) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&derivative;
        if(eq_deeply($candidate->([3, 1, 2, 4, 5]),[1, 4, 12, 20])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3]),[2, 6])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 2, 1]),[2, 2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 2, 1, 0, 4]),[2, 2, 0, 16])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1]),[])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given an array of numbers, return whether or not they are sorted
# in ascending order. If array has more than 1 duplicate of the same
# number, return ''. Assume no negative numbers and only integers.
# Examples
# >>> is_sorted([5])
# 1
# >>> is_sorted([1, 2, 3, 4, 5])
# 1
# >>> is_sorted([1, 3, 2, 4, 5])
# ""
# >>> is_sorted([1, 2, 3, 4, 5, 6])
# 1
# >>> is_sorted([1, 2, 3, 4, 5, 6, 7])
# 1
# >>> is_sorted([1, 3, 2, 4, 5, 6, 7])
# ""
# >>> is_sorted([1, 2, 2, 3, 3, 4])
# 1
# >>> is_sorted([1, 2, 2, 2, 3, 4])
# ""
sub is_sorted {
    my($lst) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&is_sorted;
        if(eq_deeply($candidate->([5]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 4, 5]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 3, 2, 4, 5]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 4, 5, 6]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 4, 5, 6, 7]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 3, 2, 4, 5, 6, 7]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 2, 1]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 2, 2, 3, 4]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 3, 3, 4]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 2, 3, 3, 4]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 4]),1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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"
sub solve {
    my($s) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&solve;
        if(eq_deeply($candidate->("AsDf"),"aSdF")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("1234"),"4321")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("ab"),"AB")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("#a@C"),"#A@c")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("#AsdfW^45"),"#aSDFw^45")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("#6@2"),"2@6#")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("#$a^D"),"#$A^d")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("#ccc"),"#CCC")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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 an array of the
# first n + 1 numbers of the Tribonacci sequence.
# Examples:
# >>> tri(3)
# [1, 3, 2, 8]
sub tri {
    my($n) = @_;


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
sub fizz_buzz {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&fizz_buzz;
        if(eq_deeply($candidate->(50),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(78),2)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(79),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(100),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(200),6)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4000),192)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10000),639)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(100000),8026)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Filter an input array of strings only for ones that start with a given prefix.
# >>> filter_by_prefix([], "a")
# []
# >>> filter_by_prefix(["abc", "bcd", "cde", "array"], "a")
# ["abc", "array"]
sub filter_by_prefix {
    my($strings, $prefix) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&filter_by_prefix;
        if(eq_deeply($candidate->([], "john"),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx"], "xxx"),["xxx", "xxxAAA", "xxx"])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub solve {
    my($N) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&solve;
        if(eq_deeply($candidate->(1000),"1")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(150),"110")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(147),"1100")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(333),"1001")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(963),"10010")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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 arrays 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 array of the values on the cells that the minimum path go through.
# Examples:
# >>> minPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3)
# [1, 2, 1]
# >>> minPath([[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1)
# [1]
sub minPath {
    my($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
sub count_upper {
    my($s) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&count_upper;
        if(eq_deeply($candidate->("aBCdEf"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("abcdefg"),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("dBBE"),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("B"),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("U"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(""),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("EEEE"),2)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given an array arr of integers and a positive integer k, return a sorted array
# of length k with the maximum k numbers in arr.
# Example 1:
# >>> maximum([-3, -4, 5], 3)
# [-4, -3, 5]
# Example 2:
# >>> maximum([4, -4, 4], 2)
# [4, 4]
# Example 3:
# >>> maximum([-3, 2, 1, 2, -1, -2, 1], 1)
# [2]
# Note:
# 1. The length of the array will be in the range of [1, 1000].
# 2. The elements in the array will be in the range of [-1000, 1000].
# 3. 0 <= k <= len(arr)
sub maximum {
    my($arr, $k) = @_;


Prompt:
# For a given number n, find the largest number that divides n evenly, smaller than n
# >>> largest_divisor(15)
# 5
sub largest_divisor {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&largest_divisor;
        if(eq_deeply($candidate->(3),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(7),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(100),50)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(49),7)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given an array of non-negative integers, return a copl of the given array after sorting,
# you will sort the given array 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 array.
# Examples:
# >>> sort_array([])
# []
# >>> sort_array([5])
# [5]
# >>> sort_array([2, 4, 3, 0, 1, 5])
# [0, 1, 2, 3, 4, 5]
# >>> sort_array([2, 4, 3, 0, 1, 5, 6])
# [6, 5, 4, 3, 2, 1, 0]
sub sort_array {
    my($array) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&sort_array;
        if(eq_deeply($candidate->([]),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5]),[5])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([2, 4, 3, 0, 1, 5]),[0, 1, 2, 3, 4, 5])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([2, 4, 3, 0, 1, 5, 6]),[6, 5, 4, 3, 2, 1, 0])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([2, 1]),[1, 2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([15, 42, 87, 32, 11, 0]),[0, 11, 15, 32, 42, 87])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([21, 14, 23, 11]),[23, 21, 14, 11])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Implement the function f that takes n as a parameter,
# and returns an array 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)
# [1, 2, 6, 24, 15]
sub f {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&f;
        if(eq_deeply($candidate->(5),[1, 2, 6, 24, 15])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(7),[1, 2, 6, 24, 15, 720, 28])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1),[1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3),[1, 2, 6])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Write a function that takes an integer a and returns 1
# if this ingeger is a cube of some integer number.
# Note: you may assume the input is always valid.
# Examples:
# >>> iscube(1)
# 1
# >>> iscube(2)
# ""
# >>> iscube(-1)
# 1
# >>> iscube(64)
# 1
# >>> iscube(0)
# 1
# >>> iscube(180)
# ""
sub iscube {
    my($a) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&iscube;
        if(eq_deeply($candidate->(1),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(-1),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(64),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(180),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1000),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(0),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1729),"")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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"
sub encode {
    my($message) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&encode;
        if(eq_deeply($candidate->("TEST"),"tgst")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Mudasir"),"mWDCSKR")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("YES"),"ygs")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("This is a message"),"tHKS KS C MGSSCGG")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("I DoNt KnOw WhAt tO WrItE"),"k dQnT kNqW wHcT Tq wRkTg")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub is_bored {
    my($S) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&is_bored;
        if(eq_deeply($candidate->("Hello world"),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Is the sky blue?"),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("I love It !"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("bIt"),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("I feel good today. I will be productive. will kill It"),2)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("You and I are going for a walk"),0)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# pairs_sum_to_zero takes an array of integers as an input.
# it returns 1 if there are two distinct elements in the array that
# sum to zero, and '' otherwise.
# >>> pairs_sum_to_zero([1, 3, 5, 0])
# ""
# >>> pairs_sum_to_zero([1, 3, -2, 1])
# ""
# >>> pairs_sum_to_zero([1, 2, 3, 7])
# ""
# >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
# 1
# >>> pairs_sum_to_zero([1])
# ""
sub pairs_sum_to_zero {
    my($l) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&pairs_sum_to_zero;
        if(eq_deeply($candidate->([1, 3, 5, 0]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 3, -2, 1]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 7]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([2, 4, -5, 3, 5, 7]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-3, 9, -1, 3, 2, 30]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-3, 9, -1, 3, 2, 31]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-3, 9, -1, 4, 2, 30]),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-3, 9, -1, 4, 2, 31]),"")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub triangle_area {
    my($a, $b, $c) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&triangle_area;
        if(eq_deeply($candidate->(3, 4, 5),6.0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 2, 10),-1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4, 8, 5),8.18)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 2, 2),1.73)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 2, 3),-1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10, 5, 7),16.25)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 6, 3),-1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 1, 1),0.43)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 2, 10),-1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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 an array 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 array if planet1 or planet2
# are not correct planet names.
# Examples
# >>> bf("Jupiter", "Neptune")
# ["Saturn", "Uranus"]
# >>> bf("Earth", "Mercury")
# "Venus"
# >>> bf("Mercury", "Uranus")
# ["Venus", "Earth", "Mars", "Jupiter", "Saturn"]
sub bf {
    my($planet1, $planet2) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&bf;
        if(eq_deeply($candidate->("Jupiter", "Neptune"),["Saturn", "Uranus"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Earth", "Mercury"),["Venus"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Mercury", "Uranus"),["Venus", "Earth", "Mars", "Jupiter", "Saturn"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Neptune", "Venus"),["Earth", "Mars", "Jupiter", "Saturn", "Uranus"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Earth", "Earth"),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Mars", "Earth"),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Jupiter", "Makemake"),[])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub digits {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&digits;
        if(eq_deeply($candidate->(5),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(54),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(120),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5014),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(98765),315)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5576543),2625)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2468),0)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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 an array of the words.
# For example:
# >>> words_string("Hi, my name is John")
# ["Hi", "my", "name", "is", "John"]
# >>> words_string("One, two, three, four, five, six")
# ["One", "two", "three", "four", "five", "six"]
sub words_string {
    my($s) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&words_string;
        if(eq_deeply($candidate->("Hi, my name is John"),["Hi", "my", "name", "is", "John"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("One, two, three, four, five, six"),["One", "two", "three", "four", "five", "six"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Hi, my name"),["Hi", "my", "name"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("One,, two, three, four, five, six,"),["One", "two", "three", "four", "five", "six"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(""),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("ahmed     , gamal"),["ahmed", "gamal"])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub how_many_times {
    my($string, $substring) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&how_many_times;
        if(eq_deeply($candidate->("", "x"),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("xyxyxyx", "x"),4)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("cacacacac", "cac"),4)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("john doe", "john"),1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Create a function that takes integers, floats, or strings representing
# real numbers, and returns the larger variable in its given variable type.
# Return undef 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)
# undef
sub compare_one {
    my($a, $b) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&compare_one;
        if(eq_deeply($candidate->(1, 2),2)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 2.5),2.5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 3),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5, 6),6)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, "2,3"),"2,3")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("5,1", "6"),"6")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("1", "2"),"2")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("1", 1),undef)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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"
sub remove_vowels {
    my($text) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&remove_vowels;
        if(eq_deeply($candidate->(""),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("abcdef
ghijklm"),"bcdf
ghjklm")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("fedcba"),"fdcb")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("eeeee"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("acBAA"),"cB")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("EcBOO"),"cB")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("ybcd"),"ybcd")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given array of integers, return array in strange order.
# Strange sorting, is when you start with the minimum value,
# then maximum of the remaining integers, then minimum and so on.
# Examples:
# >>> strange_sort_list([1, 2, 3, 4])
# [1, 4, 2, 3]
# >>> strange_sort_list([5, 5, 5, 5])
# [5, 5, 5, 5]
# >>> strange_sort_list([])
# []
sub strange_sort_list {
    my($lst) = @_;


Prompt:
# From a supplied array of numbers (of length at least two) select and return two that are the closest to each
# other and return them in order (smaller number, larger number).
# >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
# [2.0, 2.2]
# >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
# [2.0, 2.0]
sub find_closest_elements {
    my($numbers) = @_;


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)
# 1
# >>> is_simple_power(2, 2)
# 1
# >>> is_simple_power(8, 2)
# 1
# >>> is_simple_power(3, 2)
# ""
# >>> is_simple_power(3, 1)
# ""
# >>> is_simple_power(5, 3)
# ""
sub is_simple_power {
    my($x, $n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&is_simple_power;
        if(eq_deeply($candidate->(16, 2),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(143214, 16),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4, 2),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(9, 3),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(16, 4),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(24, 2),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(128, 4),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(12, 6),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 1),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 12),1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub prime_fib {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&prime_fib;
        if(eq_deeply($candidate->(1),2)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4),13)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5),89)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(6),233)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(7),1597)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(8),28657)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(9),514229)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10),433494437)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Write a function which sorts the given array 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 array.
# For example:
# >>> order_by_points([1, 11, -1, -11, -12])
# [-1, -11, 1, -12, 11]
# >>> order_by_points([])
# []
sub order_by_points {
    my($nums) = @_;


Prompt:
# Check if in given array of numbers, are any two numbers closer to each other than
# given threshold.
# >>> has_close_elements([1.0, 2.0, 3.0], 0.5)
# ""
# >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
# 1
sub has_close_elements {
    my($numbers, $threshold) = @_;


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"
sub make_palindrome {
    my($string) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&make_palindrome;
        if(eq_deeply($candidate->(""),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("x"),"x")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("xyz"),"xyzyx")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("xyx"),"xyx")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("jerry"),"jerryrrej")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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"
sub string_xor {
    my($a, $b) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&string_xor;
        if(eq_deeply($candidate->("111000", "101010"),"010010")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("1", "1"),"0")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("0101", "0000"),"0101")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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.
sub special_factorial {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&special_factorial;
        if(eq_deeply($candidate->(4),288)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(5),34560)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(7),125411328000)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1),1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given a non-empty array of integers arr and an integer k, return
# the sum of the elements with at most two digits from the first k elements of arr.
# Example:
# >>> add_elements([111, 21, 3, 4000, 5, 6, 7, 8, 9], 4)
# 24
# Constraints:
# 1. 1 <= len(arr) <= 100
# 2. 1 <= k <= len(arr)
sub add_elements {
    my($arr, $k) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&add_elements;
        if(eq_deeply($candidate->([1, -2, -3, 41, 57, 76, 87, 88, 99], 3),-4)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([111, 121, 3, 4000, 5, 6], 2),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([11, 21, 3, 90, 5, 6, 7, 8, 9], 4),125)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([111, 21, 3, 4000, 5, 6, 7, 8, 9], 4),24)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1], 1),1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub fib4 {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&fib4;
        if(eq_deeply($candidate->(5),4)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(8),28)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10),104)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(12),386)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given an array of positive integers x. return a sorted array of all
# elements that hasn't any even digit.
# Note: Returned array should be sorted in increasing order.
# For example:
# >>> unique_digits([15, 33, 1422, 1])
# [1, 15, 33]
# >>> unique_digits([152, 323, 1422, 10])
# []
sub unique_digits {
    my($x) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&unique_digits;
        if(eq_deeply($candidate->([15, 33, 1422, 1]),[1, 15, 33])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([152, 323, 1422, 10]),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([12345, 2033, 111, 151]),[111, 151])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([135, 103, 31]),[31, 135])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given a string s and a natural number n, you have been tasked to implement
# a function that returns an array 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 array.
# Note: you may assume the input string contains only letters and spaces.
# Examples:
# >>> select_words("Mary had a little lamb", 4)
# ["little"]
# >>> select_words("Mary had a little lamb", 3)
# ["Mary", "lamb"]
# >>> select_words("simple white space", 2)
# []
# >>> select_words("Hello world", 4)
# ["world"]
# >>> select_words("Uncle sam", 3)
# ["Uncle"]
sub select_words {
    my($s, $n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&select_words;
        if(eq_deeply($candidate->("Mary had a little lamb", 4),["little"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Mary had a little lamb", 3),["Mary", "lamb"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("simple white space", 2),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Hello world", 4),["world"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Uncle sam", 3),["Uncle"])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("", 4),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("a b c d e f", 1),["b", "c", "d", "f"])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Write a function that returns 1 if the object q will fly, and '' otherwise.
# The object q will fly if it's balanced (it is a palindromic array) and the sum of its elements is less than or equal the maximum possible weight w.
# Example:
# >>> will_it_fly([1, 2], 5)
# ""
# # 1+2 is less than the maximum possible weight, but it's unbalanced.
# >>> will_it_fly([3, 2, 3], 1)
# ""
# # it's balanced, but 3+2+3 is more than the maximum possible weight.
# >>> will_it_fly([3, 2, 3], 9)
# 1
# # 3+2+3 is less than the maximum possible weight, and it's balanced.
# >>> will_it_fly([3], 5)
# 1
# # 3 is less than the maximum possible weight, and it's balanced.
sub will_it_fly {
    my($q, $w) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&will_it_fly;
        if(eq_deeply($candidate->([3, 2, 3], 9),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2], 5),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3], 5),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 2, 3], 1),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3], 6),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5], 5),1)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Return n-th Fibonacci number.
# >>> fib(10)
# 55
# >>> fib(1)
# 1
# >>> fib(8)
# 21
sub fib {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&fib;
        if(eq_deeply($candidate->(10),55)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(8),21)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(11),89)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(12),144)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# You will be given the name of a class (a string) and an array 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 array.
# For example, if you are given "Slices" as the class and an array 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", ["AA", "Be", "CC"])
# "my_class.AA"
sub Strongest_Extension {
    my($class_name, $extensions) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&Strongest_Extension;
        if(eq_deeply($candidate->("Watashi", ["tEN", "niNE", "eIGHt8OKe"]),"Watashi.eIGHt8OKe")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Boku123", ["nani", "NazeDa", "YEs.WeCaNe", "32145tggg"]),"Boku123.YEs.WeCaNe")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("__YESIMHERE", ["t", "eMptY", "nothing", "zeR00", "NuLl__", "123NoooneB321"]),"__YESIMHERE.NuLl__")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("K", ["Ta", "TAR", "t234An", "cosSo"]),"K.TAR")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("__HAHA", ["Tab", "123", "781345", "-_-"]),"__HAHA.123")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("YameRore", ["HhAas", "okIWILL123", "WorkOut", "Fails", "-_-"]),"YameRore.okIWILL123")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("finNNalLLly", ["Die", "NowW", "Wow", "WoW"]),"finNNalLLly.WoW")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("_", ["Bb", "91245"]),"_.Bb")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Sp", ["671235", "Bb"]),"Sp.671235")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# You are given an array 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(["()(", ")"])
# "Yes"
# >>> match_parens([")", ")"])
# "No"
sub match_parens {
    my($lst) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&match_parens;
        if(eq_deeply($candidate->(["()(", ")"]),"Yes")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([")", ")"]),"No")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["(()(())", "())())"]),"No")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([")())", "(()()("]),"Yes")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["(())))", "(()())(("]),"Yes")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["()", "())"]),"No")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["(()(", "()))()"]),"Yes")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["((((", "((())"]),"No")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([")(()", "(()("]),"No")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([")(", ")("]),"No")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(["(", ")"]),"Yes")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([")", "("]),"Yes")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# You are given an array of integers.
# Write a function next_smallest() that returns the 2nd smallest element of the array.
# Return undef if there is no such element.
# >>> next_smallest([1, 2, 3, 4, 5])
# 2
# >>> next_smallest([5, 1, 4, 3, 2])
# 2
# >>> next_smallest([])
# undef
# >>> next_smallest([1, 1])
# undef
sub next_smallest {
    my($lst) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&next_smallest;
        if(eq_deeply($candidate->([1, 2, 3, 4, 5]),2)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5, 1, 4, 3, 2]),2)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([]),undef)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 1]),undef)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 1, 1, 1, 0]),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 1]),undef)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-35, 34, 12, -45]),-35)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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)
# 1
# >>> any_int(3, 2, 2)
# ""
# >>> any_int(3, -2, 1)
# 1
# >>> any_int(3.6, -2.2, 2)
# ""
sub any_int {
    my($x, $y, $z) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&any_int;
        if(eq_deeply($candidate->(2, 3, 1),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2.5, 2, 3),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1.5, 5, 3.5),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 6, 2),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(4, 2, 2),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2.2, 2.2, 2.2),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(-4, 6, 2),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 1, 1),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3, 4, 7),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3.0, 4, 7),"")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub truncate_number {
    my($number) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&truncate_number;
        if(eq_deeply($candidate->(3.5),0.5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1.25),0.25)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(123.0),0.0)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Return array with elements incremented by 1.
# >>> incr_list([1, 2, 3])
# [2, 3, 4]
# >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
# [6, 4, 6, 3, 4, 4, 10, 1, 124]
sub incr_list {
    my($l) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&incr_list;
        if(eq_deeply($candidate->([]),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 2, 1]),[4, 3, 2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5, 2, 5, 2, 3, 3, 9, 0, 123]),[6, 3, 6, 3, 4, 4, 10, 1, 124])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub x_or_y {
    my($n, $x, $y) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&x_or_y;
        if(eq_deeply($candidate->(7, 34, 12),34)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(15, 8, 5),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3, 33, 5212),33)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1259, 3, 52),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(7919, -1, 12),-1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3609, 1245, 583),583)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(91, 56, 129),129)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(6, 34, 1234),1234)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1, 2, 0),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(2, 2, 0),2)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub modp {
    my($n, $p) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&modp;
        if(eq_deeply($candidate->(3, 5),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(1101, 101),2)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(0, 101),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3, 11),8)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(100, 101),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(30, 5),4)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(31, 5),3)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given an integer. return an array that has the number of even and odd digits respectively.
# Example:
# >>> even_odd_count(-12)
# [1, 1]
# >>> even_odd_count(123)
# [1, 2]
sub even_odd_count {
    my($num) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&even_odd_count;
        if(eq_deeply($candidate->(7),[0, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(-78),[1, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(3452),[2, 2])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(346211),[3, 3])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(-345821),[3, 3])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(-2),[1, 0])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(-45347),[2, 3])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(0),[1, 0])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# You are given a string s.
# Your task is to check if the string is happl or not.
# A string is happl if its length is at least 3 and every 3 consecutive letters are distinct
# For example:
# >>> is_happy("a")
# ""
# >>> is_happy("aa")
# ""
# >>> is_happy("abcd")
# 1
# >>> is_happy("aabb")
# ""
# >>> is_happy("adb")
# 1
# >>> is_happy("xyy")
# ""
sub is_happy {
    my($s) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&is_happy;
        if(eq_deeply($candidate->("a"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("aa"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("abcd"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("aabb"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("adb"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("xyy"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("iopaxpoi"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("iopaxioi"),"")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub largest_prime_factor {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&largest_prime_factor;
        if(eq_deeply($candidate->(15),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(27),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(63),7)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(330),11)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(13195),29)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


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
sub digitSum {
    my($s) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&digitSum;
        if(eq_deeply($candidate->(""),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("abAB"),131)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("abcCd"),67)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("helloE"),69)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("woArBld"),131)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("aAaaaXa"),153)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(" How are yOu?"),151)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("You arE Very Smart"),327)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Given array of numbers (of at least two elements), apply a linear transform to that array,
# such that the smallest number will become 0 and the largest will become 1
# >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
# [0.0, 0.25, 0.5, 0.75, 1.0]
sub rescale_to_unit {
    my($numbers) = @_;


Prompt:
# Given a non-empty array of integers, return the sum of all of the odd elements that are in even positions.
# Examples
# >>> solution([5, 8, 7, 1])
# 12
# >>> solution([3, 3, 3, 3, 3])
# 9
# >>> solution([30, 13, 24, 321])
# 0
sub solution {
    my($lst) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&solution;
        if(eq_deeply($candidate->([5, 8, 7, 1]),12)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 3, 3, 3, 3]),9)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([30, 13, 24, 321]),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5, 9]),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([2, 4, 8]),0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([30, 13, 23, 32]),23)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 13, 2, 9]),3)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# "Given an array representing a branch of a tree that has non-negative integer nodes
# your task is to pluck one of the nodes and return it.
# The plucked node should be the node with the smallest even value.
# If multiple nodes with the same smallest even value are found return the node that has smallest index.
# The plucked node should be returned in an array, [ smalest_value, its index ],
# If there are no even values or the given array is empty, return [].
# Example 1:
# >>> pluck([4, 2, 3])
# [2, 1]
# Explanation: 2 has the smallest even value, and 2 has the smallest index.
# Example 2:
# >>> pluck([1, 2, 3])
# [2, 1]
# Explanation: 2 has the smallest even value, and 2 has the smallest index.
# Example 3:
# >>> pluck([])
# []
# Example 4:
# >>> pluck([5, 0, 3, 0, 4, 2])
# [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
sub pluck {
    my($arr) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&pluck;
        if(eq_deeply($candidate->([4, 2, 3]),[2, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3]),[2, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([]),[])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5, 0, 3, 0, 4, 2]),[0, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 0, 5, 3]),[0, 3])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5, 4, 8, 4, 8]),[4, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([7, 6, 7, 1]),[6, 1])) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([7, 9, 7, 1]),[])) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# You are given a positive integer n. You have to create an integer array a of length n.
# For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
# Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
# and a[i] + a[j] + a[k] is a multiple of 3.
# Example :
# >>> get_max_triples(5)
# 1
# Explanation:
# a = [1, 3, 7, 13, 21]
# The only valid triple is (1, 7, 13).
sub get_max_triples {
    my($n) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&get_max_triples;
        if(eq_deeply($candidate->(5),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(6),4)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(10),36)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(100),53361)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# In this problem, you will implement a function that takes two arrays of numbers,
# and determines whether it is possible to perform an exchange of elements
# between them to make lst1 an array 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([1, 2, 3, 4], [1, 2, 3, 4])
# "YES"
# >>> exchange([1, 2, 3, 4], [1, 5, 3, 4])
# "NO"
# It is assumed that the input arrays will be non-empty.
sub exchange {
    my($lst1, $lst2) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&exchange;
        if(eq_deeply($candidate->([1, 2, 3, 4], [1, 2, 3, 4]),"YES")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 4], [1, 5, 3, 4]),"NO")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([1, 2, 3, 4], [2, 1, 4, 3]),"YES")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5, 7, 3], [2, 6, 4]),"YES")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5, 7, 3], [2, 6, 3]),"NO")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([3, 2, 6, 1, 8, 9], [3, 5, 5, 1, 1, 1]),"NO")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([100, 200], [200, 200]),"YES")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Return median of elements in the array l.
# >>> median([3, 1, 2, 4, 5])
# 3
# >>> median([-10, 4, 6, 1000, 10, 20])
# 15.0
sub median {
    my($l) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&median;
        if(eq_deeply($candidate->([3, 1, 2, 4, 5]),3)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([-10, 4, 6, 1000, 10, 20]),8.0)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([5]),5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([6, 5]),5.5)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->([8, 1, 3, 9, 9, 2, 7]),7)) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();


Prompt:
# Write a function that takes a string and returns 1 if the string
# length is a prime number or '' otherwise
# Examples
# >>> prime_length("Hello")
# 1
# >>> prime_length("abcdcba")
# 1
# >>> prime_length("kittens")
# 1
# >>> prime_length("orange")
# ""
sub prime_length {
    my($string) = @_;

use Test::Deep;

sub testhumaneval {
    my $candidate = \&prime_length;
        if(eq_deeply($candidate->("Hello"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("abcdcba"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("kittens"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("orange"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("wow"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("world"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("MadaM"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Wow"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->(""),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("HI"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("go"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("gogo"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("aaaaaaaaaaaaaaa"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("Madam"),1)) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("M"),"")) {
        print "ok!" }else{
        exit 1;
        }
        if(eq_deeply($candidate->("0"),"")) {
        print "ok!" }else{
        exit 1;
        }
}

testhumaneval();