diff --git "a/bt_jhumaneval.jsonl" "b/bt_jhumaneval.jsonl" new file mode 100644--- /dev/null +++ "b/bt_jhumaneval.jsonl" @@ -0,0 +1,164 @@ +{"task_id": "bt_JHumanEval/0", "prompt": "リストnumbersの中に、与えられたthresholdより近い2つの数値が存在するか判定する \n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True", "code": "from typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n distance = abs(elem - elem2)\n if distance < threshold:\n return True\n\n return False\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3) == True\n assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05) == False\n assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.95) == True\n assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.8) == False\n assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1) == True\n assert candidate([1.1, 2.2, 3.1, 4.1, 5.1], 1.0) == True\n assert candidate([1.1, 2.2, 3.1, 4.1, 5.1], 0.5) == False\n\n\ncandidate = has_close_elements\ncheck(candidate)", "entry_point": "has_close_elements"} +{"task_id": "bt_JHumanEval/1", "prompt": "この関数への入力は、入れ子になった括弧が複数含まれる文字列である。\n あなたの目的は、これらの括弧を別々の文字列に分割し、そのリストを返すことである。\n 分離された括弧はバランスがとれ、つまり、開いた括弧はそれぞれ適切に閉じられていて、\n 互いに入れ子になっていない。引数の文字列内の空白は無視せよ。\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']", "code": "from typing import List\n\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n result = []\n current_string = []\n current_depth = 0\n\n for c in paren_string:\n if c == '(':\n current_depth += 1\n current_string.append(c)\n elif c == ')':\n current_depth -= 1\n current_string.append(c)\n\n if current_depth == 0:\n result.append(''.join(current_string))\n current_string.clear()\n\n return result\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('(()()) ((())) () ((())()())') == [\n '(()())', '((()))', '()', '((())()())'\n ]\n assert candidate('() (()) ((())) (((())))') == [\n '()', '(())', '((()))', '(((())))'\n ]\n assert candidate('(()(())((())))') == [\n '(()(())((())))'\n ]\n assert candidate('( ) (( )) (( )( ))') == ['()', '(())', '(()())']\n\ncandidate = separate_paren_groups\ncheck(candidate)", "entry_point": "separate_paren_groups"} +{"task_id": "bt_JHumanEval/2", "prompt": "正の浮動小数点数が与えられると、それを整数部(与えられた数より小さい最大の整数)\n と小数部(常に1より小さい残余部分)に分解することができる。\n \n 関数は、数値の小数部を返す。\n >>> truncate_number(3.5)\n 0.5", "code": "def truncate_number(number: float) -> float:\n return number % 1.0\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3.5) == 0.5\n assert abs(candidate(1.33) - 0.33) < 1e-6\n assert abs(candidate(123.456) - 0.456) < 1e-6\n\ncandidate = truncate_number\ncheck(candidate)", "entry_point": "truncate_number"} +{"task_id": "bt_JHumanEval/3", "prompt": "銀行口座に対する入出金操作のリストが与えられます。あなたのタスクは、残高ゼロから\n 始まて、口座の残高がゼロ以下になったかどうかを検出し、その時点で関数がTrueを\n 返すようにすることです。そうでなければFalseを返すようにしてください。\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True", "code": "from typing import List\n\n\ndef below_zero(operations: List[int]) -> bool:\n balance = 0\n\n for op in operations:\n balance += op\n if balance < 0:\n return True\n\n return False\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == False\n assert candidate([1, 2, -3, 1, 2, -3]) == False\n assert candidate([1, 2, -4, 5, 6]) == True\n assert candidate([1, -1, 2, -2, 5, -5, 4, -4]) == False\n assert candidate([1, -1, 2, -2, 5, -5, 4, -5]) == True\n assert candidate([1, -2, 2, -2, 5, -5, 4, -4]) == True\n\ncandidate = below_zero\ncheck(candidate)", "entry_point": "below_zero"} +{"task_id": "bt_JHumanEval/4", "prompt": "第一引数の数値リストに対して、このデータセットの平均値を中心とし���平均絶対偏差(MAD)を計算する。\n 平均絶対偏差(MAD)とは、各要素と中心点(この場合は平均値)との差の絶対値の平均である:\n MAD = 平均|x - x_mean|\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0", "code": "from typing import List\n\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n mean = sum(numbers) / len(numbers)\n return sum(abs(x - mean) for x in numbers) / len(numbers)\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert abs(candidate([1.0, 2.0, 3.0]) - 2.0/3.0) < 1e-6\n assert abs(candidate([1.0, 2.0, 3.0, 4.0]) - 1.0) < 1e-6\n assert abs(candidate([1.0, 2.0, 3.0, 4.0, 5.0]) - 6.0/5.0) < 1e-6\n\n\ncandidate = mean_absolute_deviation\ncheck(candidate)", "entry_point": "mean_absolute_deviation"} +{"task_id": "bt_JHumanEval/5", "prompt": "数値リスト numbers 中の全ての連続する二要素の間に、'delimeterの値を挿入する\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]", "code": "from typing import List\n\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n if not numbers:\n return []\n\n result = []\n\n for n in numbers[:-1]:\n result.append(n)\n result.append(delimeter)\n\n result.append(numbers[-1])\n\n return result\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([], 7) == []\n assert candidate([5, 6, 3, 2], 8) == [5, 8, 6, 8, 3, 8, 2]\n assert candidate([2, 2, 2], 2) == [2, 2, 2, 2, 2]\n\ncandidate = intersperse\ncheck(candidate)", "entry_point": "intersperse"} +{"task_id": "bt_JHumanEval/6", "prompt": "この関数の入力は、空白で区切られた複数の入れ子になった括弧のグループを表す文字列です。\n 各グループについて、括弧の最も深い入れ子のレベルを出力します。\n 例えば、'(()())'は最大で2レベルの入れ子になっていますが、'((()))'は3レベルです。\n \n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]", "code": "from typing import List\n\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n def parse_paren_group(s):\n depth = 0\n max_depth = 0\n for c in s:\n if c == '(':\n depth += 1\n max_depth = max(depth, max_depth)\n else:\n depth -= 1\n\n return max_depth\n\n return [parse_paren_group(x) for x in paren_string.split(' ') if x]\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('(()()) ((())) () ((())()())') == [2, 3, 1, 3]\n assert candidate('() (()) ((())) (((())))') == [1, 2, 3, 4]\n assert candidate('(()(())((())))') == [4]\n\ncandidate = parse_nested_parens\ncheck(candidate)", "entry_point": "parse_nested_parens"} +{"task_id": "bt_JHumanEval/7", "prompt": "文字列リストstringsを、与えれた部分文字列substringを含むものだけにフィルタする\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']", "code": "from typing import List\n\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n return [x for x in strings if substring in x]\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([], 'john') == []\n assert candidate(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx') == ['xxx', 'xxxAAA', 'xxx']\n assert candidate(['xxx', 'asd', 'aaaxxy', 'john doe', 'xxxAAA', 'xxx'], 'xx') == ['xxx', 'aaaxxy', 'xxxAAA', 'xxx']\n assert candidate(['grunt', 'trumpet', 'prune', 'gruesome'], 'run') == ['grunt', 'prune']\n\ncandidate = filter_by_substring\ncheck(candidate)", "entry_point": "filter_by_substring"} +{"task_id": "bt_JHumanEval/8", "prompt": "与えられた整数リストに対して、リスト内のすべての整数の和と積からなるタプルを返す。\n ただし、空の和は0、空の積は1とする。\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)", "code": "from typing import List, Tuple\n\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n sum_value = 0\n prod_value = 1\n\n for n in numbers:\n sum_value += n\n prod_value *= n\n return sum_value, prod_value\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == (0, 1)\n assert candidate([1, 1, 1]) == (3, 1)\n assert candidate([100, 0]) == (100, 0)\n assert candidate([3, 5, 7]) == (3 + 5 + 7, 3 * 5 * 7)\n assert candidate([10]) == (10, 10)\n\ncandidate = sum_product\ncheck(candidate)", "entry_point": "sum_product"} +{"task_id": "bt_JHumanEval/9", "prompt": "与えられた整数リストから、各要素のそこまでの最大値(ローリング最大値)のリストを生成する。\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]", "code": "from typing import List, Tuple\n\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n running_max = None\n result = []\n\n for n in numbers:\n if running_max is None:\n running_max = n\n else:\n running_max = max(running_max, n)\n\n result.append(running_max)\n\n return result\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == []\n assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]\n assert candidate([4, 3, 2, 1]) == [4, 4, 4, 4]\n assert candidate([3, 2, 3, 100, 3]) == [3, 3, 3, 100, 100]\n\ncandidate = rolling_max\ncheck(candidate)", "entry_point": "rolling_max"} +{"task_id": "bt_JHumanEval/10", "prompt": "与えられた文字列で始まる最短の回文を見つけてください。\n アルゴリズムのアイデアは以下の通りです:\n - 与えられた文字列の中で最も長い回文となる接尾辞を見つけます。\n - その回文の接尾辞の前に来る接頭辞を逆順にして、文字列の末尾に追加します。\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'", "code": "def is_palindrome(string: str) -> bool:\n \n return string == string[::-1]\n\n\ndef make_palindrome(string: str) -> str:\n if not string:\n return ''\n\n beginning_of_suffix = 0\n\n while not is_palindrome(string[beginning_of_suffix:]):\n beginning_of_suffix += 1\n\n return string + string[:beginning_of_suffix][::-1]\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == ''\n assert candidate('x') == 'x'\n assert candidate('xyz') == 'xyzyx'\n assert candidate('xyx') == 'xyx'\n assert candidate('jerry') == 'jerryrrej'\n\ncandidate = make_palindrome\ncheck(candidate)", "entry_point": "make_palindrome"} +{"task_id": "bt_JHumanEval/11", "prompt": "引数は1と0のみからなる文字列aとbである。\n これらの引数に対して排他論理和(XOR)を実行し、結果を文字列として返す。\n >>> string_xor('010', '110')\n '100'", "code": "from typing import List\n\n\ndef string_xor(a: str, b: str) -> str:\n def xor(i, j):\n if i == j:\n return '0'\n else:\n return '1'\n\n return ''.join(xor(x, y) for x, y in zip(a, b))\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('111000', '101010') == '010010'\n assert candidate('1', '1') == '0'\n assert candidate('0101', '0000') == '0101'\n\ncandidate = string_xor\ncheck(candidate)", "entry_point": "string_xor"} +{"task_id": "bt_JHumanEval/12", "prompt": "文字列のリストのうち、最も長いものを返す。同じ長さの文字列が\n 複数ある場合は最初のものを返す。入力リストが空の場合は None を返す。\n >>> longest([])\n\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'", "code": "from typing import List, Optional\n\n\ndef longest(strings: List[str]) -> Optional[str]:\n if not strings:\n return None\n\n maxlen = max(len(x) for x in strings)\n for s in strings:\n if len(s) == maxlen:\n return s\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == None\n assert candidate(['x', 'y', 'z']) == 'x'\n assert candidate(['x', 'yyy', 'zzzz', 'www', 'kkkk', 'abc']) == 'zzzz'\n\ncandidate = longest\ncheck(candidate)", "entry_point": "longest"} +{"task_id": "bt_JHumanEval/13", "prompt": "整数 a と b の最大公約数を返す\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5", "code": "def greatest_common_divisor(a: int, b: int) -> int:\n while b:\n a, b = b, a % b\n return a\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3, 7) == 1\n assert candidate(10, 15) == 5\n assert candidate(49, 14) == 7\n assert candidate(144, 60) == 12\n\ncandidate = greatest_common_divisor\ncheck(candidate)", "entry_point": "greatest_common_divisor"} +{"task_id": "bt_JHumanEval/14", "prompt": "引数で与えられた文字列に対して、短いものから長いものへ、全ての接頭辞のリストを返す\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']", "code": "from typing import List\n\n\ndef all_prefixes(string: str) -> List[str]:\n result = []\n\n for i in range(len(string)):\n result.append(string[:i+1])\n return result\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == []\n assert candidate('asdfgh') == ['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']\n assert candidate('WWW') == ['W', 'WW', 'WWW']\n\ncandidate = all_prefixes\ncheck(candidate)", "entry_point": "all_prefixes"} +{"task_id": "bt_JHumanEval/15", "prompt": "0からnまでの数字を空白区切りで連結した文字列で返す。\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'", "code": "def string_sequence(n: int) -> str:\n return ' '.join([str(x) for x in range(n + 1)])\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(0) == '0'\n assert candidate(3) == '0 1 2 3'\n assert candidate(10) == '0 1 2 3 4 5 6 7 8 9 10'\n\ncandidate = string_sequence\ncheck(candidate)", "entry_point": "string_sequence"} +{"task_id": "bt_JHumanEval/16", "prompt": "文字列が与えられたとき、その文字列が(大文字小文字に関係なく)いくつの異なる文字が含まれているか数える\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4", "code": "def count_distinct_characters(string: str) -> int:\n return len(set(string.lower()))\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == 0\n assert candidate('abcde') == 5\n assert candidate('abcde' + 'cade' + 'CADE') == 5\n assert candidate('aaaaAAAAaaaa') == 1\n assert candidate('Jerry jERRY JeRRRY') == 5\n\ncandidate = count_distinct_characters\ncheck(candidate)", "entry_point": "count_distinct_characters"} +{"task_id": "bt_JHumanEval/17", "prompt": "この関数の引数は、特別なASCII形式の音符を表す文字列である。あなたの仕事は、この文字列を解析して、それぞれの音符が何拍続くかに対応する整数のリストを返すことである。\n ここに凡例がある:\n o' - 全音符、4拍続く\n o|' - 2分音符、2拍続く\n .|」-4分音符、1拍続く\n \n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]", "code": "from typing import List\n\n\ndef parse_music(music_string: str) -> List[int]:\n note_map = {'o': 4, 'o|': 2, '.|': 1}\n return [note_map[x] for x in music_string.split(' ') if x]\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == []\n assert candidate('o o o o') == [4, 4, 4, 4]\n assert candidate('.| .| .| .|') == [1, 1, 1, 1]\n assert candidate('o| o| .| .| o o o o') == [2, 2, 1, 1, 4, 4, 4, 4]\n assert candidate('o| .| o| .| o o| o o|') == [2, 1, 2, 1, 4, 2, 4, 2]\n\ncandidate = parse_music\ncheck(candidate)", "entry_point": "parse_music"} +{"task_id": "bt_JHumanEval/18", "prompt": "部分文字列substringが文字列stringの中で何回見つかるか数える。\n 重なるケースもカウントに含まれる。\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3", "code": "def how_many_times(string: str, substring: str) -> int:\n times = 0\n\n for i in range(len(string) - len(substring) + 1):\n if string[i:i+len(substring)] == substring:\n times += 1\n\n return times\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('', 'x') == 0\n assert candidate('xyxyxyx', 'x') == 4\n assert candidate('cacacacac', 'cac') == 4\n assert candidate('john doe', 'john') == 1\n\ncandidate = how_many_times\ncheck(candidate)", "entry_point": "how_many_times"} +{"task_id": "bt_JHumanEval/19", "prompt": "引数は'zero'から'nine'までの英単語の数を空白で区切った文字列である。\n 有効な英単語は''、'zero', 'one'、'two'、'three'、'four'、'five'、'six'、'seven'、'eight'、'nine'である。\n 関数は、英単語の数を小さい方から大きい方へとソートした文字列を返す。\n >>> sort_numbers('three one five')\n 'one three five'", "code": "from typing import List\n\n\ndef sort_numbers(numbers: str) -> str:\n value_map = {\n 'zero': 0,\n 'one': 1,\n 'two': 2,\n 'three': 3,\n 'four': 4,\n 'five': 5,\n 'six': 6,\n 'seven': 7,\n 'eight': 8,\n 'nine': 9\n }\n return ' '.join(sorted([x for x in numbers.split(' ') if x], key=lambda x: value_map[x]))\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == ''\n assert candidate('three') == 'three'\n assert candidate('three five nine') == 'three five nine'\n assert candidate('five zero four seven nine eight') == 'zero four five seven eight nine'\n assert candidate('six five four three two one zero') == 'zero one two three four five six'\n\ncandidate = sort_numbers\ncheck(candidate)", "entry_point": "sort_numbers"} +{"task_id": "bt_JHumanEval/20", "prompt": "(少なくとも長さ2以上の)リストnumbersから、互いに最も近いものを2つ選び、\n 順番に(小さい数、大きい数)返す。\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])\n (2.0, 2.2)\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])\n (2.0, 2.0)", "code": "from typing import List, Tuple\n\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n closest_pair = None\n distance = None\n\n for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n if distance is None:\n distance = abs(elem - elem2)\n closest_pair = tuple(sorted([elem, elem2]))\n else:\n new_distance = abs(elem - elem2)\n if new_distance < distance:\n distance = new_distance\n closest_pair = tuple(sorted([elem, elem2]))\n\n return closest_pair\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2]) == (3.9, 4.0)\n assert candidate([1.0, 2.0, 5.9, 4.0, 5.0]) == (5.0, 5.9)\n assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)\n assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)\n assert candidate([1.1, 2.2, 3.1, 4.1, 5.1]) == (2.2, 3.1)\n\n\ncandidate = find_closest_elements\ncheck(candidate)", "entry_point": "find_closest_elements"} +{"task_id": "bt_JHumanEval/21", "prompt": "(少なくとも 2 つ以上の要素からなる) リストnumbersに線形変換を適用し、\n 最小の数値が 0 になり、最大の数値が 1 になるリストを返す\n >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])\n [0.0, 0.25, 0.5, 0.75, 1.0]", "code": "from typing import List\n\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n min_number = min(numbers)\n max_number = max(numbers)\n return [(x - min_number) / (max_number - min_number) for x in numbers]\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2.0, 49.9]) == [0.0, 1.0]\n assert candidate([100.0, 49.9]) == [1.0, 0.0]\n assert candidate([1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]\n assert candidate([2.0, 1.0, 5.0, 3.0, 4.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]\n assert candidate([12.0, 11.0, 15.0, 13.0, 14.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]\n\ncandidate = rescale_to_unit\ncheck(candidate)", "entry_point": "rescale_to_unit"} +{"task_id": "bt_JHumanEval/22", "prompt": "任意の種類の値が含まれるリストから整数値のみ抽出する\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', {}, []])\n [1, 2, 3]", "code": "from typing import List, Any\n\n\ndef filter_integers(values: List[Any]) -> List[int]:\n return [x for x in values if isinstance(x, int)]\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == []\n assert candidate([4, {}, [], 23.2, 9, 'adasd']) == [4, 9]\n assert candidate([3, 'c', 3, 3, 'a', 'b']) == [3, 3, 3]\n\ncandidate = filter_integers\ncheck(candidate)", "entry_point": "filter_integers"} +{"task_id": "bt_JHumanEval/23", "prompt": "引数で与えられた文字列の長さを返す\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3", "code": "def strlen(string: str) -> int:\n return len(string)\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == 0\n assert candidate('x') == 1\n assert candidate('asdasnakj') == 9\n\ncandidate = strlen\ncheck(candidate)", "entry_point": "strlen"} +{"task_id": "bt_JHumanEval/24", "prompt": "与えられた数nについて、nの約数のうち、nより小さい最大の数を求める\n >>> largest_divisor(15)\n 5", "code": "def largest_divisor(n: int) -> int:\n for i in reversed(range(n)):\n if n % i == 0:\n return i\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3) == 1\n assert candidate(7) == 1\n assert candidate(10) == 5\n assert candidate(100) == 50\n assert candidate(49) == 7\n\ncandidate = largest_divisor\ncheck(candidate)", "entry_point": "largest_divisor"} +{"task_id": "bt_JHumanEval/25", "prompt": "与えられた整数の素因数のリストを小さいものから大きいものの順に返す。各因数は、\n 因数分解で現れる回数分、リストに登場する。引数の整数は全ての因数の積に等しくな\n ければならない。\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]", "code": "from typing import List\n\n\ndef factorize(n: int) -> List[int]:\n import math\n fact = []\n i = 2\n while i <= int(math.sqrt(n) + 1):\n if n % i == 0:\n fact.append(i)\n n //= i\n else:\n i += 1\n\n if n > 1:\n fact.append(n)\n return fact\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == [2]\n assert candidate(4) == [2, 2]\n assert candidate(8) == [2, 2, 2]\n assert candidate(3 * 19) == [3, 19]\n assert candidate(3 * 19 * 3 * 19) == [3, 3, 19, 19]\n assert candidate(3 * 19 * 3 * 19 * 3 * 19) == [3, 3, 3, 19, 19, 19]\n assert candidate(3 * 19 * 19 * 19) == [3, 19, 19, 19]\n assert candidate(3 * 2 * 3) == [2, 3, 3]\n\ncandidate = factorize\ncheck(candidate)", "entry_point": "factorize"} +{"task_id": "bt_JHumanEval/26", "prompt": "整数のリストから、複数回出現する要素をすべて取り除く。\n 要素の順序は入力と同じようにする。\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]", "code": "from typing import List\n\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n import collections\n c = collections.Counter(numbers)\n return [n for n in numbers if c[n] <= 1]\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == []\n assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]\n assert candidate([1, 2, 3, 2, 4, 3, 5]) == [1, 4, 5]\n\ncandidate = remove_duplicates\ncheck(candidate)", "entry_point": "remove_duplicates"} +{"task_id": "bt_JHumanEval/27", "prompt": "与えられた文字列に対して、英小文字を英大文字に、英大文字を英小文字に変換する。\n >>> flip_case('Hello')\n 'hELLO'", "code": "def flip_case(string: str) -> str:\n return string.swapcase()\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == ''\n assert candidate('Hello!') == 'hELLO!'\n assert candidate('These violent delights have violent ends') == 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS'\n\ncandidate = flip_case\ncheck(candidate)", "entry_point": "flip_case"} +{"task_id": "bt_JHumanEval/28", "prompt": "文字列のリストを1つの文字列に連結する\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'", "code": "from typing import List\n\n\ndef concatenate(strings: List[str]) -> str:\n return ''.join(strings)\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == ''\n assert candidate(['x', 'y', 'z']) == 'xyz'\n assert candidate(['x', 'y', 'z', 'w', 'k']) == 'xyzwk'\n\ncandidate = concatenate\ncheck(candidate)", "entry_point": "concatenate"} +{"task_id": "bt_JHumanEval/29", "prompt": "文字列のリストから、指定された接頭辞prefixで始まるものだけを取り出す。\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']", "code": "from typing import List\n\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n return [x for x in strings if x.startswith(prefix)]\n", "testcode": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([], 'john') == []\n assert candidate(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx') == ['xxx', 'xxxAAA', 'xxx']\n\ncandidate = filter_by_prefix\ncheck(candidate)", "entry_point": "filter_by_prefix"} +{"task_id": "bt_JHumanEval/30", "prompt": "リスト内の正の数だけを返す。\n >>> get_positive([-1, 2, -4, 5, 6])\n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]", "code": "def get_positive(l: list):\n return [e for e in l if e > 0]\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([-1, -2, 4, 5, 6]) == [4, 5, 6]\n assert candidate([5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 3, 9, 123, 1]\n assert candidate([-1, -2]) == []\n assert candidate([]) == []\n\n\ncandidate = get_positive\ncheck(candidate)", "entry_point": "get_positive"} +{"task_id": "bt_JHumanEval/31", "prompt": "与えられた数が素数であれば真を、そうでなければ偽を返す。\n >>> is_prime(6)\n False\n >>> is_prime(101)\n True\n >>> is_prime(11)\n True\n >>> is_prime(13441)\n True\n >>> is_prime(61)\n True\n >>> is_prime(4)\n False\n >>> is_prime(1)\n False", "code": "def is_prime(n):\n if n < 2:\n return False\n for k in range(2, n - 1):\n if n % k == 0:\n return False\n return True\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(6) == False\n assert candidate(101) == True\n assert candidate(11) == True\n assert candidate(13441) == True\n assert candidate(61) == True\n assert candidate(4) == False\n assert candidate(1) == False\n assert candidate(5) == True\n assert candidate(11) == True\n assert candidate(17) == True\n assert candidate(5 * 17) == False\n assert candidate(11 * 7) == False\n assert candidate(13441 * 19) == False\n\n\ncandidate = is_prime\ncheck(candidate)", "entry_point": "is_prime"} +{"task_id": "bt_JHumanEval/32", "prompt": "xsは多項式の係数である。\n find_zero関数は、poly(x) = 0 となる x を見つける。\n find_zero関数は、たとえ複数解があったとしても解をひとつのみを返す。\n さらに、find_zero関数は、解を持つことを保証するため、偶数個の係数xsと\n 最大係数は常に0でないと想定する。\n >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x\n -0.5\n >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3\n 1.0", "code": "import math\n\n\ndef poly(xs: list, x: float):\n \n return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])\n\n\ndef find_zero(xs: list):\n begin, end = -1., 1.\n while poly(xs, begin) * poly(xs, end) > 0:\n begin *= 2.0\n end *= 2.0\n while end - begin > 1e-10:\n center = (begin + end) / 2.0\n if poly(xs, center) * poly(xs, begin) > 0:\n begin = center\n else:\n end = center\n return begin\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n import math\n import random\n rng = random.Random(42)\n import copy\n for _ in range(100):\n ncoeff = 2 * rng.randint(1, 4)\n coeffs = []\n for _ in range(ncoeff):\n coeff = rng.randint(-10, 10)\n if coeff == 0:\n coeff = 1\n coeffs.append(coeff)\n solution = candidate(copy.deepcopy(coeffs))\n assert math.fabs(poly(coeffs, solution)) < 1e-4\n\n\ncandidate = find_zero\ncheck(candidate)", "entry_point": "find_zero"} +{"task_id": "bt_JHumanEval/33", "prompt": "この関数はリストlを受け取り、l'を返す。l'は、インデックスが3で割り\n 切れない場合はlと同じであるが、インデックスが3で割り切れる要素は\n ソートされている。\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]", "code": "def sort_third(l: list):\n l = list(l)\n l[::3] = sorted(l[::3])\n return l\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert tuple(candidate([1, 2, 3])) == tuple(sort_third([1, 2, 3]))\n assert tuple(candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])) == tuple(sort_third([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]))\n assert tuple(candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10])) == tuple(sort_third([5, 8, -12, 4, 23, 2, 3, 11, 12, -10]))\n assert tuple(candidate([5, 6, 3, 4, 8, 9, 2])) == tuple([2, 6, 3, 4, 8, 9, 5])\n assert tuple(candidate([5, 8, 3, 4, 6, 9, 2])) == tuple([2, 8, 3, 4, 6, 9, 5])\n assert tuple(candidate([5, 6, 9, 4, 8, 3, 2])) == tuple([2, 6, 9, 4, 8, 3, 5])\n assert tuple(candidate([5, 6, 3, 4, 8, 9, 2, 1])) == tuple([2, 6, 3, 4, 8, 9, 5, 1])\n\n\ncandidate = sort_third\ncheck(candidate)", "entry_point": "sort_third"} +{"task_id": "bt_JHumanEval/34", "prompt": "リスト内のユニークな要素をソートして返す\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [0, 2, 3, 5, 9, 123]", "code": "def unique(l: list):\n return sorted(list(set(l)))\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]\n\n\ncandidate = unique\ncheck(candidate)", "entry_point": "unique"} +{"task_id": "bt_JHumanEval/35", "prompt": "リスト内の最大要素を返す。\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123", "code": "def max_element(l: list):\n m = l[0]\n for e in l:\n if e > m:\n m = e\n return m\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3]) == 3\n assert candidate([5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]) == 124\n\ncandidate = max_element\ncheck(candidate)", "entry_point": "max_element"} +{"task_id": "bt_JHumanEval/36", "prompt": "11または13で割り切れるn未満の整数の中に7という数字が現れる回数を返す。\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3", "code": "def fizz_buzz(n: int):\n ns = []\n for i in range(n):\n if i % 11 == 0 or i % 13 == 0:\n ns.append(i)\n s = ''.join(list(map(str, ns)))\n ans = 0\n for c in s:\n ans += (c == '7')\n return ans\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(50) == 0\n assert candidate(78) == 2\n assert candidate(79) == 3\n assert candidate(100) == 3\n assert candidate(200) == 6\n assert candidate(4000) == 192\n assert candidate(10000) == 639\n assert candidate(100000) == 8026\n\n\ncandidate = fizz_buzz\ncheck(candidate)", "entry_point": "fizz_buzz"} +{"task_id": "bt_JHumanEval/37", "prompt": "この関数はリスト l を受け取り、l' を返す。l'は、インデックスが奇数の\n ときは l と同じで、インデックスが偶数のときはソートされている。\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]", "code": "def sort_even(l: list):\n evens = l[::2]\n odds = l[1::2]\n evens.sort()\n ans = []\n for e, o in zip(evens, odds):\n ans.extend([e, o])\n if len(evens) > len(odds):\n ans.append(evens[-1])\n return ans\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert tuple(candidate([1, 2, 3])) == tuple([1, 2, 3])\n assert tuple(candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])) == tuple([-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123])\n assert tuple(candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10])) == tuple([-12, 8, 3, 4, 5, 2, 12, 11, 23, -10])\n\n\ncandidate = sort_even\ncheck(candidate)", "entry_point": "sort_even"} +{"task_id": "bt_JHumanEval/38", "prompt": "encode_cyclic関数でエンコードされた文字列を引数に取り、デコードされた文字列を返す。", "code": "def encode_cyclic(s: str):\n \n # 文字列長が3になるように文字列をグループ化\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]\n # グループの長さが3未満でない限り、各グループを循環させる\n groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]\n return \"\".join(groups)\n\n\ndef decode_cyclic(s: str):\n return encode_cyclic(encode_cyclic(s))\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n from random import randint, choice\n import string\n\n letters = string.ascii_lowercase\n for _ in range(100):\n str = ''.join(choice(letters) for i in range(randint(10, 20)))\n encoded_str = encode_cyclic(str)\n assert candidate(encoded_str) == str\n\n\ncandidate = decode_cyclic\ncheck(candidate)", "entry_point": "decode_cyclic"} +{"task_id": "bt_JHumanEval/39", "prompt": "prime_fib はフィボナッチ数で、かつ素数であるn番目の数を返す。\n >>> prime_fib(1)\n 2\n >>> prime_fib(2)\n 3\n >>> prime_fib(3)\n 5\n >>> prime_fib(4)\n 13\n >>> prime_fib(5)\n 89", "code": "def prime_fib(n: int):\n import math\n\n def is_prime(p):\n if p < 2:\n return False\n for k in range(2, min(int(math.sqrt(p)) + 1, p - 1)):\n if p % k == 0:\n return False\n return True\n f = [0, 1]\n while True:\n f.append(f[-1] + f[-2])\n if is_prime(f[-1]):\n n -= 1\n if n == 0:\n return f[-1]\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(1) == 2\n assert candidate(2) == 3\n assert candidate(3) == 5\n assert candidate(4) == 13\n assert candidate(5) == 89\n assert candidate(6) == 233\n assert candidate(7) == 1597\n assert candidate(8) == 28657\n assert candidate(9) == 514229\n assert candidate(10) == 433494437\n\n\ncandidate = prime_fib\ncheck(candidate)", "entry_point": "prime_fib"} +{"task_id": "bt_JHumanEval/40", "prompt": "triples_sum_to_zero は整数のリストを引数に取り、\n リストの中に和が0になる3つの要素があればTrueを、\n そうでなければFalseを返す。\n \n >>> triples_sum_to_zero([1, 3, 5, 0])\n False\n >>> triples_sum_to_zero([1, 3, -2, 1])\n True\n >>> triples_sum_to_zero([1, 2, 3, 7])\n False\n >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])\n True\n >>> triples_sum_to_zero([1])\n False", "code": "def triples_sum_to_zero(l: list):\n for i in range(len(l)):\n for j in range(i + 1, len(l)):\n for k in range(j + 1, len(l)):\n if l[i] + l[j] + l[k] == 0:\n return True\n return False\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 3, 5, 0]) == False\n assert candidate([1, 3, 5, -1]) == False\n assert candidate([1, 3, -2, 1]) == True\n assert candidate([1, 2, 3, 7]) == False\n assert candidate([1, 2, 5, 7]) == False\n assert candidate([2, 4, -5, 3, 9, 7]) == True\n assert candidate([1]) == False\n assert candidate([1, 3, 5, -100]) == False\n assert candidate([100, 3, 5, -100]) == False\n\n\ncandidate = triples_sum_to_zero\ncheck(candidate)", "entry_point": "triples_sum_to_zero"} +{"task_id": "bt_JHumanEval/41", "prompt": "完全な直線で無限に長い道路を想像してほしい。\n n台の車が左から右に向かって走っている。同時に、別のn台の車が\n 右から左に向かって走っている。この2組の車は、最初は互いに非\n 常に離れている。すべての車は同じ速度で動く。2台の車は次のよ\n うに衝突する。左から右に動いている車が、右から左に動いて��る\n 車にぶつかること。\n しかし、車は限りなく頑丈で強い。あたかも衝突しなかったかのよ\n うに、その軌道を進み続ける。 \n \n この関数は、このような衝突の回数を出力する。", "code": "def car_race_collision(n: int):\n return n**2\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(2) == 4\n assert candidate(3) == 9\n assert candidate(4) == 16\n assert candidate(8) == 64\n assert candidate(10) == 100\n\n\ncandidate = car_race_collision\ncheck(candidate)", "entry_point": "car_race_collision"} +{"task_id": "bt_JHumanEval/42", "prompt": "要素を1ずつ増やしたリストを返す。\n >>> incr_list([1, 2, 3])\n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]", "code": "def incr_list(l: list):\n return [(e + 1) for e in l]\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([]) == []\n assert candidate([3, 2, 1]) == [4, 3, 2]\n assert candidate([5, 2, 5, 2, 3, 3, 9, 0, 123]) == [6, 3, 6, 3, 4, 4, 10, 1, 124]\n\n\ncandidate = incr_list\ncheck(candidate)", "entry_point": "incr_list"} +{"task_id": "bt_JHumanEval/43", "prompt": "pairs_sum_to_zero は整数のリストを引数にとる。\n リストの中に2つの要素の和がゼロになる要素があればTrueを、\n そうでなければFalseを返す。\n >>> pairs_sum_to_zero([1, 3, 5, 0])\n False\n >>> pairs_sum_to_zero([1, 3, -2, 1])\n False\n >>> pairs_sum_to_zero([1, 2, 3, 7])\n False\n >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])\n True\n >>> pairs_sum_to_zero([1])\n False", "code": "def pairs_sum_to_zero(l):\n for i, l1 in enumerate(l):\n for j in range(i + 1, len(l)):\n if l1 + l[j] == 0:\n return True\n return False\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 3, 5, 0]) == False\n assert candidate([1, 3, -2, 1]) == False\n assert candidate([1, 2, 3, 7]) == False\n assert candidate([2, 4, -5, 3, 5, 7]) == True\n assert candidate([1]) == False\n\n assert candidate([-3, 9, -1, 3, 2, 30]) == True\n assert candidate([-3, 9, -1, 3, 2, 31]) == True\n assert candidate([-3, 9, -1, 4, 2, 30]) == False\n assert candidate([-3, 9, -1, 4, 2, 31]) == False\n\n\ncandidate = pairs_sum_to_zero\ncheck(candidate)", "entry_point": "pairs_sum_to_zero"} +{"task_id": "bt_JHumanEval/44", "prompt": "引数xの基数をbaseに変換する。\n 返り値は変換後の文字列表現である。\n 基数は10未満である。\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'", "code": "def change_base(x: int, base: int):\n ret = \"\"\n while x > 0:\n ret = str(x % base) + ret\n x //= base\n return ret\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(8, 3) == \"22\"\n assert candidate(9, 3) == \"100\"\n assert candidate(234, 2) == \"11101010\"\n assert candidate(16, 2) == \"10000\"\n assert candidate(8, 2) == \"1000\"\n assert candidate(7, 2) == \"111\"\n for x in range(2, 8):\n assert candidate(x, x + 1) == str(x)\n\n\ncandidate = change_base\ncheck(candidate)", "entry_point": "change_base"} +{"task_id": "bt_JHumanEval/45", "prompt": "三角形の一辺の長さと高さが与えられたとき、面積を返す。\n >>> triangle_area(5, 3)\n 7.5", "code": "def triangle_area(a, h):\n return a * h / 2.0\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(5, 3) == 7.5\n assert candidate(2, 2) == 2.0\n assert candidate(10, 8) == 40.0\n\n\ncandidate = triangle_area\ncheck(candidate)", "entry_point": "triangle_area"} +{"task_id": "bt_JHumanEval/46", "prompt": "fib4数列はフィボナッチ数列に似た数列で、次のように定義される:\n fib4(0) -> 0\n fib4(1) -> 0\n fib4(2) -> 2\n fib4(3) -> 0\n fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n fib4数列のn番目の要素を効率的に計算する関数を書け。再帰は使わないこと。\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14", "code": "def fib4(n: int):\n results = [0, 0, 2, 0]\n if n < 4:\n return results[n]\n\n for _ in range(4, n + 1):\n results.append(results[-1] + results[-2] + results[-3] + results[-4])\n results.pop(0)\n\n return results[-1]\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(5) == 4\n assert candidate(8) == 28\n assert candidate(10) == 104\n assert candidate(12) == 386\n\n\ncandidate = fib4\ncheck(candidate)", "entry_point": "fib4"} +{"task_id": "bt_JHumanEval/47", "prompt": "リスト l の要素の中央値を返す。\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0", "code": "def median(l: list):\n l = sorted(l)\n if len(l) % 2 == 1:\n return l[len(l) // 2]\n else:\n return (l[len(l) // 2 - 1] + l[len(l) // 2]) / 2.0\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([3, 1, 2, 4, 5]) == 3\n assert candidate([-10, 4, 6, 1000, 10, 20]) == 8.0\n assert candidate([5]) == 5\n assert candidate([6, 5]) == 5.5\n assert candidate([8, 1, 3, 9, 9, 2, 7]) == 7 \n\n\ncandidate = median\ncheck(candidate)", "entry_point": "median"} +{"task_id": "bt_JHumanEval/48", "prompt": "与えられた文字列が回文かどうかを判定する\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False", "code": "def is_palindrome(text: str):\n for i in range(len(text)):\n if text[i] != text[len(text) - 1 - i]:\n return False\n return True\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate('') == True\n assert candidate('aba') == True\n assert candidate('aaaaa') == True\n assert candidate('zbcd') == False\n assert candidate('xywyx') == True\n assert candidate('xywyz') == False\n assert candidate('xywzx') == False\n\n\ncandidate = is_palindrome\ncheck(candidate)", "entry_point": "is_palindrome"} +{"task_id": "bt_JHumanEval/49", "prompt": "2^n を p で割ったモジュロを返す。計算精度に注意。\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101)\n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11)\n 8\n >>> modp(100, 101)\n 1", "code": "def modp(n: int, p: int):\n ret = 1\n for i in range(n):\n ret = (2 * ret) % p\n return ret\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(3, 5) == 3\n assert candidate(1101, 101) == 2\n assert candidate(0, 101) == 1\n assert candidate(3, 11) == 8\n assert candidate(100, 101) == 1\n assert candidate(30, 5) == 4\n assert candidate(31, 5) == 3\n\n\ncandidate = modp\ncheck(candidate)", "entry_point": "modp"} +{"task_id": "bt_JHumanEval/50", "prompt": "encode_shift関数でエンコードされた文字列を引数に取り、デコードされた文字列を返す。", "code": "def encode_shift(s: str):\n \n return \"\".join([chr(((ord(ch) + 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n\n\ndef decode_shift(s: str):\n return \"\".join([chr(((ord(ch) - 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n from random import randint, choice\n import copy\n import string\n\n letters = string.ascii_lowercase\n for _ in range(100):\n str = ''.join(choice(letters) for i in range(randint(10, 20)))\n encoded_str = encode_shift(str)\n assert candidate(copy.deepcopy(encoded_str)) == str\n\n\ncandidate = decode_shift\ncheck(candidate)", "entry_point": "decode_shift"} +{"task_id": "bt_JHumanEval/51", "prompt": "remove_vowelsは文字列を引数に取り、母音を除いた文字列を返す関数である。\n >>> remove_vowels('')\n ''\n >>> remove_vowels(\"abcdef\\nghijklm\")\n 'bcdf\\nghjklm'\n >>> remove_vowels('abcdef')\n 'bcdf'\n >>> remove_vowels('aaaaa')\n ''\n >>> remove_vowels('aaBAA')\n 'B'\n >>> remove_vowels('zbcd')\n 'zbcd'", "code": "def remove_vowels(text):\n return \"\".join([s for s in text if s.lower() not in [\"a\", \"e\", \"i\", \"o\", \"u\"]])\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate('') == ''\n assert candidate(\"abcdef\\nghijklm\") == 'bcdf\\nghjklm'\n assert candidate('fedcba') == 'fdcb'\n assert candidate('eeeee') == ''\n assert candidate('acBAA') == 'cB'\n assert candidate('EcBOO') == 'cB'\n assert candidate('ybcd') == 'ybcd'\n\n\ncandidate = remove_vowels\ncheck(candidate)", "entry_point": "remove_vowels"} +{"task_id": "bt_JHumanEval/52", "prompt": "リスト l 内の全ての数値が閾値 t 以下の場合、Trueを返す。\n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False", "code": "def below_threshold(l: list, t: int):\n for e in l:\n if e >= t:\n return False\n return True\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 2, 4, 10], 100)\n assert not candidate([1, 20, 4, 10], 5)\n assert candidate([1, 20, 4, 10], 21)\n assert candidate([1, 20, 4, 10], 22)\n assert candidate([1, 8, 4, 10], 11)\n assert not candidate([1, 8, 4, 10], 10)\n\n\ncandidate = below_threshold\ncheck(candidate)", "entry_point": "below_threshold"} +{"task_id": "bt_JHumanEval/53", "prompt": "2つの数xとyを足す\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12", "code": "def add(x: int, y: int):\n return x + y\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n import random\n\n assert candidate(0, 1) == 1\n assert candidate(1, 0) == 1\n assert candidate(2, 3) == 5\n assert candidate(5, 7) == 12\n assert candidate(7, 5) == 12\n\n for i in range(100):\n x, y = random.randint(0, 1000), random.randint(0, 1000)\n assert candidate(x, y) == x + y\n\n\ncandidate = add\ncheck(candidate)", "entry_point": "add"} +{"task_id": "bt_JHumanEval/54", "prompt": "2つの単語が同じ文字セットから構成されるかどうか判定する。\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc')\n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce')\n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False", "code": "def same_chars(s0: str, s1: str):\n return set(s0) == set(s1)\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate('eabcdzzzz', 'dddzzzzzzzddeddabc') == True\n assert candidate('abcd', 'dddddddabc') == True\n assert candidate('dddddddabc', 'abcd') == True\n assert candidate('eabcd', 'dddddddabc') == False\n assert candidate('abcd', 'dddddddabcf') == False\n assert candidate('eabcdzzzz', 'dddzzzzzzzddddabc') == False\n assert candidate('aabb', 'aaccc') == False\n\n\ncandidate = same_chars\ncheck(candidate)", "entry_point": "same_chars"} +{"task_id": "bt_JHumanEval/55", "prompt": "n番目のフィボナッチ数を返す。\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21", "code": "def fib(n: int):\n if n == 0:\n return 0\n if n == 1:\n return 1\n return fib(n - 1) + fib(n - 2)\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(10) == 55\n assert candidate(1) == 1\n assert candidate(8) == 21\n assert candidate(11) == 89\n assert candidate(12) == 144\n\n\ncandidate = fib\ncheck(candidate)", "entry_point": "fib"} +{"task_id": "bt_JHumanEval/56", "prompt": "引数bracketsは\"<\"と\">\"の文字列である。\n すべての開き括弧が対応する閉じ括弧を持つ場合、Trueを返す。\n \n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False", "code": "def correct_bracketing(brackets: str):\n depth = 0\n for b in brackets:\n if b == \"<\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(\"<>\")\n assert candidate(\"<<><>>\")\n assert candidate(\"<><><<><>><>\")\n assert candidate(\"<><><<<><><>><>><<><><<>>>\")\n assert not candidate(\"<<<><>>>>\")\n assert not candidate(\"><<>\")\n assert not candidate(\"<\")\n assert not candidate(\"<<<<\")\n assert not candidate(\">\")\n assert not candidate(\"<<>\")\n assert not candidate(\"<><><<><>><>><<>\")\n assert not candidate(\"<><><<><>><>>><>\")\n\n\ncandidate = correct_bracketing\ncheck(candidate)", "entry_point": "correct_bracketing"} +{"task_id": "bt_JHumanEval/57", "prompt": "リストの要素が単調増加または単調減少する場合にTrueを返す。\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True", "code": "def monotonic(l: list):\n if l == sorted(l) or l == sorted(l, reverse=True):\n return True\n return False\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 2, 4, 10]) == True\n assert candidate([1, 2, 4, 20]) == True\n assert candidate([1, 20, 4, 10]) == False\n assert candidate([4, 1, 0, -10]) == True\n assert candidate([4, 1, 1, 0]) == True\n assert candidate([1, 2, 3, 2, 5, 60]) == False\n assert candidate([1, 2, 3, 4, 5, 60]) == True\n assert candidate([9, 9, 9, 9]) == True\n\n\ncandidate = monotonic\ncheck(candidate)", "entry_point": "monotonic"} +{"task_id": "bt_JHumanEval/58", "prompt": "2つのリストについて、ユニークな共通要素をソートして返す。\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]", "code": "def common(l1: list, l2: list):\n ret = set()\n for e1 in l1:\n for e2 in l2:\n if e1 == e2:\n ret.add(e1)\n return sorted(list(ret))\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]\n assert candidate([5, 3, 2, 8], [3, 2]) == [2, 3]\n assert candidate([4, 3, 2, 8], [3, 2, 4]) == [2, 3, 4]\n assert candidate([4, 3, 2, 8], []) == []\n\n\ncandidate = common\ncheck(candidate)", "entry_point": "common"} +{"task_id": "bt_JHumanEval/59", "prompt": "nの最大となる素因数を返す。ただし、 n > 1 を前提とし、素数ではないものとする。\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2", "code": "def largest_prime_factor(n: int):\n def is_prime(k):\n if k < 2:\n return False\n for i in range(2, k - 1):\n if k % i == 0:\n return False\n return True\n largest = 1\n for j in range(2, n + 1):\n if n % j == 0 and is_prime(j):\n largest = max(largest, j)\n return largest\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(15) == 5\n assert candidate(27) == 3\n assert candidate(63) == 7\n assert candidate(330) == 11\n assert candidate(13195) == 29\n\n\ncandidate = largest_prime_factor\ncheck(candidate)", "entry_point": "largest_prime_factor"} +{"task_id": "bt_JHumanEval/60", "prompt": "sum_to_nは1からnまでの総和を求める関数である。\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1", "code": "def sum_to_n(n: int):\n return sum(range(n + 1))\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(1) == 1\n assert candidate(6) == 21\n assert candidate(11) == 66\n assert candidate(30) == 465\n assert candidate(100) == 5050\n\n\ncandidate = sum_to_n\ncheck(candidate)", "entry_point": "sum_to_n"} +{"task_id": "bt_JHumanEval/61", "prompt": "引数bracketsは\"(\"と\") \"からなる文字列である。\n すべての開き括弧が対応する閉じ括弧を持つ場合、Trueを返す。\n \n >>> correct_bracketing(\"(\")\n False\n >>> correct_bracketing(\"()\")\n True\n >>> correct_bracketing(\"(()())\")\n True\n >>> correct_bracketing(\")(()\")\n False", "code": "def correct_bracketing(brackets: str):\n depth = 0\n for b in brackets:\n if b == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(\"()\")\n assert candidate(\"(()())\")\n assert candidate(\"()()(()())()\")\n assert candidate(\"()()((()()())())(()()(()))\")\n assert not candidate(\"((()())))\")\n assert not candidate(\")(()\")\n assert not candidate(\"(\")\n assert not candidate(\"((((\")\n assert not candidate(\")\")\n assert not candidate(\"(()\")\n assert not candidate(\"()()(()())())(()\")\n assert not candidate(\"()()(()())()))()\")\n\n\ncandidate = correct_bracketing\ncheck(candidate)", "entry_point": "correct_bracketing"} +{"task_id": "bt_JHumanEval/62", "prompt": "xsは多項式の係数列を表す。\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n 関数は、この多項式の導関数を同じ形式で返す。\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]", "code": "def derivative(xs: list):\n return [(i * x) for i, x in enumerate(xs)][1:]\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([3, 1, 2, 4, 5]) == [1, 4, 12, 20]\n assert candidate([1, 2, 3]) == [2, 6]\n assert candidate([3, 2, 1]) == [2, 2]\n assert candidate([3, 2, 1, 0, 4]) == [2, 2, 0, 16]\n assert candidate([1]) == []\n\n\ncandidate = derivative\ncheck(candidate)", "entry_point": "derivative"} +{"task_id": "bt_JHumanEval/63", "prompt": "FibFib数列はフィボナッチ数列に似た数列で、以下のように定義される:\n fibfib(0) == 0\n fibfib(1) == 0\n fibfib(2) == 1\n fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n fibfib数列のn番目の要素を効率よく計算する関数を書いてください。\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24", "code": "def fibfib(n: int):\n if n == 0:\n return 0\n if n == 1:\n return 0\n if n == 2:\n return 1\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n", "testcode": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(2) == 1\n assert candidate(1) == 0\n assert candidate(5) == 4\n assert candidate(8) == 24\n assert candidate(10) == 81\n assert candidate(12) == 274\n assert candidate(14) == 927\n\n\ncandidate = fibfib\ncheck(candidate)", "entry_point": "fibfib"} +{"task_id": "bt_JHumanEval/64", "prompt": "単語を表す文字列を引数とし、その文字列に含まれる母音の数を返す\n 関数 vowels_count を書きなさい。この場合の母音は'a', 'e', 'i', 'o', 'u'である。\n ここで、与えられた単語の末尾にある場合のみ、'y'も母音とする。\n \n 例:\n >>> vowels_count(\"abcde\")\n 2\n >>> vowels_count(\"ACEDY\")\n 3", "code": "FIX = def vowels_count(s):\n vowels = \"aeiouAEIOU\"\n n_vowels = sum(c in vowels for c in s)\n if s[-1] == 'y' or s[-1] == 'Y':\n n_vowels += 1\n return n_vowels\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"abcde\") == 2, \"Test 1\"\n assert candidate(\"Alone\") == 3, \"Test 2\"\n assert candidate(\"key\") == 2, \"Test 3\"\n assert candidate(\"bye\") == 1, \"Test 4\"\n assert candidate(\"keY\") == 2, \"Test 5\"\n assert candidate(\"bYe\") == 1, \"Test 6\"\n assert candidate(\"ACEDY\") == 3, \"Test 7\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = vowels_count\ncheck(candidate)", "entry_point": "vowels_count"} +{"task_id": "bt_JHumanEval/65", "prompt": "整数 x の桁を循環シフトする。shift 分だけ桁を右にシフトし、結果を文字列として返す。\n もし、shift > 桁数なら、桁を反転して返す。\n >>> circular_shift(12, 1)\n \"21\"\n >>> circular_shift(12, 2)\n \"12\"", "code": "def circular_shift(x, shift):\n s = str(x)\n if shift > len(s):\n return s[::-1]\n else:\n return s[len(s) - shift:] + s[:len(s) - shift]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(100, 2) == \"001\"\n assert candidate(12, 2) == \"12\"\n assert candidate(97, 8) == \"79\"\n assert candidate(12, 1) == \"21\", \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(11, 101) == \"11\", \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = circular_shift\ncheck(candidate)", "entry_point": "circular_shift"} +{"task_id": "bt_JHumanEval/66", "prompt": "タスク\n 文字列を引数にとり、英大文字のみのASCIIコードの和を返す関数を書く。\n Examples:\n digitSum(\"\") => 0\n digitSum(\"abAB\") => 131\n digitSum(\"abcCd\") => 67\n digitSum(\"helloE\") => 69\n digitSum(\"woArBld\") => 131\n digitSum(\"aAaaaXa\") => 153", "code": "def digitSum(s):\n if s == \"\": return 0\n return sum(ord(char) if char.isupper() else 0 for char in s)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(\"\") == 0, \"Error\"\n assert candidate(\"abAB\") == 131, \"Error\"\n assert candidate(\"abcCd\") == 67, \"Error\"\n assert candidate(\"helloE\") == 69, \"Error\"\n assert candidate(\"woArBld\") == 131, \"Error\"\n assert candidate(\"aAaaaXa\") == 153, \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(\" How are yOu?\") == 151, \"Error\"\n assert candidate(\"You arE Very Smart\") == 327, \"Error\"\n\n\ncandidate = digitSum\ncheck(candidate)", "entry_point": "digitSum"} +{"task_id": "bt_JHumanEval/67", "prompt": "この課題では、果物の入ったカゴに配られたリンゴとオレンジの数を表す文字列が\n 与えられ、このカゴにはリンゴ、オレンジ、マンゴーの果実が入っている。オレンジ\n とリンゴの総数を表す文字列と、かごの中の果物の総数を表す整数が与えられたら、\n かごの中のマンゴーの果物の数を返しなさい。\n たとえば:\n fruit_distribution(\"5 apples and 6 oranges\", 19) ->19 - 5 - 6 = 8\n fruit_distribution(\"0 apples and 1 oranges\",3) -> 3 - 0 - 1 = 2\n fruit_distribution(\"2 apples and 3 oranges\", 100) -> 100 - 2 - 3 = 95\n fruit_distribution(\"100 apples and 1 oranges\",120) -> 120 - 100 - 1 = 19", "code": "def fruit_distribution(s,n):\n lis = list()\n for i in s.split(' '):\n if i.isdigit():\n lis.append(int(i))\n return n - sum(lis)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"5 apples and 6 oranges\",19) == 8\n assert candidate(\"5 apples and 6 oranges\",21) == 10\n assert candidate(\"0 apples and 1 oranges\",3) == 2\n assert candidate(\"1 apples and 0 oranges\",3) == 2\n assert candidate(\"2 apples and 3 oranges\",100) == 95\n assert candidate(\"2 apples and 3 oranges\",5) == 0\n assert candidate(\"1 apples and 100 oranges\",120) == 19\n\ncandidate = fruit_distribution\ncheck(candidate)", "entry_point": "fruit_distribution"} +{"task_id": "bt_JHumanEval/68", "prompt": "非負整数のノードを持つ木の枝を表す配列が与えられたとする。あなたの仕事は、\n ノードの1つを抜き取り、それを返すことである。\n 摘出されるノードは、最小偶数値を持つノードでなければならない。\n 同じ最小偶数値を持つノードが複数見つかった場合は、最小のインデックスを持つ\n ノードを返す。\n\n 摘出されたノードは [ smalest_value, its index ] というリストで返されなければならない。\n 偶数値がない場合や与えられた配列が空の場合は [] を返します。\n 例 1:\n 入力: [4,2,3]\n 出力: [2, 1]\n 解説: 2は最小偶数値を持ち、最小インデックスを持つ。\n\n 例 2:\n 入力: [1,2,3]\n 出力: [2, 1]\n 解説: 2が最小偶数値で、2が最小インデックスを持つ。\n\n 例 3:\n 入力: []\n 出力: []\n \n 例 4:\n 入力: [5, 0, 3, 0, 4, 2]\n 出力: [0, 1]\n 解説: 0は最小値だが、0は2つあるので、最小インデックスを持つ最初の0を選ぶ。\n\n 制約:\n * 1 <= ノードの長さ <= 10000\n * 0 <= ノードの値", "code": "def pluck(arr):\n if(len(arr) == 0): return []\n evens = list(filter(lambda x: x%2 == 0, arr))\n if(evens == []): return []\n return [min(evens), arr.index(min(evens))]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([4,2,3]) == [2, 1], \"Error\"\n assert candidate([1,2,3]) == [2, 1], \"Error\"\n assert candidate([]) == [], \"Error\"\n assert candidate([5, 0, 3, 0, 4, 2]) == [0, 1], \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([1, 2, 3, 0, 5, 3]) == [0, 3], \"Error\"\n assert candidate([5, 4, 8, 4 ,8]) == [4, 1], \"Error\"\n assert candidate([7, 6, 7, 1]) == [6, 1], \"Error\"\n assert candidate([7, 9, 7, 1]) == [], \"Error\"\n\n\ncandidate = pluck\ncheck(candidate)", "entry_point": "pluck"} +{"task_id": "bt_JHumanEval/69", "prompt": "正の整数の空でないリストが与えられる。0より大きく、その整数自身の値以上の頻度を\n 持つ最大の整数を返せ。整数の頻度とは、それがリストに現れる回数である。\n そのような値が存在しない場合は -1 を返す。\n 例:\n search([4, 1, 2, 2, 3, 1]) == 2\n search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3\n search([5, 5, 4, 4, 4]) == -1", "code": "def search(lst):\n frq = [0] * (max(lst) + 1)\n for i in lst:\n frq[i] += 1;\n\n ans = -1\n for i in range(1, len(frq)):\n if frq[i] >= i:\n ans = i\n \n return ans\n", "testcode": "def check(candidate):\n\n # manually generated tests\n assert candidate([5, 5, 5, 5, 1]) == 1\n assert candidate([4, 1, 4, 1, 4, 4]) == 4\n assert candidate([3, 3]) == -1\n assert candidate([8, 8, 8, 8, 8, 8, 8, 8]) == 8\n assert candidate([2, 3, 3, 2, 2]) == 2\n\n # automatically generated tests\n assert candidate([2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10, 4, 3, 6, 7, 1, 7, 4, 10, 8, 1]) == 1\n assert candidate([3, 2, 8, 2]) == 2\n assert candidate([6, 7, 1, 8, 8, 10, 5, 8, 5, 3, 10]) == 1\n assert candidate([8, 8, 3, 6, 5, 6, 4]) == -1\n assert candidate([6, 9, 6, 7, 1, 4, 7, 1, 8, 8, 9, 8, 10, 10, 8, 4, 10, 4, 10, 1, 2, 9, 5, 7, 9]) == 1\n assert candidate([1, 9, 10, 1, 3]) == 1\n assert candidate([6, 9, 7, 5, 8, 7, 5, 3, 7, 5, 10, 10, 3, 6, 10, 2, 8, 6, 5, 4, 9, 5, 3, 10]) == 5\n assert candidate([1]) == 1\n assert candidate([8, 8, 10, 6, 4, 3, 5, 8, 2, 4, 2, 8, 4, 6, 10, 4, 2, 1, 10, 2, 1, 1, 5]) == 4\n assert candidate([2, 10, 4, 8, 2, 10, 5, 1, 2, 9, 5, 5, 6, 3, 8, 6, 4, 10]) == 2\n assert candidate([1, 6, 10, 1, 6, 9, 10, 8, 6, 8, 7, 3]) == 1\n assert candidate([9, 2, 4, 1, 5, 1, 5, 2, 5, 7, 7, 7, 3, 10, 1, 5, 4, 2, 8, 4, 1, 9, 10, 7, 10, 2, 8, 10, 9, 4]) == 4\n assert candidate([2, 6, 4, 2, 8, 7, 5, 6, 4, 10, 4, 6, 3, 7, 8, 8, 3, 1, 4, 2, 2, 10, 7]) == 4\n assert candidate([9, 8, 6, 10, 2, 6, 10, 2, 7, 8, 10, 3, 8, 2, 6, 2, 3, 1]) == 2\n assert candidate([5, 5, 3, 9, 5, 6, 3, 2, 8, 5, 6, 10, 10, 6, 8, 4, 10, 7, 7, 10, 8]) == -1\n assert candidate([10]) == -1\n assert candidate([9, 7, 7, 2, 4, 7, 2, 10, 9, 7, 5, 7, 2]) == 2\n assert candidate([5, 4, 10, 2, 1, 1, 10, 3, 6, 1, 8]) == 1\n assert candidate([7, 9, 9, 9, 3, 4, 1, 5, 9, 1, 2, 1, 1, 10, 7, 5, 6, 7, 6, 7, 7, 6]) == 1\n assert candidate([3, 10, 10, 9, 2]) == -1\n\n\ncandidate = search\ncheck(candidate)", "entry_point": "search"} +{"task_id": "bt_JHumanEval/70", "prompt": "整数のリストが与えられたとき、リストを奇妙な順序で返す。\n 奇妙なソートとは、最小値から始まり、残りの整数の最大値、最小値の順で\n ソートすることである。\n \n 例:\n strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]\n strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]\n strange_sort_list([]) == []", "code": "def strange_sort_list(lst):\n res, switch = [], True\n while lst:\n res.append(min(lst) if switch else max(lst))\n lst.remove(res[-1])\n switch = not switch\n return res", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1, 2, 3, 4]) == [1, 4, 2, 3]\n assert candidate([5, 6, 7, 8, 9]) == [5, 9, 6, 8, 7]\n assert candidate([1, 2, 3, 4, 5]) == [1, 5, 2, 4, 3]\n assert candidate([5, 6, 7, 8, 9, 1]) == [1, 9, 5, 8, 6, 7]\n assert candidate([5, 5, 5, 5]) == [5, 5, 5, 5]\n assert candidate([]) == []\n assert candidate([1,2,3,4,5,6,7,8]) == [1, 8, 2, 7, 3, 6, 4, 5]\n assert candidate([0,2,2,2,5,5,-5,-5]) == [-5, 5, -5, 5, 0, 2, 2, 2]\n assert candidate([111111]) == [111111]\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = strange_sort_list\ncheck(candidate)", "entry_point": "strange_sort_list"} +{"task_id": "bt_JHumanEval/71", "prompt": "三角形の3辺の長さが与えられた。3辺が有効な三角形を形成していれば、\n 三角形の面積を小数点以下2桁で四捨五入して返す。そうでない場合は-1を\n 返す。\n 任意の2辺の和が3辺より大きいとき、3辺は有効な三角形となる。\n 例:\n triangle_area(3, 4, 5) == 6.00\n triangle_area(1, 2, 10) == -1", "code": "def triangle_area(a, b, c):\n if a + b <= c or a + c <= b or b + c <= a:\n return -1 \n s = (a + b + c)/2 \n area = (s * (s - a) * (s - b) * (s - c)) ** 0.5\n area = round(area, 2)\n return area\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(3, 4, 5) == 6.00, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(1, 2, 10) == -1\n assert candidate(4, 8, 5) == 8.18\n assert candidate(2, 2, 2) == 1.73\n assert candidate(1, 2, 3) == -1\n assert candidate(10, 5, 7) == 16.25\n assert candidate(2, 6, 3) == -1\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1, 1, 1) == 0.43, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(2, 2, 10) == -1\n\n\ncandidate = triangle_area\ncheck(candidate)", "entry_point": "triangle_area"} +{"task_id": "bt_JHumanEval/72", "prompt": "物体qが飛べばTrueを、そうでなければFalseを返す関数を書け。\n 物体qはバランスが取れていて(つまり、リストが回文であって)、その要素の和が\n 最大荷重w以下であれば飛ぶ。\n \n 例:\n will_it_fly([1, 2], 5) ➞ False \n # 1+2 は最大荷重以下であるが、バランスが取れていない\n\n will_it_fly([3, 2, 3], 1) ➞ False\n # バランスが取れているが、3+2+3 は最大荷重を超える\n \n will_it_fly([3, 2, 3], 9) ➞ True\n # 3+2+3 は最大荷重以下であり、バランスも取れている\n\n will_it_fly([3], 5) ➞ True\n # 3 は最大荷重以下であり、バランスも取れている", "code": "def will_it_fly(q,w):\n if sum(q) > w:\n return False\n\n i, j = 0, len(q)-1\n while i true\n is_simple_power(2, 2) => true\n is_simple_power(8, 2) => true\n is_simple_power(3, 2) => false\n is_simple_power(3, 1) => false\n is_simple_power(5, 3) => false", "code": "def is_simple_power(x, n):\n if (n == 1): \n return (x == 1) \n power = 1\n while (power < x): \n power = power * n \n return (power == x) \n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(16, 2)== True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(143214, 16)== False, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(4, 2)==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(9, 3)==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(16, 4)==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(24, 2)==False, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(128, 4)==False, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(12, 6)==False, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1, 1)==True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(1, 12)==True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = is_simple_power\ncheck(candidate)", "entry_point": "is_simple_power"} +{"task_id": "bt_JHumanEval/77", "prompt": "整数aを受け取り、この整数がある整数の3乗である場合にTrue\n を返す関数を書きなさい。\n 注意:入力は常に処理可能であると仮定してよい。\n 例:\n iscube(1) ==> True\n iscube(2) ==> False\n iscube(-1) ==> True\n iscube(64) ==> True\n iscube(0) ==> True\n iscube(180) ==> False", "code": "def iscube(a):\n a = abs(a)\n return int(round(a ** (1. / 3))) ** 3 == a\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(1) == True, \"First test error: \" + str(candidate(1))\n assert candidate(2) == False, \"Second test error: \" + str(candidate(2))\n assert candidate(-1) == True, \"Third test error: \" + str(candidate(-1))\n assert candidate(64) == True, \"Fourth test error: \" + str(candidate(64))\n assert candidate(180) == False, \"Fifth test error: \" + str(candidate(180))\n assert candidate(1000) == True, \"Sixth test error: \" + str(candidate(1000))\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(0) == True, \"1st edge test error: \" + str(candidate(0))\n assert candidate(1729) == False, \"2nd edge test error: \" + str(candidate(1728))\n\n\ncandidate = iscube\ncheck(candidate)", "entry_point": "iscube"} +{"task_id": "bt_JHumanEval/78", "prompt": "16進数の数字を文字列として受け取り、その中に含まれる素数である16進数の桁数を\n カウントする関数を作成するタスクが与えられました。素数とは、1より大きく、\n 2つのより小さい自然数の積でない自然数です。\n 16進数の桁には0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, Fがあります。\n 素数としては2, 3, 5, 7, 11, 13, 17,...があります。\n したがって、次の数字のいずれかがいくつあるかを判定する必要があります:\n 2, 3, 5, 7, B(=10進数で11), D(=10進数で13)\n 注意:入力は常に正確、または空の文字列であり、記号A, B, C, D, E, Fは常に\n 大文字であると仮定してよいです。\n 例:\n num = \"AB\" の場合、出力は 1 です。\n num = \"1077E\" の場合、出力は 2 です。\n num = \"ABED1A33\" の場合、出力は 4 です。\n num = \"123456789ABCDEF0\" の場合、出力は 6 です。\n num = \"2020\" の場合、出力は 2 です。be 2.", "code": "def hex_key(num):\n primes = ('2', '3', '5', '7', 'B', 'D')\n total = 0\n for i in range(0, len(num)):\n if num[i] in primes:\n total += 1\n return total\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"AB\") == 1, \"First test error: \" + str(candidate(\"AB\")) \n assert candidate(\"1077E\") == 2, \"Second test error: \" + str(candidate(\"1077E\")) \n assert candidate(\"ABED1A33\") == 4, \"Third test error: \" + str(candidate(\"ABED1A33\")) \n assert candidate(\"2020\") == 2, \"Fourth test error: \" + str(candidate(\"2020\")) \n assert candidate(\"123456789ABCDEF0\") == 6, \"Fifth test error: \" + str(candidate(\"123456789ABCDEF0\")) \n assert candidate(\"112233445566778899AABBCCDDEEFF00\") == 12, \"Sixth test error: \" + str(candidate(\"112233445566778899AABBCCDDEEFF00\")) \n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([]) == 0\n\n\ncandidate = hex_key\ncheck(candidate)", "entry_point": "hex_key"} +{"task_id": "bt_JHumanEval/79", "prompt": "10進数形式の数値が与えられ、あなたのタスクはそれを2進数形式に変換することである。\n この関数は、文字列を返し、その各文字は2進数を表す。文字列の各文字は'0'か'1'である。\n \n なお、文字列の最初と最後には'db'という余分な文字をつける。\n この文字は書式を助けるためにある。\n \n 例:\n decimal_to_binary(15) # \"db1111db\"を返す\n decimal_to_binary(32) # \"db100000db\"を返す", "code": "def decimal_to_binary(decimal):\n return \"db\" + bin(decimal)[2:] + \"db\"\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(0) == \"db0db\"\n assert candidate(32) == \"db100000db\"\n assert candidate(103) == \"db1100111db\"\n assert candidate(15) == \"db1111db\", \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = decimal_to_binary\ncheck(candidate)", "entry_point": "decimal_to_binary"} +{"task_id": "bt_JHumanEval/80", "prompt": "あなたは文字列sが与えられる。\n あなたのタスクは、その文字列が幸せかどうかをチェックすることである。\n 文字列は幸せとは、文字列の長さが少なくとも3以上で、連続する3文字がすべて異なる場合である。\n 例えば:\n is_happy(a) => False\n is_happy(aa) => False\n is_happy(abcd) => True\n is_happy(aabb) => False\n is_happy(adb) => True\n is_happy(xyy) => False", "code": "def is_happy(s):\n if len(s) < 3:\n return False\n\n for i in range(len(s) - 2):\n \n if s[i] == s[i+1] or s[i+1] == s[i+2] or s[i] == s[i+2]:\n return False\n return True\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"a\") == False , \"a\"\n assert candidate(\"aa\") == False , \"aa\"\n assert candidate(\"abcd\") == True , \"abcd\"\n assert candidate(\"aabb\") == False , \"aabb\"\n assert candidate(\"adb\") == True , \"adb\"\n assert candidate(\"xyy\") == False , \"xyy\"\n assert candidate(\"iopaxpoi\") == True , \"iopaxpoi\"\n assert candidate(\"iopaxioi\") == False , \"iopaxioi\"\n\ncandidate = is_happy\ncheck(candidate)", "entry_point": "is_happy"} +{"task_id": "bt_JHumanEval/81", "prompt": "学期最終週、教師は生徒に成績をつけなければならない。教師は独自のアルゴリズムで採点している。\n 問題は、彼女が成績評価に使ったコードを紛失してしまったことです。\n 彼女は何人かの生徒のGPAのリストをあなたに渡したので、あなたは次の表を使って評点のリストを\n 出力できる関数を書くことになりました。\n\n GPA | 評点\n 4.0 A+\n > 3.7 A \n > 3.3 A- \n > 3.0 B+\n > 2.7 B \n > 2.3 B-\n > 2.0 C+\n > 1.7 C\n > 1.3 C-\n > 1.0 D+ \n > 0.7 D \n > 0.0 D-\n 0.0 E\n \n\n 例:\n grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']", "code": "def numerical_letter_grade(grades):\n\n \n letter_grade = []\n for gpa in grades:\n if gpa == 4.0:\n letter_grade.append(\"A+\")\n elif gpa > 3.7:\n letter_grade.append(\"A\")\n elif gpa > 3.3:\n letter_grade.append(\"A-\")\n elif gpa > 3.0:\n letter_grade.append(\"B+\")\n elif gpa > 2.7:\n letter_grade.append(\"B\")\n elif gpa > 2.3:\n letter_grade.append(\"B-\")\n elif gpa > 2.0:\n letter_grade.append(\"C+\")\n elif gpa > 1.7:\n letter_grade.append(\"C\")\n elif gpa > 1.3:\n letter_grade.append(\"C-\")\n elif gpa > 1.0:\n letter_grade.append(\"D+\")\n elif gpa > 0.7:\n letter_grade.append(\"D\")\n elif gpa > 0.0:\n letter_grade.append(\"D-\")\n else:\n letter_grade.append(\"E\")\n return letter_grade\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([4.0, 3, 1.7, 2, 3.5]) == ['A+', 'B', 'C-', 'C', 'A-']\n assert candidate([1.2]) == ['D+']\n assert candidate([0.5]) == ['D-']\n assert candidate([0.0]) == ['E']\n assert candidate([1, 0.3, 1.5, 2.8, 3.3]) == ['D', 'D-', 'C-', 'B', 'B+']\n assert candidate([0, 0.7]) == ['E', 'D-']\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = numerical_letter_grade\ncheck(candidate)", "entry_point": "numerical_letter_grade"} +{"task_id": "bt_JHumanEval/82", "prompt": "文字列を受け取り、文字列の長さが素数であればTrueを、そうでなければFalseを返す関数を書く。\n 例\n prime_length('Hello') == True\n prime_length('abcdcba') == True\n prime_length('kittens') == True\n prime_length('orange') == False", "code": "def prime_length(string):\n l = len(string)\n if l == 0 or l == 1:\n return False\n for i in range(2, l):\n if l % i == 0:\n return False\n return True\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('Hello') == True\n assert candidate('abcdcba') == True\n assert candidate('kittens') == True\n assert candidate('orange') == False\n assert candidate('wow') == True\n assert candidate('world') == True\n assert candidate('MadaM') == True\n assert candidate('Wow') == True\n assert candidate('') == False\n assert candidate('HI') == True\n assert candidate('go') == True\n assert candidate('gogo') == False\n assert candidate('aaaaaaaaaaaaaaa') == False\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('Madam') == True\n assert candidate('M') == False\n assert candidate('0') == False\n\n\ncandidate = prime_length\ncheck(candidate)", "entry_point": "prime_length"} +{"task_id": "bt_JHumanEval/83", "prompt": "正の整数 n が与えられたとき、n 桁の正の整数で 1 で始まるか\n もしくは終わる数のカウントを返す", "code": "def starts_one_ends(n):\n if n == 1: return 1\n return 18 * (10 ** (n - 2))\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(1) == 1\n assert candidate(2) == 18\n assert candidate(3) == 180\n assert candidate(4) == 1800\n assert candidate(5) == 18000\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = starts_one_ends\ncheck(candidate)", "entry_point": "starts_one_ends"} +{"task_id": "bt_JHumanEval/84", "prompt": "正の整数 N が与えられた時、その桁の総和を2進数で返す。\n 例\n N = 1000のとき, 各桁の総和は1、だから返り値は \"1\".\n N = 150のとき,各桁の総和は6、 だから返り値は \"110\".\n N = 147のとき,各桁の総和は12、 だから返り値は \"1100\".\n \n 変数:\n @N 整数\n 制約: 0 ≤ N ≤ 10000.\n 返り値:\n 2進数表記の文字列", "code": "def solve(N):\n return bin(sum(int(i) for i in str(N)))[2:]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(1000) == \"1\", \"Error\"\n assert candidate(150) == \"110\", \"Error\"\n assert candidate(147) == \"1100\", \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(333) == \"1001\", \"Error\"\n assert candidate(963) == \"10010\", \"Error\"\n\n\ncandidate = solve\ncheck(candidate)", "entry_point": "solve"} +{"task_id": "bt_JHumanEval/85", "prompt": "空でない整数のリストlstが与えられたとき、奇数のインデックスにある偶数の要素を加える。\n\n 例:\n add([4, 2, 6, 7]) ==> 2", "code": "def add(lst):\n return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([4, 88]) == 88\n assert candidate([4, 5, 6, 7, 2, 122]) == 122\n assert candidate([4, 0, 6, 7]) == 0\n assert candidate([4, 4, 6, 8]) == 12\n\n # Check some edge cases that are easy to work out by hand.\n \n\ncandidate = add\ncheck(candidate)", "entry_point": "add"} +{"task_id": "bt_JHumanEval/86", "prompt": "文字列を引数として受け取り、その「順序付けられたバージョン」を返す関数を作成してください。\n 順序付けられたバージョンとは、各単語(空白で区切られた)の文字がASCII値に基づいて昇順に\n 並べ替えられた新しい単語に置き換えられた文字列です。\n 注意:文章内の単語と空白の順序はそのまま保ってください。\n \n 例えば:\n anti_shuffle('Hi') は 'Hi'を返す\n anti_shuffle('hello') は 'ehllo'返す\n anti_shuffle('Hello World!!!') は 'Hello !!!Wdlor'返す", "code": "def anti_shuffle(s):\n return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('Hi') == 'Hi'\n assert candidate('hello') == 'ehllo'\n assert candidate('number') == 'bemnru'\n assert candidate('abcd') == 'abcd'\n assert candidate('Hello World!!!') == 'Hello !!!Wdlor'\n assert candidate('') == ''\n assert candidate('Hi. My name is Mister Robot. How are you?') == '.Hi My aemn is Meirst .Rboot How aer ?ouy'\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = anti_shuffle\ncheck(candidate)", "entry_point": "anti_shuffle"} +{"task_id": "bt_JHumanEval/87", "prompt": "2次元のデータがネストされたリストとして与えられる。これは行列に似ているが、\n 行列とは異なり、各行は異なる数の列を含むことができる。\n lstと整数xが与えられたとき、リスト内の整数xを見つけ、各タプルが0から始まる\n 座標(行、列)であるようなタプルのリスト[(x1, y1), (x2, y2) ...]を返す。\n 座標を最初は行の昇順でソートする。\n また、行の座標を列の降順でソートする。\n \n 例:\n get_row([\n [1,2,3,4,5,6],\n [1,2,3,4,1,6],\n [1,2,3,4,5,1]\n ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n get_row([], 1) == []\n get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]", "code": "def get_row(lst, x):\n coords = [(i, j) for i in range(len(lst)) for j in range(len(lst[i])) if lst[i][j] == x]\n return sorted(sorted(coords, key=lambda x: x[1], reverse=True), key=lambda x: x[0])\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([\n [1,2,3,4,5,6],\n [1,2,3,4,1,6],\n [1,2,3,4,5,1]\n ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n assert candidate([\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,2,3,4,5,6]\n ], 2) == [(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]\n assert candidate([\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,1,3,4,5,6],\n [1,2,1,4,5,6],\n [1,2,3,1,5,6],\n [1,2,3,4,1,6],\n [1,2,3,4,5,1]\n ], 1) == [(0, 0), (1, 0), (2, 1), (2, 0), (3, 2), (3, 0), (4, 3), (4, 0), (5, 4), (5, 0), (6, 5), (6, 0)]\n assert candidate([], 1) == []\n assert candidate([[1]], 2) == []\n assert candidate([[], [1], [1, 2, 3]], 3) == [(2, 2)]\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = get_row\ncheck(candidate)", "entry_point": "get_row"} +{"task_id": "bt_JHumanEval/88", "prompt": "非負の整数からなる配列が与えられた場合、配列をソートしたコピーを返してください。\n 配列の最初の要素と最後の要素の和が奇数であれば、配列を昇順(小さい順)にソートします。\n その和が偶数であれば、配列を降順(大きい順)にソートします。\n\n 注意点:\n * 与えられた配列自体を変更しないでください。\n\n 例:\n * sort_array([]) => []\n * sort_array([5]) => [5]\n * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]\n * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]", "code": "def sort_array(array):\n return [] if len(array) == 0 else sorted(array, reverse= (array[0]+array[-1]) % 2 == 0) \n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([]) == [], \"Error\"\n assert candidate([5]) == [5], \"Error\"\n assert candidate([2, 4, 3, 0, 1, 5]) == [0, 1, 2, 3, 4, 5], \"Error\"\n assert candidate([2, 4, 3, 0, 1, 5, 6]) == [6, 5, 4, 3, 2, 1, 0], \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([2, 1]) == [1, 2], \"Error\"\n assert candidate([15, 42, 87, 32 ,11, 0]) == [0, 11, 15, 32, 42, 87], \"Error\"\n assert candidate([21, 14, 23, 11]) == [23, 21, 14, 11], \"Error\"\n\n\ncandidate = sort_array\ncheck(candidate)", "entry_point": "sort_array"} +{"task_id": "bt_JHumanEval/89", "prompt": "文字列を引数にとり、アルファベットを回転させて暗号化した\n 文字列を返す関数encryptを作成せよ。\n アルファベットは、文字位置を2倍して2つ下にシフトするように\n 回転する。\n 例:\n encrypt('hi') returns 'lm'\n encrypt('asdfghjkl') returns 'ewhjklnop'\n encrypt('gf') returns 'kj'\n encrypt('et') returns 'ix'", "code": "def encrypt(s):\n d = 'abcdefghijklmnopqrstuvwxyz'\n out = ''\n for c in s:\n if c in d:\n out += d[(d.index(c)+2*2) % 26]\n else:\n out += c\n return out\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('hi') == 'lm', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('asdfghjkl') == 'ewhjklnop', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('gf') == 'kj', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('et') == 'ix', \"This prints if this assert fails 1 (good for debugging!)\"\n\n assert candidate('faewfawefaewg')=='jeiajeaijeiak', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('hellomyfriend')=='lippsqcjvmirh', \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate('dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh')=='hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl', \"This prints if this assert fails 3 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('a')=='e', \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = encrypt\ncheck(candidate)", "entry_point": "encrypt"} +{"task_id": "bt_JHumanEval/90", "prompt": "整数のリストが与えられる。\n リストの2番目に小さい要素を返す関数 next_smallest() を書きなさい。\n そのような要素がない場合は None を返す。\n \n next_smallest([1, 2, 3, 4, 5]) == 2\n next_smallest([5, 1, 4, 3, 2]) == 2\n next_smallest([]) == None\n next_smallest([1, 1]) == None", "code": "def next_smallest(lst):\n lst = sorted(set(lst))\n return None if len(lst) < 2 else lst[1]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1, 2, 3, 4, 5]) == 2\n assert candidate([5, 1, 4, 3, 2]) == 2\n assert candidate([]) == None\n assert candidate([1, 1]) == None\n assert candidate([1,1,1,1,0]) == 1\n assert candidate([1, 0**0]) == None\n assert candidate([-35, 34, 12, -45]) == -35\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = next_smallest\ncheck(candidate)", "entry_point": "next_smallest"} +{"task_id": "bt_JHumanEval/91", "prompt": "単語の文字列が与えられ、あなたのタスクは退屈指数を数える\n ことである。退屈指数とは、\"I \"で始まる文のことである。\n 文は'.'、’?’、'!'のいずれかで区切られる。 \n \n 例えば:\n >>> is_bored(\"Hello world\")\n 0\n >>> is_bored(\"The sky is blue. The sun is shining. I love this weather\")\n 1", "code": "def is_bored(S):\n import re\n sentences = re.split(r'[.?!]\\s*', S)\n return sum(sentence[0:2] == 'I ' for sentence in sentences)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"Hello world\") == 0, \"Test 1\"\n assert candidate(\"Is the sky blue?\") == 0, \"Test 2\"\n assert candidate(\"I love It !\") == 1, \"Test 3\"\n assert candidate(\"bIt\") == 0, \"Test 4\"\n assert candidate(\"I feel good today. I will be productive. will kill It\") == 2, \"Test 5\"\n assert candidate(\"You and I are going for a walk\") == 0, \"Test 6\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = is_bored\ncheck(candidate)", "entry_point": "is_bored"} +{"task_id": "bt_JHumanEval/92", "prompt": "3つの数値を受け取る関数を作る。\n 1つの数値が他の2つの数値の和と等しく、すべての数値が整数である場合にTrueを返す。\n それ以外の場合はFalseを返す。\n \n 例\n any_int(5, 2, 7) ➞ True\n \n any_int(3, 2, 2) ➞ False\n\n any_int(3, -2, 1) ➞ True\n \n any_int(3.6, -2.2, 2) ➞ False", "code": "def any_int(x, y, z):\n \n if isinstance(x,int) and isinstance(y,int) and isinstance(z,int):\n if (x+y==z) or (x+z==y) or (y+z==x):\n return True\n return False\n return False\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(2, 3, 1)==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(2.5, 2, 3)==False, \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate(1.5, 5, 3.5)==False, \"This prints if this assert fails 3 (good for debugging!)\"\n assert candidate(2, 6, 2)==False, \"This prints if this assert fails 4 (good for debugging!)\"\n assert candidate(4, 2, 2)==True, \"This prints if this assert fails 5 (good for debugging!)\"\n assert candidate(2.2, 2.2, 2.2)==False, \"This prints if this assert fails 6 (good for debugging!)\"\n assert candidate(-4, 6, 2)==True, \"This prints if this assert fails 7 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(2,1,1)==True, \"This prints if this assert fails 8 (also good for debugging!)\"\n assert candidate(3,4,7)==True, \"This prints if this assert fails 9 (also good for debugging!)\"\n assert candidate(3.0,4,7)==False, \"This prints if this assert fails 10 (also good for debugging!)\"\n\n\ncandidate = any_int\ncheck(candidate)", "entry_point": "any_int"} +{"task_id": "bt_JHumanEval/93", "prompt": "メッセージを受け取り、すべての文字の大文字と小文字を入れ替え、\n メッセージ中のすべての母音を英語の母音の2つ前に現れる文字に置\n き換えるようにエンコードする関数を書きなさい。 \n 文字だけを想定する。\n\n 例\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'", "code": "def encode(message):\n vowels = \"aeiouAEIOU\"\n vowels_replace = dict([(i, chr(ord(i) + 2)) for i in vowels])\n message = message.swapcase()\n return ''.join([vowels_replace[i] if i in vowels else i for i in message])\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('TEST') == 'tgst', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('Mudasir') == 'mWDCSKR', \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate('YES') == 'ygs', \"This prints if this assert fails 3 (good for debugging!)\"\n \n # Check some edge cases that are easy to work out by hand.\n assert candidate('This is a message') == 'tHKS KS C MGSSCGG', \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(\"I DoNt KnOw WhAt tO WrItE\") == 'k dQnT kNqW wHcT Tq wRkTg', \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = encode\ncheck(candidate)", "entry_point": "encode"} +{"task_id": "bt_JHumanEval/94", "prompt": "整数のリストが与えらる。\n 最大の素数を求め、その桁数の和を返す必要がある。\n 例:\n lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] のとき、返り値は10\n lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1]のとき、返り値は 25\n lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3]のとき、返り値は13\n lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6]のとき、返り値は11\n lst = [0,81,12,3,1,21]のとき、返り値は3\n lst = [0,8,1,2,1,7]のとき、返り値は7", "code": "def skjkasdkd(lst):\n def isPrime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n\n return True\n maxx = 0\n i = 0\n while i < len(lst):\n if(lst[i] > maxx and isPrime(lst[i])):\n maxx = lst[i]\n i+=1\n result = sum(int(digit) for digit in str(maxx))\n return result\n\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3]) == 10, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1]) == 25, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3]) == 13, \"This prints if this assert fails 3 (also good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([0,724,32,71,99,32,6,0,5,91,83,0,5,6]) == 11, \"This prints if this assert fails 4 (also good for debugging!)\"\n \n # Check some edge cases that are easy to work out by hand.\n assert candidate([0,81,12,3,1,21]) == 3, \"This prints if this assert fails 5 (also good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([0,8,1,2,1,7]) == 7, \"This prints if this assert fails 6 (also good for debugging!)\"\n\n assert candidate([8191]) == 19, \"This prints if this assert fails 7 (also good for debugging!)\"\n assert candidate([8191, 123456, 127, 7]) == 19, \"This prints if this assert fails 8 (also good for debugging!)\"\n assert candidate([127, 97, 8192]) == 10, \"This prints if this assert fails 9 (also good for debugging!)\"\n\ncandidate = skjkasdkd\ncheck(candidate)", "entry_point": "skjkasdkd"} +{"task_id": "bt_JHumanEval/95", "prompt": "辞書が与えられたとき、すべてのキーが小文字であればTrueを、\n すべてのキーが大文字の文字列であればFalseを返す。\n 与えられた辞書が空の場合、この関数は False を返す。\n 例:\n check_dict_case({\"a\":\"apple\", \"b\":\"banana\"}) は、 Trueを返す。\n check_dict_case({\"a\":\"apple\", \"A\":\"banana\", \"B\":\"banana\"}) は、 Falseを返す。\n check_dict_case({\"a\":\"apple\", 8:\"banana\", \"a\":\"apple\"}) は、 Falseを返す。\n check_dict_case({\"Name\":\"John\", \"Age\":\"36\", \"City\":\"Houston\"}) は、 Falseを返す。\n check_dict_case({\"STATE\":\"NC\", \"ZIP\":\"12345\" }) は、 Trueを返す。", "code": "def check_dict_case(dict):\n if len(dict.keys()) == 0:\n return False\n else:\n state = \"start\"\n for key in dict.keys():\n\n if isinstance(key, str) == False:\n state = \"mixed\"\n break\n if state == \"start\":\n if key.isupper():\n state = \"upper\"\n elif key.islower():\n state = \"lower\"\n else:\n break\n elif (state == \"upper\" and not key.isupper()) or (state == \"lower\" and not key.islower()):\n state = \"mixed\"\n break\n else:\n break\n return state == \"upper\" or state == \"lower\" \n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate({\"p\":\"pineapple\", \"b\":\"banana\"}) == True, \"First test error: \" + str(candidate({\"p\":\"pineapple\", \"b\":\"banana\"}))\n assert candidate({\"p\":\"pineapple\", \"A\":\"banana\", \"B\":\"banana\"}) == False, \"Second test error: \" + str(candidate({\"p\":\"pineapple\", \"A\":\"banana\", \"B\":\"banana\"}))\n assert candidate({\"p\":\"pineapple\", 5:\"banana\", \"a\":\"apple\"}) == False, \"Third test error: \" + str(candidate({\"p\":\"pineapple\", 5:\"banana\", \"a\":\"apple\"}))\n assert candidate({\"Name\":\"John\", \"Age\":\"36\", \"City\":\"Houston\"}) == False, \"Fourth test error: \" + str(candidate({\"Name\":\"John\", \"Age\":\"36\", \"City\":\"Houston\"}))\n assert candidate({\"STATE\":\"NC\", \"ZIP\":\"12345\" }) == True, \"Fifth test error: \" + str(candidate({\"STATE\":\"NC\", \"ZIP\":\"12345\" })) \n assert candidate({\"fruit\":\"Orange\", \"taste\":\"Sweet\" }) == True, \"Fourth test error: \" + str(candidate({\"fruit\":\"Orange\", \"taste\":\"Sweet\" })) \n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate({}) == False, \"1st edge test error: \" + str(candidate({}))\n\n\ncandidate = check_dict_case\ncheck(candidate)", "entry_point": "check_dict_case"} +{"task_id": "bt_JHumanEval/96", "prompt": "非負整数を受け取り、素数でnより小さい最初のn個の\n 整数の配列を返す関数を実装せよ。\n 例えば:\n count_up_to(5) => [2,3]\n count_up_to(11) => [2,3,5,7]\n count_up_to(0) => []\n count_up_to(20) => [2,3,5,7,11,13,17,19]\n count_up_to(1) => []\n count_up_to(18) => [2,3,5,7,11,13,17]", "code": "def count_up_to(n):\n primes = []\n for i in range(2, n):\n is_prime = True\n for j in range(2, i):\n if i % j == 0:\n is_prime = False\n break\n if is_prime:\n primes.append(i)\n return primes\n\n", "testcode": "def check(candidate):\n\n assert candidate(5) == [2,3]\n assert candidate(6) == [2,3,5]\n assert candidate(7) == [2,3,5]\n assert candidate(10) == [2,3,5,7]\n assert candidate(0) == []\n assert candidate(22) == [2,3,5,7,11,13,17,19]\n assert candidate(1) == []\n assert candidate(18) == [2,3,5,7,11,13,17]\n assert candidate(47) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]\n assert candidate(101) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]\n\n\ncandidate = count_up_to\ncheck(candidate)", "entry_point": "count_up_to"} +{"task_id": "bt_JHumanEval/97", "prompt": "2つの整数を受け取り、その1の位の数の積を返す関数を完成させよ。\n 入力は常に有効範囲にあるとする。\n 例:\n multiply(148, 412) は16を返す。\n multiply(19, 28) は72を返す。\n multiply(2020, 1851) は0を返す。\n multiply(14,-15) は20を返す。", "code": "def multiply(a, b):\n return abs(a % 10) * abs(b % 10)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(148, 412) == 16, \"First test error: \" + str(candidate(148, 412)) \n assert candidate(19, 28) == 72, \"Second test error: \" + str(candidate(19, 28)) \n assert candidate(2020, 1851) == 0, \"Third test error: \" + str(candidate(2020, 1851))\n assert candidate(14,-15) == 20, \"Fourth test error: \" + str(candidate(14,-15)) \n assert candidate(76, 67) == 42, \"Fifth test error: \" + str(candidate(76, 67)) \n assert candidate(17, 27) == 49, \"Sixth test error: \" + str(candidate(17, 27)) \n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(0, 1) == 0, \"1st edge test error: \" + str(candidate(0, 1))\n assert candidate(0, 0) == 0, \"2nd edge test error: \" + str(candidate(0, 0))\n\n\ncandidate = multiply\ncheck(candidate)", "entry_point": "multiply"} +{"task_id": "bt_JHumanEval/98", "prompt": "文字列 s が与えられたとき、偶数のインデックスに含まれる大文字の母音の数を数える。\n 例えば:\n count_upper('aBCdEf') returns 1\n count_upper('abcdefg') returns 0\n count_upper('dBBE') returns 0", "code": "def count_upper(s):\n count = 0\n for i in range(0,len(s),2):\n if s[i] in \"AEIOU\":\n count += 1\n return count\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('aBCdEf') == 1\n assert candidate('abcdefg') == 0\n assert candidate('dBBE') == 0\n assert candidate('B') == 0\n assert candidate('U') == 1\n assert candidate('') == 0\n assert candidate('EEEE') == 2\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = count_upper\ncheck(candidate)", "entry_point": "count_upper"} +{"task_id": "bt_JHumanEval/99", "prompt": "数値を表す文字列valueを受け取り、それに最も近い整数を返す関数を作る。\n その数値が2つの整数から等距離にある場合は、ゼロから四捨五入する。\n \n 例\n >>> closest_integer(\"10\")\n 10\n >>> closest_integer(\"15.3\")\n 15\n \n Note:\n ゼロからの四捨五入とは、与えられた数値が2つの整数から\n 等距離にある場合、ゼロから遠い方を返すという意味である。\n 例えば、 close_integer(\"14.5\")は15を返し、closest_integer(\"-14.5\")は-15を返す。", "code": "def closest_integer(value):\n from math import floor, ceil\n\n if value.count('.') == 1:\n # remove trailing zeros\n while (value[-1] == '0'):\n value = value[:-1]\n\n num = float(value)\n if value[-2:] == '.5':\n if num > 0:\n res = ceil(num)\n else:\n res = floor(num)\n elif len(value) > 0:\n res = int(round(num))\n else:\n res = 0\n\n return res\n\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"10\") == 10, \"Test 1\"\n assert candidate(\"14.5\") == 15, \"Test 2\"\n assert candidate(\"-15.5\") == -16, \"Test 3\"\n assert candidate(\"15.3\") == 15, \"Test 3\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"0\") == 0, \"Test 0\"\n\n\ncandidate = closest_integer\ncheck(candidate)", "entry_point": "closest_integer"} +{"task_id": "bt_JHumanEval/100", "prompt": "正の整数nが与えられたとき、n段の石の山を作らなければならない。\n 最初の段にはn個の石がある。\n 次の段の石の数は\n - nが奇数なら次の奇数。\n - nが偶数なら次の偶数。\n 各段の石の数をリストで返す。インデックス i の要素は、段 (i+1) の石の\n 数を表すものとする。\n 例:\n >>> make_a_pile(3)\n [3, 5, 7]", "code": "def make_a_pile(n):\n return [n + 2*i for i in range(n)]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(3) == [3, 5, 7], \"Test 3\"\n assert candidate(4) == [4,6,8,10], \"Test 4\"\n assert candidate(5) == [5, 7, 9, 11, 13]\n assert candidate(6) == [6, 8, 10, 12, 14, 16]\n assert candidate(8) == [8, 10, 12, 14, 16, 18, 20, 22]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = make_a_pile\ncheck(candidate)", "entry_point": "make_a_pile"} +{"task_id": "bt_JHumanEval/101", "prompt": "カンマまたは空白で区切られた単語の文字列が与えられる。あなたのタスクは、\n 文字列を単語に分割し、単語の配列を返すことである。\n \n 例えば:\n words_string(\"Hi, my name is John\") == [\"Hi\", \"my\", \"name\", \"is\", \"John\"]\n words_string(\"One, two, three, four, five, six\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]", "code": "def words_string(s):\n if not s:\n return []\n\n s_list = []\n\n for letter in s:\n if letter == ',':\n s_list.append(' ')\n else:\n s_list.append(letter)\n\n s_list = \"\".join(s_list)\n return s_list.split()\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(\"Hi, my name is John\") == [\"Hi\", \"my\", \"name\", \"is\", \"John\"]\n assert candidate(\"One, two, three, four, five, six\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]\n assert candidate(\"Hi, my name\") == [\"Hi\", \"my\", \"name\"]\n assert candidate(\"One,, two, three, four, five, six,\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(\"\") == []\n assert candidate(\"ahmed , gamal\") == [\"ahmed\", \"gamal\"]\n\n\ncandidate = words_string\ncheck(candidate)", "entry_point": "words_string"} +{"task_id": "bt_JHumanEval/102", "prompt": "この関数は2つの正の数xとyを受け取り、範囲[x, y](両端を含む)に含まれる\n 最大の偶数整数を返す。そのような数がない場合、関数は-1を返す。\n \n 例えば:\n choose_num(12, 15) = 14\n choose_num(13, 12) = -1", "code": "def choose_num(x, y):\n if x > y:\n return -1\n if y % 2 == 0:\n return y\n if x == y:\n return -1\n return y - 1\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(12, 15) == 14\n assert candidate(13, 12) == -1\n assert candidate(33, 12354) == 12354\n assert candidate(5234, 5233) == -1\n assert candidate(6, 29) == 28\n assert candidate(27, 10) == -1\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(7, 7) == -1\n assert candidate(546, 546) == 546\n\n\ncandidate = choose_num\ncheck(candidate)", "entry_point": "choose_num"} +{"task_id": "bt_JHumanEval/103", "prompt": "2つの正の整数nとmが与えられており、あなたのタスクはnからmまでの\n 整数(nとmを含む)の平均を計算することである。\n 答えを最も近い整数に丸め、2進数に変換せよ。\n nがmより大きい場合は-1を返す。\n 例:\n rounded_avg(1, 5) => \"0b11\"\n rounded_avg(7, 5) => -1\n rounded_avg(10, 20) => \"0b1111\"\n rounded_avg(20, 33) => \"0b11010\"", "code": "def rounded_avg(n, m):\n if m < n:\n return -1\n summation = 0\n for i in range(n, m+1):\n summation += i\n return bin(round(summation/(m - n + 1)))\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(1, 5) == \"0b11\"\n assert candidate(7, 13) == \"0b1010\"\n assert candidate(964,977) == \"0b1111001010\"\n assert candidate(996,997) == \"0b1111100100\"\n assert candidate(560,851) == \"0b1011000010\"\n assert candidate(185,546) == \"0b101101110\"\n assert candidate(362,496) == \"0b110101101\"\n assert candidate(350,902) == \"0b1001110010\"\n assert candidate(197,233) == \"0b11010111\"\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(7, 5) == -1\n assert candidate(5, 1) == -1\n assert candidate(5, 5) == \"0b101\"\n\n\ncandidate = rounded_avg\ncheck(candidate)", "entry_point": "rounded_avg"} +{"task_id": "bt_JHumanEval/104", "prompt": "正の整数xのリストが与えられたとき、偶数桁の要素を持たない全ての\n 要素をソートしたリストを返す。\n \n 注意: 返されるリストは昇順にソートされていなければならない。\n \n 例えば:\n >>> unique_digits([15, 33, 1422, 1])\n [1, 15, 33]\n >>> unique_digits([152, 323, 1422, 10])\n []", "code": "def unique_digits(x):\n odd_digit_elements = []\n for i in x:\n if all (int(c) % 2 == 1 for c in str(i)):\n odd_digit_elements.append(i)\n return sorted(odd_digit_elements)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([15, 33, 1422, 1]) == [1, 15, 33]\n assert candidate([152, 323, 1422, 10]) == []\n assert candidate([12345, 2033, 111, 151]) == [111, 151]\n assert candidate([135, 103, 31]) == [31, 135]\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = unique_digits\ncheck(candidate)", "entry_point": "unique_digits"} +{"task_id": "bt_JHumanEval/105", "prompt": "整数の配列が与えられたとき、1から9までの整数をソートし、\n 得られた配列を逆順にし、各桁を以下の数字に相当する名前に置き換える。\n \"One\"、\"Two\"、\"Three\"、\"Four\"、\"Five\"、\"Six\"、\"Seven\"、\"Eight\"、\"Nine \"\n 例えば:\n arr = [2, 1, 1, 4, 5, 8, 2, 3] \n -> arrをソート -> [1, 1, 2, 2, 3, 4, 5, 8] \n -> arrを逆順 -> [8, 5, 4, 3, 2, 2, 1, 1]\n [\"Eight\", \"Five\", \"Four\", \"Three\", \"Two\", \"Two\", \"One\", \"One\"]を返す。\n \n もし空配列なら、空配列を返す:\n arr = []\n return []\n \n もし変な数値が配列に含まれていたら無視せよ:\n arr = [1, -1 , 55] \n -> arrをソート-> [-1, 1, 55]\n -> rarrを逆順 -> [55, 1, -1]\n ['One']を返す。", "code": "def by_length(arr):\n dic = {\n 1: \"One\",\n 2: \"Two\",\n 3: \"Three\",\n 4: \"Four\",\n 5: \"Five\",\n 6: \"Six\",\n 7: \"Seven\",\n 8: \"Eight\",\n 9: \"Nine\",\n }\n sorted_arr = sorted(arr, reverse=True)\n new_arr = []\n for var in sorted_arr:\n try:\n new_arr.append(dic[var])\n except:\n pass\n return new_arr\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([2, 1, 1, 4, 5, 8, 2, 3]) == [\"Eight\", \"Five\", \"Four\", \"Three\", \"Two\", \"Two\", \"One\", \"One\"], \"Error\"\n assert candidate([]) == [], \"Error\"\n assert candidate([1, -1 , 55]) == ['One'], \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([1, -1, 3, 2]) == [\"Three\", \"Two\", \"One\"]\n assert candidate([9, 4, 8]) == [\"Nine\", \"Eight\", \"Four\"]\n\n\ncandidate = by_length\ncheck(candidate)", "entry_point": "by_length"} +{"task_id": "bt_JHumanEval/106", "prompt": "iは1から始まる。iの階乗は1からiまでの数の掛け算(1 * 2 * ... * i)である。\n Example:\n f(5) == [1, 2, 6, 24, 15]", "code": "def f(n):\n ret = []\n for i in range(1,n+1):\n if i%2 == 0:\n x = 1\n for j in range(1,i+1): x *= j\n ret += [x]\n else:\n x = 0\n for j in range(1,i+1): x += j\n ret += [x]\n return ret\n", "testcode": "def check(candidate):\n\n assert candidate(5) == [1, 2, 6, 24, 15]\n assert candidate(7) == [1, 2, 6, 24, 15, 720, 28]\n assert candidate(1) == [1]\n assert candidate(3) == [1, 2, 6]\n\ncandidate = f\ncheck(candidate)", "entry_point": "f"} +{"task_id": "bt_JHumanEval/107", "prompt": "与えられた正の整数 nに対して、範囲 1 から n まで(両端を含む)に存在する\n 偶数の回文数(integer palindrome)と奇数の回文数の個数をタプル形式で返す。\n \n 例 1:\n\n 入力: 3\n 出力: (1, 2)\n 解説:\n 回文数は1、2、3であり、そのうち1つは偶数、2つは奇数である。\n\n 例 2:\n\n 入力: 12\n 出力: (4, 6)\n 解説:\n 回文数は、1、2、3、4、5、6、7、8、9、11であり、そのうち4つは偶数、6つは奇数である。\n\n ノート:\n 1. 1 <= n <= 10^3\n 2. 返されるタプルは、それぞれ偶数と奇数の回文数を持つ。", "code": "def even_odd_palindrome(n):\n def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\n even_palindrome_count = 0\n odd_palindrome_count = 0\n\n for i in range(1, n+1):\n if i%2 == 1 and is_palindrome(i):\n odd_palindrome_count += 1\n elif i%2 == 0 and is_palindrome(i):\n even_palindrome_count += 1\n return (even_palindrome_count, odd_palindrome_count)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(123) == (8, 13)\n assert candidate(12) == (4, 6)\n assert candidate(3) == (1, 2)\n assert candidate(63) == (6, 8)\n assert candidate(25) == (5, 6)\n assert candidate(19) == (4, 6)\n assert candidate(9) == (4, 5), \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1) == (0, 1), \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = even_odd_palindrome\ncheck(candidate)", "entry_point": "even_odd_palindrome"} +{"task_id": "bt_JHumanEval/108", "prompt": "count_nums 関数は、整数の配列を引数として受け取り、その配列内の各整数の各桁の合計が \n >0 となるような整数の個数を返す。負の数に関しては、最初の桁(符号付き桁)は負となる。\n たとえば、−123 の符号付き桁は −1, 2, 3 である。\n >>> count_nums([]) == 0\n >> count_nums([-1, 11, -11]) == 1\n >> count_nums([1, 1, 2]) == 3", "code": "def count_nums(arr):\n def digits_sum(n):\n neg = 1\n if n < 0: n, neg = -1 * n, -1 \n n = [int(i) for i in str(n)]\n n[0] = n[0] * neg\n return sum(n)\n return len(list(filter(lambda x: x > 0, [digits_sum(i) for i in arr])))\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([]) == 0\n assert candidate([-1, -2, 0]) == 0\n assert candidate([1, 1, 2, -2, 3, 4, 5]) == 6\n assert candidate([1, 6, 9, -6, 0, 1, 5]) == 5\n assert candidate([1, 100, 98, -7, 1, -1]) == 4\n assert candidate([12, 23, 34, -45, -56, 0]) == 5\n assert candidate([-0, 1**0]) == 1\n assert candidate([1]) == 1\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = count_nums\ncheck(candidate)", "entry_point": "count_nums"} +{"task_id": "bt_JHumanEval/109", "prompt": "N個の整数arr[1], arr[2], ..., arr[N]なる配列 'arr' があります。\n この配列の数字はランダムな順番に並んでいます。あなたの課題は、以下の操作を何度でも行うことで、\n 配列を非減少.の順番にソートできるかどうかを判断することです。\n 操作として許されているのは「右シフト」です。\n \n 一回の「右シフト」操作とは、配列のすべての要素を右方向に一つずつずらすことを意味します。\n 配列の最後の要素は配列の先頭、すなわち0番目のインデックスに移動します。\n \n 上記の操作を行ってソートされた配列を得られる場合は True を、そうでない場合は False を返してください。\n 与えられた配列が空の場合は True を返してください。\n \n 注意:与えられたリストには一意の要素しか含まれていないことが保証されています。\n \n 例:\n \n move_one_ball([3, 4, 5, 1, 2]) => True\n 説明:2回の右シフト操作を行うことで、与えられた配列を非減少の順序にすることができます。\n \n move_one_ball([3, 5, 4, 1, 2]) => False\n 説明:どれだけ右シフト操作を行っても、与えられた配列を非減少の順序にすることはできません。", "code": "def move_one_ball(arr):\n if len(arr)==0:\n return True\n sorted_array=sorted(arr)\n my_arr=[]\n \n min_value=min(arr)\n min_index=arr.index(min_value)\n my_arr=arr[min_index:]+arr[0:min_index]\n for i in range(len(arr)):\n if my_arr[i]!=sorted_array[i]:\n return False\n return True\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([3, 4, 5, 1, 2])==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([3, 5, 10, 1, 2])==True\n assert candidate([4, 3, 1, 2])==False\n # Check some edge cases that are easy to work out by hand.\n assert candidate([3, 5, 4, 1, 2])==False, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([])==True\n\ncandidate = move_one_ball\ncheck(candidate)", "entry_point": "move_one_ball"} +{"task_id": "bt_JHumanEval/110", "prompt": "この問題では、2つの数のリストを受け取り、lst1を偶数のみのリストに\n するために、それらの間で要素の交換を行うことが可能かどうかを判断す\n る関数を実装する。\n lst1とlst2の間で交換される要素の数に制限はない。\n lst1とlst2の間で要素の交換を行い、lst1の要素をすべて偶数にすることが\n 可能であれば、\"YES \"を返す。\n そうでなければ \"NO \"を返す。\n 例えば:\n exchange([1, 2, 3, 4], [1, 2, 3, 4]) => \"YES\"\n exchange([1, 2, 3, 4], [1, 5, 3, 4]) => \"NO\"\n 受け取るリストは空でないと前提してよい。", "code": "def exchange(lst1, lst2):\n odd = 0\n even = 0\n for i in lst1:\n if i%2 == 1:\n odd += 1\n for i in lst2:\n if i%2 == 0:\n even += 1\n if even >= odd:\n return \"YES\"\n return \"NO\"\n \n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1, 2, 3, 4], [1, 2, 3, 4]) == \"YES\"\n assert candidate([1, 2, 3, 4], [1, 5, 3, 4]) == \"NO\"\n assert candidate([1, 2, 3, 4], [2, 1, 4, 3]) == \"YES\" \n assert candidate([5, 7, 3], [2, 6, 4]) == \"YES\"\n assert candidate([5, 7, 3], [2, 6, 3]) == \"NO\" \n assert candidate([3, 2, 6, 1, 8, 9], [3, 5, 5, 1, 1, 1]) == \"NO\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([100, 200], [200, 200]) == \"YES\"\n\n\ncandidate = exchange\ncheck(candidate)", "entry_point": "exchange"} +{"task_id": "bt_JHumanEval/111", "prompt": "空白で区切られた小文字を表す文字列が与えられる。最も出現回数が多い文字と\n 対応するカウントの辞書を返す。\n 複数の文字が同じ出現回数を持つ場合、それらすべてを返す。\n \n 例:\n histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}\n histogram('a b b a') == {'a': 2, 'b': 2}\n histogram('a b c a b') == {'a': 2, 'b': 2}\n histogram('b b b b a') == {'b': 4}\n histogram('') == {}", "code": "def histogram(test):\n dict1={}\n list1=test.split(\" \")\n t=0\n\n for i in list1:\n if(list1.count(i)>t) and i!='':\n t=list1.count(i)\n if t>0:\n for i in list1:\n if(list1.count(i)==t):\n \n dict1[i]=t\n return dict1\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('a b b a') == {'a':2,'b': 2}, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('a b c a b') == {'a': 2, 'b': 2}, \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate('a b c d g') == {'a': 1, 'b': 1, 'c': 1, 'd': 1, 'g': 1}, \"This prints if this assert fails 3 (good for debugging!)\"\n assert candidate('r t g') == {'r': 1,'t': 1,'g': 1}, \"This prints if this assert fails 4 (good for debugging!)\"\n assert candidate('b b b b a') == {'b': 4}, \"This prints if this assert fails 5 (good for debugging!)\"\n assert candidate('r t g') == {'r': 1,'t': 1,'g': 1}, \"This prints if this assert fails 6 (good for debugging!)\"\n \n \n # Check some edge cases that are easy to work out by hand.\n assert candidate('') == {}, \"This prints if this assert fails 7 (also good for debugging!)\"\n assert candidate('a') == {'a': 1}, \"This prints if this assert fails 8 (also good for debugging!)\"\n\n\ncandidate = histogram\ncheck(candidate)", "entry_point": "histogram"} +{"task_id": "bt_JHumanEval/112", "prompt": "課題\n sとcの2つの文字列が与えられる。sに含まれる文字のうち、cに含まれる文字と\n 等しいものをすべて削除し、その結果の文字列が回文かどうかをチェックする。\n 文字列は、後ろから読んでも前から読んでも同じであれば回文と呼ばれる。\n 結果文字列とチェックのためのTrue/Falseを含むタプルを返す必要がある。\n 例\n s = \"abcde\", c = \"ae\"のとき、結果は ('bcd',False)\n s = \"abcdef\", c = \"b\" のとき、結果は ('acdef',False)\n s = \"abcdedcba\", c = \"ab\", のとき、結果は ('cdedc',True)", "code": "def reverse_delete(s,c):\n s = ''.join([char for char in s if char not in c])\n return (s,s[::-1] == s)\n", "testcode": "def check(candidate):\n\n assert candidate(\"abcde\",\"ae\") == ('bcd',False)\n assert candidate(\"abcdef\", \"b\") == ('acdef',False)\n assert candidate(\"abcdedcba\",\"ab\") == ('cdedc',True)\n assert candidate(\"dwik\",\"w\") == ('dik',False)\n assert candidate(\"a\",\"a\") == ('',True)\n assert candidate(\"abcdedcba\",\"\") == ('abcdedcba',True)\n assert candidate(\"abcdedcba\",\"v\") == ('abcdedcba',True)\n assert candidate(\"vabba\",\"v\") == ('abba',True)\n assert candidate(\"mamma\", \"mia\") == (\"\", True)\n\ncandidate = reverse_delete\ncheck(candidate)", "entry_point": "reverse_delete"} +{"task_id": "bt_JHumanEval/113", "prompt": "数字のみで構成された文字列のリストを引数として受け取り、新しいリストを返します。\n 出力される新しいリストの各要素は、\"the number of odd elements in the string i of the \n input.\"となりますが、この文字列内のすべての 'i' は、入力リストのi番目の文字列に含ま\n れる奇数の数に置き換えられます。\n\n >>> odd_count(['1234567'])\n [\"the number of odd elements 4n the str4ng 4 of the 4nput.\"]\n >>> odd_count(['3',\"11111111\"])\n [\"the number of odd elements 1n the str1ng 1 of the 1nput.\",\n \"the number of odd elements 8n the str8ng 8 of the 8nput.\"]", "code": "def odd_count(lst):\n res = []\n for arr in lst:\n n = sum(int(d)%2==1 for d in arr)\n res.append(\"the number of odd elements \" + str(n) + \"n the str\"+ str(n) +\"ng \"+ str(n) +\" of the \"+ str(n) +\"nput.\")\n return res\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(['1234567']) == [\"the number of odd elements 4n the str4ng 4 of the 4nput.\"], \"Test 1\"\n assert 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.\"], \"Test 2\"\n assert candidate(['271', '137', '314']) == [\n 'the number of odd elements 2n the str2ng 2 of the 2nput.',\n 'the number of odd elements 3n the str3ng 3 of the 3nput.',\n 'the number of odd elements 2n the str2ng 2 of the 2nput.'\n ]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = odd_count\ncheck(candidate)", "entry_point": "odd_count"} +{"task_id": "bt_JHumanEval/114", "prompt": "整数の配列 nums が与えられたとき、nums の空でない部分配列の最小和を求めよ。\n 例:\n minSubArraySum([2, 3, 4, 1, 2, 4]) == 1\n minSubArraySum([-1, -2, -3]) == -6", "code": "def minSubArraySum(nums):\n max_sum = 0\n s = 0\n for num in nums:\n s += -num\n if (s < 0):\n s = 0\n max_sum = max(s, max_sum)\n if max_sum == 0:\n max_sum = max(-i for i in nums)\n min_sum = -max_sum\n return min_sum\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([2, 3, 4, 1, 2, 4]) == 1, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([-1, -2, -3]) == -6\n assert candidate([-1, -2, -3, 2, -10]) == -14\n assert candidate([-9999999999999999]) == -9999999999999999\n assert candidate([0, 10, 20, 1000000]) == 0\n assert candidate([-1, -2, -3, 10, -5]) == -6\n assert candidate([100, -1, -2, -3, 10, -5]) == -6\n assert candidate([10, 11, 13, 8, 3, 4]) == 3\n assert candidate([100, -33, 32, -1, 0, -2]) == -33\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([-10]) == -10, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([7]) == 7\n assert candidate([1, -1]) == -1\n\ncandidate = minSubArraySum\ncheck(candidate)", "entry_point": "minSubArraySum"} +{"task_id": "bt_JHumanEval/115", "prompt": "長方形のグリッド状(grid)の井戸が与えられる。各行が1つの井戸を表し、\n 行の1が1単位の水を表す。\n 各井戸には,そこから水を汲み上げるのに使える対応するバケツがあり,\n すべてのバケツ容量(capacity)は同じである.\n あなたの仕事は,バケツを使って井戸を空にすることである.\n バケツを降ろす回数を出力せよ.\n \n 例 1:\n 入力: \n グリッド : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]\n バケツ容量 : 1\n 出力: 6\n\n 例 2:\n 入力: \n グリッド : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]\n バケツ容量 : 2\n 出力: 5\n \n 例 3:\n 入力: \n グリッド : [[0,0,0], [0,0,0]]\n バケツ容量 : 5\n 出力: 0\n\n 制約:\n * すべての井戸が同じ長さ\n * 1 <= grid.length <= 10^2\n * 1 <= grid[:,1].length <= 10^2\n * grid[i][j] -> 0 | 1\n * 1 <= capacity <= 10", "code": "def max_fill(grid, capacity):\n import math\n return sum([math.ceil(sum(arr)/capacity) for arr in grid])\n", "testcode": "def check(candidate):\n\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([[0,0,1,0], [0,1,0,0], [1,1,1,1]], 1) == 6, \"Error\"\n assert candidate([[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]], 2) == 5, \"Error\"\n assert candidate([[0,0,0], [0,0,0]], 5) == 0, \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([[1,1,1,1], [1,1,1,1]], 2) == 4, \"Error\"\n assert candidate([[1,1,1,1], [1,1,1,1]], 9) == 2, \"Error\"\n\n\ncandidate = max_fill\ncheck(candidate)", "entry_point": "max_fill"} +{"task_id": "bt_JHumanEval/116", "prompt": "この問題では、非負整数の配列を2進数表現における\"1\"の個数を昇順でソートする。\n \"1\"の個数が同じ場合は,10進数に基づいてソートする。\n\n 次のように実装する: \n >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]\n >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]\n >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]", "code": "def sort_array(arr):\n return sorted(sorted(arr), key=lambda x: bin(x)[2:].count('1'))\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1,5,2,3,4]) == [1, 2, 4, 3, 5]\n assert candidate([-2,-3,-4,-5,-6]) == [-4, -2, -6, -5, -3]\n assert candidate([1,0,2,3,4]) == [0, 1, 2, 4, 3]\n assert candidate([]) == []\n assert candidate([2,5,77,4,5,3,5,7,2,3,4]) == [2, 2, 4, 4, 3, 3, 5, 5, 5, 7, 77]\n assert candidate([3,6,44,12,32,5]) == [32, 3, 5, 6, 12, 44]\n assert candidate([2,4,8,16,32]) == [2, 4, 8, 16, 32]\n assert candidate([2,4,8,16,32]) == [2, 4, 8, 16, 32]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = sort_array\ncheck(candidate)", "entry_point": "sort_array"} +{"task_id": "bt_JHumanEval/117", "prompt": "ある文字列sと自然数nが与えらる。あなたに課せられたタスクは、文字列s\n の中から、ちょうどn個の子音を含むすべての単語のリストを現れる順に返す\n 関数を実装することである。\n 注意:入力文字列には英文字と空白しか含まれないと仮定してもよい。\n 例:\n select_words(\"Mary had a little lamb\", 4) ==> [\"little\"]\n select_words(\"Mary had a little lamb\", 3) ==> [\"Mary\", \"lamb\"]\n select_words(\"simple white space\", 2) ==> []\n select_words(\"Hello world\", 4) ==> [\"world\"]\n select_words(\"Uncle sam\", 3) ==> [\"Uncle\"]", "code": "def select_words(s, n):\n result = []\n for word in s.split():\n n_consonants = 0\n for i in range(0, len(word)):\n if word[i].lower() not in [\"a\",\"e\",\"i\",\"o\",\"u\"]:\n n_consonants += 1 \n if n_consonants == n:\n result.append(word)\n return result\n\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"Mary had a little lamb\", 4) == [\"little\"], \"First test error: \" + str(candidate(\"Mary had a little lamb\", 4)) \n assert candidate(\"Mary had a little lamb\", 3) == [\"Mary\", \"lamb\"], \"Second test error: \" + str(candidate(\"Mary had a little lamb\", 3)) \n assert candidate(\"simple white space\", 2) == [], \"Third test error: \" + str(candidate(\"simple white space\", 2)) \n assert candidate(\"Hello world\", 4) == [\"world\"], \"Fourth test error: \" + str(candidate(\"Hello world\", 4)) \n assert candidate(\"Uncle sam\", 3) == [\"Uncle\"], \"Fifth test error: \" + str(candidate(\"Uncle sam\", 3))\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"\", 4) == [], \"1st edge test error: \" + str(candidate(\"\", 4))\n assert candidate(\"a b c d e f\", 1) == [\"b\", \"c\", \"d\", \"f\"], \"2nd edge test error: \" + str(candidate(\"a b c d e f\", 1))\n\n\ncandidate = select_words\ncheck(candidate)", "entry_point": "select_words"} +{"task_id": "bt_JHumanEval/118", "prompt": "単語が与えられる。あなたの仕事は、単語の右側から2つの子音(大文字と\n 小文字を区別)の間に立っている最も近い母音を見つけることである。\n \n 最初と最後の母音はカウントされない。上記の条件を満たす母音が見つから\n なかった場合は、空の文字列を返せ。\n \n 指定された文字列は英字のみを含むとみなしてよい。\n \n 例:\n get_closest_vowel(\"yogurt\") ==> \"u\"\n get_closest_vowel(\"FULL\") ==> \"U\"\n get_closest_vowel(\"quick\") ==> \"\"\n get_closest_vowel(\"ab\") ==> \"\"", "code": "def get_closest_vowel(word):\n if len(word) < 3:\n return \"\"\n\n vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", 'O', 'U', 'I'}\n for i in range(len(word)-2, 0, -1):\n if word[i] in vowels:\n if (word[i+1] not in vowels) and (word[i-1] not in vowels):\n return word[i]\n return \"\"\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"yogurt\") == \"u\"\n assert candidate(\"full\") == \"u\"\n assert candidate(\"easy\") == \"\"\n assert candidate(\"eAsy\") == \"\"\n assert candidate(\"ali\") == \"\"\n assert candidate(\"bad\") == \"a\"\n assert candidate(\"most\") == \"o\"\n assert candidate(\"ab\") == \"\"\n assert candidate(\"ba\") == \"\"\n assert candidate(\"quick\") == \"\"\n assert candidate(\"anime\") == \"i\"\n assert candidate(\"Asia\") == \"\"\n assert candidate(\"Above\") == \"o\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = get_closest_vowel\ncheck(candidate)", "entry_point": "get_closest_vowel"} +{"task_id": "bt_JHumanEval/119", "prompt": "2つの文字列からなるリストが与えられます。両方の文字列は開き括弧 '(' または\n 閉じ括弧 ')' のみで構成されています。\n あなたの仕事は、2つの文字列を何らかの順序で結合して、「良い」文字列にすることが\n 可能かどうかを確認することです。\n \n 文字列Sが「良い」とは、文字列内のすべての括弧がバランスしている場合に限ります。\n 例えば、文字列 '(())()' は良いですが、文字列 '())' は良くありません。\n 良い文字列を作る方法がある場合は 'Yes' を返し、そうでない場合は 'No' を返してください。\n \n 例\n match_parens(['()(', ')']) == 'Yes'\n match_parens([')', ')']) == 'No'", "code": "def match_parens(lst):\n def check(s):\n val = 0\n for i in s:\n if i == '(':\n val = val + 1\n else:\n val = val - 1\n if val < 0:\n return False\n return True if val == 0 else False\n\n S1 = lst[0] + lst[1]\n S2 = lst[1] + lst[0]\n return 'Yes' if check(S1) or check(S2) else 'No'\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(['()(', ')']) == 'Yes'\n assert candidate([')', ')']) == 'No'\n assert candidate(['(()(())', '())())']) == 'No'\n assert candidate([')())', '(()()(']) == 'Yes'\n assert candidate(['(())))', '(()())((']) == 'Yes'\n assert candidate(['()', '())']) == 'No'\n assert candidate(['(()(', '()))()']) == 'Yes'\n assert candidate(['((((', '((())']) == 'No'\n assert candidate([')(()', '(()(']) == 'No'\n assert candidate([')(', ')(']) == 'No'\n \n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(['(', ')']) == 'Yes'\n assert candidate([')', '(']) == 'Yes' \n\n\ncandidate = match_parens\ncheck(candidate)", "entry_point": "match_parens"} +{"task_id": "bt_JHumanEval/120", "prompt": "整数の配列 arr と正の整数 k が与えられる。arr に含まれる大きい方から k 個の数を含む\n 長さ k のソート済みリストを返す。\n\n 例 1:\n\n 入力: arr = [-3, -4, 5], k = 3\n 出力: [-4, -3, 5]\n\n 例 2:\n\n 入力: arr = [4, -4, 4], k = 2\n 出力: [4, 4]\n\n 例 3:\n\n 入力: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1\n 出力: [2]\n\n ノート:\n 1. 配列の長さは[1, 1000]の範囲とする。\n 2. 配列の要素は [-1000, 1000] の範囲にある。\n 3. 0 <= k <= len(arr)", "code": "def maximum(arr, k):\n if k == 0:\n return []\n arr.sort()\n ans = arr[-k:]\n return ans\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([-3, -4, 5], 3) == [-4, -3, 5]\n assert candidate([4, -4, 4], 2) == [4, 4]\n assert candidate([-3, 2, 1, 2, -1, -2, 1], 1) == [2]\n assert candidate([123, -123, 20, 0 , 1, 2, -3], 3) == [2, 20, 123]\n assert candidate([-123, 20, 0 , 1, 2, -3], 4) == [0, 1, 2, 20]\n assert candidate([5, 15, 0, 3, -13, -8, 0], 7) == [-13, -8, 0, 0, 3, 5, 15]\n assert candidate([-1, 0, 2, 5, 3, -10], 2) == [3, 5]\n assert candidate([1, 0, 5, -7], 1) == [5]\n assert candidate([4, -4], 2) == [-4, 4]\n assert candidate([-10, 10], 2) == [-10, 10]\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1, 2, 3, -23, 243, -400, 0], 0) == []\n\n\ncandidate = maximum\ncheck(candidate)", "entry_point": "maximum"} +{"task_id": "bt_JHumanEval/121", "prompt": "整数の空でないリストが与えられた時、偶数の位置にある奇数の要素の合計を返す。\n 例\n solution([5, 8, 7, 1]) ==> 12\n solution([3, 3, 3, 3, 3]) ==> 9\n solution([30, 13, 24, 321]) ==>0", "code": "def solution(lst):\n return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([5, 8, 7, 1]) == 12\n assert candidate([3, 3, 3, 3, 3]) == 9\n assert candidate([30, 13, 24, 321]) == 0\n assert candidate([5, 9]) == 5\n assert candidate([2, 4, 8]) == 0\n assert candidate([30, 13, 23, 32]) == 23\n assert candidate([3, 13, 2, 9]) == 3\n\n # Check some edge cases that are easy to work out by hand.\n\n\ncandidate = solution\ncheck(candidate)", "entry_point": "solution"} +{"task_id": "bt_JHumanEval/122", "prompt": "整数の空でない配列 arr と整数 k が与えられたとき、\n arr の最初の k 個の要素から高々 2 桁までの要素の和を返す。\n\n 例:\n\n 入力: arr = [111,21,3,4000,5,6,7,8,9], k = 4\n 出力: 24 # 21 + 3 の話\n\n 制約:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)", "code": "def add_elements(arr, k):\n return sum(elem for elem in arr[:k] if len(str(elem)) <= 2)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1,-2,-3,41,57,76,87,88,99], 3) == -4\n assert candidate([111,121,3,4000,5,6], 2) == 0\n assert candidate([11,21,3,90,5,6,7,8,9], 4) == 125\n assert candidate([111,21,3,4000,5,6,7,8,9], 4) == 24, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1], 1) == 1, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = add_elements\ncheck(candidate)", "entry_point": "add_elements"} +{"task_id": "bt_JHumanEval/123", "prompt": "正の整数nが与えられたとき、コラッツ数列の奇数を持つソートされたリストを返す。\n コラッツ予想とは数学の予想で、次のように定義される数列に関するものである: \n 任意の正の整数nから始め、各項は前の項から次のように求められる。\n 前の項が偶数なら、次の項は前の項の2分の1である。前の項が奇数の場合、次の項は前の項の3倍+1である。\n 予想では、nがどのような値であっても、数列は必ず1に達する。\n\n 注:\n       1. Collatz(1)は[1]である。\n 2. 返されるリストは昇順にソートされている。\n \n 例えば:\n get_odd_collatz(5) は [1, 5]を返す。つまり、5に対するコラッツ数列 は、[5, 16, 8, 4, 2, 1]であり、 奇数は 1 と 5 である。", "code": "def get_odd_collatz(n):\n if n%2==0:\n odd_collatz = [] \n else:\n odd_collatz = [n]\n while n > 1:\n if n % 2 == 0:\n n = n/2\n else:\n n = n*3 + 1\n \n if n%2 == 1:\n odd_collatz.append(int(n))\n\n return sorted(odd_collatz)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(14) == [1, 5, 7, 11, 13, 17]\n assert candidate(5) == [1, 5]\n assert candidate(12) == [1, 3, 5], \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1) == [1], \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = get_odd_collatz\ncheck(candidate)", "entry_point": "get_odd_collatz"} +{"task_id": "bt_JHumanEval/124", "prompt": "与えられた日付文字列を検証し、その日付が有効であればTrueを、そうでなければFalseを返す関数を書く必要がある。\n 日付が有効であるのは、以下のルールがすべて満たされている場合である:\n 1. 日付文字列が空でない。\n 2. 日数が、月1,3,5,7,8,10,12の場合、1日以上31日以下である。また、月4,6,9,11については、日数が1以上30日以下である。また、月2については、日数が1以上29以下であること。\n 3. 月は1未満または12以上であってはならない。\n 4. 日付はmm-dd-yyyyの形式でなければならない。\n\n 例えば: \n valid_date('03-11-2000') => True\n\n valid_date('15-01-2012') => False\n\n valid_date('04-0-2040') => False\n\n valid_date('06-04-2020') => True\n\n valid_date('06/04/2020') => False", "code": "def valid_date(date):\n try:\n date = date.strip()\n month, day, year = date.split('-')\n month, day, year = int(month), int(day), int(year)\n if month < 1 or month > 12:\n return False\n if month in [1,3,5,7,8,10,12] and day < 1 or day > 31:\n return False\n if month in [4,6,9,11] and day < 1 or day > 30:\n return False\n if month == 2 and day < 1 or day > 29:\n return False\n except:\n return False\n\n return True\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('03-11-2000') == True\n\n assert candidate('15-01-2012') == False\n\n assert candidate('04-0-2040') == False\n\n assert candidate('06-04-2020') == True\n\n assert candidate('01-01-2007') == True\n\n assert candidate('03-32-2011') == False\n\n assert candidate('') == False\n\n assert candidate('04-31-3000') == False\n\n assert candidate('06-06-2005') == True\n\n assert candidate('21-31-2000') == False\n\n assert candidate('04-12-2003') == True\n\n assert candidate('04122003') == False\n\n assert candidate('20030412') == False\n\n assert candidate('2003-04') == False\n\n assert candidate('2003-04-12') == False\n\n assert candidate('04-2003') == False\n\ncandidate = valid_date\ncheck(candidate)", "entry_point": "valid_date"} +{"task_id": "bt_JHumanEval/125", "prompt": "単語の文字列が与えられた場合、空白で分割された単語のリストを返す。\n テキスト中に空白が存在しない場合は、カンマ ',' で分割する必要がある。カンマが存在しない場合は、\n アルファベットの奇数順の小文字の数を返す必要がある。ord('a') = 0, ord('b') = 1, ... ord('z') = 25\n 例\n split_words(\"Hello world!\") ➞ [\"Hello\", \"world!\"]\n split_words(\"Hello,world!\") ➞ [\"Hello\", \"world!\"]\n split_words(\"abcdef\") == 3", "code": "def split_words(txt):\n if \" \" in txt:\n return txt.split()\n elif \",\" in txt:\n return txt.replace(',',' ').split()\n else:\n return len([i for i in txt if i.islower() and ord(i)%2 == 0])\n", "testcode": "def check(candidate):\n\n assert candidate(\"Hello world!\") == [\"Hello\",\"world!\"]\n assert candidate(\"Hello,world!\") == [\"Hello\",\"world!\"]\n assert candidate(\"Hello world,!\") == [\"Hello\",\"world,!\"]\n assert candidate(\"Hello,Hello,world !\") == [\"Hello,Hello,world\",\"!\"]\n assert candidate(\"abcdef\") == 3\n assert candidate(\"aaabb\") == 2\n assert candidate(\"aaaBb\") == 1\n assert candidate(\"\") == 0\n\ncandidate = split_words\ncheck(candidate)", "entry_point": "split_words"} +{"task_id": "bt_JHumanEval/126", "prompt": "数字のリストが与えられたとき、昇順に整列されているかどうかを返す。\n リストに同じ数の重複が1つ以上ある場合は、Falseを返す。\n 負の数はなく、整数のみであると仮定する。\n \n 例\n is_sorted([5]) ➞ True\n is_sorted([1, 2, 3, 4, 5]) ➞ True\n is_sorted([1, 3, 2, 4, 5]) ➞ False\n is_sorted([1, 2, 3, 4, 5, 6]) ➞ True\n is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True\n is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False\n is_sorted([1, 2, 2, 3, 3, 4]) ➞ True\n is_sorted([1, 2, 2, 2, 3, 4]) ➞ False", "code": "def is_sorted(lst):\n count_digit = dict([(i, 0) for i in lst])\n for i in lst:\n count_digit[i]+=1 \n if any(count_digit[i] > 2 for i in lst):\n return False\n if all(lst[i-1] <= lst[i] for i in range(1, len(lst))):\n return True\n else:\n return False\n \n \n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([5]) == True\n assert candidate([1, 2, 3, 4, 5]) == True\n assert candidate([1, 3, 2, 4, 5]) == False\n assert candidate([1, 2, 3, 4, 5, 6]) == True\n assert candidate([1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate([1, 3, 2, 4, 5, 6, 7]) == False, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([]) == True, \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate([1]) == True, \"This prints if this assert fails 3 (good for debugging!)\"\n assert candidate([3, 2, 1]) == False, \"This prints if this assert fails 4 (good for debugging!)\"\n \n # Check some edge cases that are easy to work out by hand.\n assert candidate([1, 2, 2, 2, 3, 4]) == False, \"This prints if this assert fails 5 (good for debugging!)\"\n assert candidate([1, 2, 3, 3, 3, 4]) == False, \"This prints if this assert fails 6 (good for debugging!)\"\n assert candidate([1, 2, 2, 3, 3, 4]) == True, \"This prints if this assert fails 7 (good for debugging!)\"\n assert candidate([1, 2, 3, 4]) == True, \"This prints if this assert fails 8 (good for debugging!)\"\n\n\ncandidate = is_sorted\ncheck(candidate)", "entry_point": "is_sorted"} +{"task_id": "bt_JHumanEval/127", "prompt": "2つの区間が与えられます。\n それぞれの区間は整数のペアで示されます。例えば、区間 = (start, end ) = (1, 2) です。\n 与えられた区間は閉区間であり、start と end の両端が含まれます。\n 各区間について、start は end 以下であると仮定します。\n \n あなたの仕事は、これら2つの区間の交差部分の長さが素数であるかどうかを判断することです。\n \n 例えば、区間 (1, 3) と (2, 4) の交差部分は (2, 3) で、その長さは1ですが、これは素数ではありません。\n \n 交差部分の長さが素数であれば \"YES\" を返し、そうでなければ \"NO\" を返してください。\n もし2つの区間が交差しない場合も \"NO\" を返してください。\n\n [input/output] サンプル:\n intersection((1, 2), (2, 3)) ==> \"NO\"\n intersection((-1, 1), (0, 4)) ==> \"NO\"\n intersection((-3, -1), (-5, 5)) ==> \"YES\"", "code": "def intersection(interval1, interval2):\n def is_prime(num):\n if num == 1 or num == 0:\n return False\n if num == 2:\n return True\n for i in range(2, num):\n if num%i == 0:\n return False\n return True\n\n l = max(interval1[0], interval2[0])\n r = min(interval1[1], interval2[1])\n length = r - l\n if length > 0 and is_prime(length):\n return \"YES\"\n return \"NO\"\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate((1, 2), (2, 3)) == \"NO\"\n assert candidate((-1, 1), (0, 4)) == \"NO\"\n assert candidate((-3, -1), (-5, 5)) == \"YES\"\n assert candidate((-2, 2), (-4, 0)) == \"YES\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate((-11, 2), (-1, -1)) == \"NO\"\n assert candidate((1, 2), (3, 5)) == \"NO\"\n assert candidate((1, 2), (1, 2)) == \"NO\"\n assert candidate((-2, -2), (-3, -2)) == \"NO\"\n\n\ncandidate = intersection\ncheck(candidate)", "entry_point": "intersection"} +{"task_id": "bt_JHumanEval/128", "prompt": "整数の配列 arr が与えられます。この配列に含まれる各数値の絶対値の合計と、\n 各数値の符号(プラスは1、マイナスは-1、ゼロは0)の積を掛け合わせた値を\n 返してください。\n 注意:配列`arr`が空の場合は`None`を返してください。\n \n 例:\n >>> prod_signs([1, 2, 2, -4]) == -9\n >>> prod_signs([0, 1]) == 0\n >>> prod_signs([]) == None", "code": "def prod_signs(arr):\n if not arr: return None\n prod = 0 if 0 in arr else (-1) ** len(list(filter(lambda x: x < 0, arr)))\n return prod * sum([abs(i) for i in arr])\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1, 2, 2, -4]) == -9\n assert candidate([0, 1]) == 0\n assert candidate([1, 1, 1, 2, 3, -1, 1]) == -10\n assert candidate([]) == None\n assert candidate([2, 4,1, 2, -1, -1, 9]) == 20\n assert candidate([-1, 1, -1, 1]) == 4\n assert candidate([-1, 1, 1, 1]) == -4\n assert candidate([-1, 1, 1, 0]) == 0\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = prod_signs\ncheck(candidate)", "entry_point": "prod_signs"} +{"task_id": "bt_JHumanEval/129", "prompt": "N行とN列 (N >= 2)) のグリッドと正の整数kが与えられた場合、各セルには値が含まれている。\n 範囲[1, N * N](両端を含む)のすべての整数は、グリッドのセルに一度だけ表れる。\n\n このグリッド内で長さkの最短の経路を見つける必要がある。任意のセルからスタートでき、\n 各ステップで隣接するセルに移動できる。言い換えれば、現在のセルと辺を共有するセルに\n 移動できる。長さkの経路とは、正確にk個のセル(必ずしも異なるとは限らない)を訪れる\n ことを意味する。ただし、グリッドから出ることはない。\n\n 長さkの2つの経路AとBがある場合、AとBが通るセルの値を順番にリスト化したものを\n それぞれlst_A、lst_Bと呼ぶ。lst_Aがlst_Bより辞書順で小さい場合、経路Aは経路Bよりも\n 小さいとする。つまり、整数インデックスi( 1 <= i <= k ) が存在して、lst_A[i] < lst_B[i] となり、\n 任意の j( 1 <= j < i )に対して lst_A[j] = lst_B[j] が成立する。\n\n 答えは一意であることが保証されている。\n 最短の経路が通るセルの値の順番に並べたリストを返すようにせよ。\n \n 例:\n \n 入力:grid =[ [1,2,3], [4,5,6], [7,8,9]]. k = 3\n 出力:[1, 2, 1]\n \n 入力:grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1\n 出力:[1]", "code": "def minPath(grid, k):\n n = len(grid)\n val = n * n + 1\n for i in range(n):\n for j in range(n):\n if grid[i][j] == 1:\n temp = []\n if i != 0:\n temp.append(grid[i - 1][j])\n\n if j != 0:\n temp.append(grid[i][j - 1])\n\n if i != n - 1:\n temp.append(grid[i + 1][j])\n\n if j != n - 1:\n temp.append(grid[i][j + 1])\n\n val = min(temp)\n\n ans = []\n for i in range(k):\n if i % 2 == 0:\n ans.append(1)\n else:\n ans.append(val)\n return ans\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n print\n assert candidate([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3) == [1, 2, 1]\n assert candidate([[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1) == [1]\n assert candidate([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], 4) == [1, 2, 1, 2]\n assert candidate([[6, 4, 13, 10], [5, 7, 12, 1], [3, 16, 11, 15], [8, 14, 9, 2]], 7) == [1, 10, 1, 10, 1, 10, 1]\n assert candidate([[8, 14, 9, 2], [6, 4, 13, 15], [5, 7, 1, 12], [3, 10, 11, 16]], 5) == [1, 7, 1, 7, 1]\n assert candidate([[11, 8, 7, 2], [5, 16, 14, 4], [9, 3, 15, 6], [12, 13, 10, 1]], 9) == [1, 6, 1, 6, 1, 6, 1, 6, 1]\n assert candidate([[12, 13, 10, 1], [9, 3, 15, 6], [5, 16, 14, 4], [11, 8, 7, 2]], 12) == [1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6]\n assert candidate([[2, 7, 4], [3, 1, 5], [6, 8, 9]], 8) == [1, 3, 1, 3, 1, 3, 1, 3]\n assert candidate([[6, 1, 5], [3, 8, 9], [2, 7, 4]], 8) == [1, 5, 1, 5, 1, 5, 1, 5]\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([[1, 2], [3, 4]], 10) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate([[1, 3], [3, 2]], 10) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]\n\n\ncandidate = minPath\ncheck(candidate)", "entry_point": "minPath"} +{"task_id": "bt_JHumanEval/130", "prompt": "フィボナッチ数列は、ここ数世紀の間に数学者によって深く研究され、誰もが知っている。\n しかし、人々が知らないのはトリボナッチ数列である。\n トリボナッチ数列は再帰によって定義される:\n tri(1) = 3\n tri(n) = 1 + n / 2, n が偶数の場合.\n tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), n が奇数の場合d.\n 例えば:\n tri(2) = 1 + (2 / 2) = 2\n tri(4) = 3\n tri(3) = tri(2) + tri(1) + tri(4)\n = 2 + 3 + 3 = 8 \n あなたは非負の整数nが与えられるので、トリボナッチ数列の最初のn + 1個の数の\n リストを返さなければならな���。\n 例:\n tri(3) = [1, 3, 2, 8]", "code": "def tri(n):\n if n == 0:\n return [1]\n my_tri = [1, 3]\n for i in range(2, n + 1):\n if i % 2 == 0:\n my_tri.append(i / 2 + 1)\n else:\n my_tri.append(my_tri[i - 1] + my_tri[i - 2] + (i + 3) / 2)\n return my_tri\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n \n assert candidate(3) == [1, 3, 2.0, 8.0]\n assert candidate(4) == [1, 3, 2.0, 8.0, 3.0]\n assert candidate(5) == [1, 3, 2.0, 8.0, 3.0, 15.0]\n assert candidate(6) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0]\n assert candidate(7) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0]\n assert candidate(8) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0]\n assert candidate(9) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0, 35.0]\n assert candidate(20) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0, 35.0, 6.0, 48.0, 7.0, 63.0, 8.0, 80.0, 9.0, 99.0, 10.0, 120.0, 11.0]\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(0) == [1]\n assert candidate(1) == [1, 3]\n\ncandidate = tri\ncheck(candidate)", "entry_point": "tri"} +{"task_id": "bt_JHumanEval/131", "prompt": "正の整数 n が与えられた時、奇数桁数の積を返す。\n 全ての桁が偶数の場合は0を返す。\n 例えば:\n digits(1) == 1\n digits(4) == 0\n digits(235) == 15", "code": "def digits(n):\n product = 1\n odd_count = 0\n for digit in str(n):\n int_digit = int(digit)\n if int_digit%2 == 1:\n product= product*int_digit\n odd_count+=1\n if odd_count ==0:\n return 0\n else:\n return product\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(5) == 5\n assert candidate(54) == 5\n assert candidate(120) ==1\n assert candidate(5014) == 5\n assert candidate(98765) == 315\n assert candidate(5576543) == 2625\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(2468) == 0\n\n\ncandidate = digits\ncheck(candidate)", "entry_point": "digits"} +{"task_id": "bt_JHumanEval/132", "prompt": "この関数は、角括弧だけを含む文字列を入力として受け取ります。括弧が有効な順序で\n 並んでいて、その中に少なくとも1つの括弧が入れ子になっている場合、関数はTrueを\n 返すようにしてください。\n\n is_nested('[[]]') ➞ True\n is_nested('[]]]]]]][[[[[]') ➞ False\n is_nested('[][]') ➞ False\n is_nested('[]') ➞ False\n is_nested('[[][]]') ➞ True\n is_nested('[[]][[') ➞ True", "code": "def is_nested(string):\n opening_bracket_index = []\n closing_bracket_index = []\n for i in range(len(string)):\n if string[i] == '[':\n opening_bracket_index.append(i)\n else:\n closing_bracket_index.append(i)\n closing_bracket_index.reverse()\n cnt = 0\n i = 0\n l = len(closing_bracket_index)\n for idx in opening_bracket_index:\n if i < l and idx < closing_bracket_index[i]:\n cnt += 1\n i += 1\n return cnt >= 2\n\n \n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('[[]]') == True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('[]]]]]]][[[[[]') == False\n assert candidate('[][]') == False\n assert candidate(('[]')) == False\n assert candidate('[[[[]]]]') == True\n assert candidate('[]]]]]]]]]]') == False\n assert candidate('[][][[]]') == True\n assert candidate('[[]') == False\n assert candidate('[]]') == False\n assert candidate('[[]][[') == True\n assert candidate('[[][]]') == True\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('') == False, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate('[[[[[[[[') == False\n assert candidate(']]]]]]]]') == False\n\n\ncandidate = is_nested\ncheck(candidate)", "entry_point": "is_nested"} +{"task_id": "bt_JHumanEval/133", "prompt": "数字のリストが与えられます。\n 与えられたリスト内の各数値をまず切り上げ(天井関数を使って最も近い整数に丸める)、\n その後それぞれの数値を二乗した値の合計を返してください。\n 例:\n lst = [1,2,3] のときの出力は 14\n lst = [1,4,9] のときの出力は 98\n lst = [1,3,5,7] のときの出力は 84\n lst = [1.4,4.2,0] のときの出力は 29\n lst = [-2.4,1,1] のときの出力は 6", "code": "def sum_squares(lst):\n import math\n squared = 0\n for i in lst:\n squared += math.ceil(i)**2\n return squared\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1,2,3])==14, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1.0,2,3])==14, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1,3,5,7])==84, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1.4,4.2,0])==29, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([-2.4,1,1])==6, \"This prints if this assert fails 1 (good for debugging!)\"\n\n assert candidate([100,1,15,2])==10230, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([10000,10000])==200000000, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([-1.4,4.6,6.3])==75, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([-1.4,17.9,18.9,19.9])==1086, \"This prints if this assert fails 1 (good for debugging!)\"\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([0])==0, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([-1])==1, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([-1,1,0])==2, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = sum_squares\ncheck(candidate)", "entry_point": "sum_squares"} +{"task_id": "bt_JHumanEval/134", "prompt": "与えられた文字列の最後の文字がアルファベットであり、かつ単語の一部でなければTrueを、\n そうでなければFalseを返す関数を作成せよ。\n 注意:単語とはスペースで区切られた文字の並びである。\n 例:\n check_if_last_char_is_a_letter(\"apple pie\") ➞ False\n check_if_last_char_is_a_letter(\"apple pi e\") ➞ True\n check_if_last_char_is_a_letter(\"apple pi e \") ➞ False\n check_if_last_char_is_a_letter(\"\") ➞ False", "code": "def check_if_last_char_is_a_letter(txt):\n \n check = txt.split(' ')[-1]\n return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"apple\") == False\n assert candidate(\"apple pi e\") == True\n assert candidate(\"eeeee\") == False\n assert candidate(\"A\") == True\n assert candidate(\"Pumpkin pie \") == False\n assert candidate(\"Pumpkin pie 1\") == False\n assert candidate(\"\") == False\n assert candidate(\"eeeee e \") == False\n assert candidate(\"apple pie\") == False\n assert candidate(\"apple pi e \") == False\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = check_if_last_char_is_a_letter\ncheck(candidate)", "entry_point": "check_if_last_char_is_a_letter"} +{"task_id": "bt_JHumanEval/135", "prompt": "直前の要素よりも大きくない要素の中で、最も大きなインデックスを持つ要素を探して\n そのインデックスを返す関数を作成してください。そのような要素が存在しない場合は、\n -1を返してください。与えられる配列には重複する値は含まれません。\n 例:\n can_arrange([1,2,4,3,5]) = 3\n can_arrange([1,2,3]) = -1", "code": "def can_arrange(arr):\n ind=-1\n i=1\n while i 0, lst))\n return (max(smallest) if smallest else None, min(largest) if largest else None)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([2, 4, 1, 3, 5, 7]) == (None, 1)\n assert candidate([2, 4, 1, 3, 5, 7, 0]) == (None, 1)\n assert candidate([1, 3, 2, 4, 5, 6, -2]) == (-2, 1)\n assert candidate([4, 5, 3, 6, 2, 7, -7]) == (-7, 2)\n assert candidate([7, 3, 8, 4, 9, 2, 5, -9]) == (-9, 2)\n assert candidate([]) == (None, None)\n assert candidate([0]) == (None, None)\n assert candidate([-1, -3, -5, -6]) == (-1, None)\n assert candidate([-1, -3, -5, -6, 0]) == (-1, None)\n assert candidate([-6, -4, -4, -3, 1]) == (-3, 1)\n assert candidate([-6, -4, -4, -3, -100, 1]) == (-3, 1)\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\ncandidate = largest_smallest_integers\ncheck(candidate)", "entry_point": "largest_smallest_integers"} +{"task_id": "bt_JHumanEval/137", "prompt": "整数、浮動小数点数、または実数を表す文字列を引数として受け取り、その中で最も大きい値を\n その元の型で返す関数を作成してください。もし値が同じであれば、Noneを返してください。\n 注意:実数が文字列として表されている場合、小数点はピリオド(.)またはカンマ(,)の可能性があります。\n\n compare_one(1, 2.5) ➞ 2.5\n compare_one(1, \"2,3\") ➞ \"2,3\"\n compare_one(\"5,1\", \"6\") ➞ \"6\"\n compare_one(\"1\", 1) ➞ None", "code": "def compare_one(a, b):\n temp_a, temp_b = a, b\n if isinstance(temp_a, str): temp_a = temp_a.replace(',','.')\n if isinstance(temp_b, str): temp_b = temp_b.replace(',','.')\n if float(temp_a) == float(temp_b): return None\n return a if float(temp_a) > float(temp_b) else b \n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(1, 2) == 2\n assert candidate(1, 2.5) == 2.5\n assert candidate(2, 3) == 3\n assert candidate(5, 6) == 6\n assert candidate(1, \"2,3\") == \"2,3\"\n assert candidate(\"5,1\", \"6\") == \"6\"\n assert candidate(\"1\", \"2\") == \"2\"\n assert candidate(\"1\", 1) == None\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = compare_one\ncheck(candidate)", "entry_point": "compare_one"} +{"task_id": "bt_JHumanEval/138", "prompt": "与えられた数値nが、ちょうど4つの正の偶数の合計として表現できるかどうかを評価してください。\n 例\n is_equal_to_sum_even(4) == False\n is_equal_to_sum_even(6) == False\n is_equal_to_sum_even(8) == True", "code": "def is_equal_to_sum_even(n):\n return n%2 == 0 and n >= 8\n", "testcode": "def check(candidate):\n assert candidate(4) == False\n assert candidate(6) == False\n assert candidate(8) == True\n assert candidate(10) == True\n assert candidate(11) == False\n assert candidate(12) == True\n assert candidate(13) == False\n assert candidate(16) == True\n\ncandidate = is_equal_to_sum_even\ncheck(candidate)", "entry_point": "is_equal_to_sum_even"} +{"task_id": "bt_JHumanEval/139", "prompt": "ブラジリアン階乗は次のように定義される:\n brazilian_factorial(n) = n!* (n-1)! * (n-2)! * ... * 1!\n ただし n > 0\n\n 例えば:\n >>> special_factorial(4)\n 288\n\n この関数は入力として整数を受け取り、整数の特殊な階乗を返す。", "code": "def special_factorial(n):\n fact_i = 1\n special_fact = 1\n for i in range(1, n+1):\n fact_i *= i\n special_fact *= fact_i\n return special_fact\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(4) == 288, \"Test 4\"\n assert candidate(5) == 34560, \"Test 5\"\n assert candidate(7) == 125411328000, \"Test 7\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1) == 1, \"Test 1\"\n\n\ncandidate = special_factorial\ncheck(candidate)", "entry_point": "special_factorial"} +{"task_id": "bt_JHumanEval/140", "prompt": "文字列テキストが与えられた場合、その中のすべての空白をアンダースコアに置換し、\n 文字列が2つ以上の連続した空白を持つ場合、すべての連続した空白を - に置換する\n\n fix_spaces(\"Example\") == \"Example\"\n fix_spaces(\"Example 1\") == \"Example_1\"\n fix_spaces(\" Example 2\") == \"_Example_2\"\n fix_spaces(\" Example 3\") == \"_Example-3\"", "code": "def fix_spaces(text):\n new_text = \"\"\n i = 0\n start, end = 0, 0\n while i < len(text):\n if text[i] == \" \":\n end += 1\n else:\n if end - start > 2:\n new_text += \"-\"+text[i]\n elif end - start > 0:\n new_text += \"_\"*(end - start)+text[i]\n else:\n new_text += text[i]\n start, end = i+1, i+1\n i+=1\n if end - start > 2:\n new_text += \"-\"\n elif end - start > 0:\n new_text += \"_\"\n return new_text\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"Example\") == \"Example\", \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(\"Mudasir Hanif \") == \"Mudasir_Hanif_\", \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate(\"Yellow Yellow Dirty Fellow\") == \"Yellow_Yellow__Dirty__Fellow\", \"This prints if this assert fails 3 (good for debugging!)\"\n \n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"Exa mple\") == \"Exa-mple\", \"This prints if this assert fails 4 (good for debugging!)\"\n assert candidate(\" Exa 1 2 2 mple\") == \"-Exa_1_2_2_mple\", \"This prints if this assert fails 4 (good for debugging!)\"\n\n\ncandidate = fix_spaces\ncheck(candidate)", "entry_point": "fix_spaces"} +{"task_id": "bt_JHumanEval/141", "prompt": "ファイル名を表す文字列を受け取り、そのファイル名が有効であれば'Yes'を返し、そうでなければ'No'\n を返す関数を作成する。ファイル名が有効であるとみなされるのは、\n 以下の条件をすべて満たす場合のみである:\n - ファイル名に3桁以上の数字('0'-'9')があってはならない。\n - ファイル名に含まれるドット '.' はひとつのみ。\n - ドットの前の部分文字列は空であってはならず、英文字('a'-'z'および'A'-'Z')から始まる文字でなければならない。\n - ドットの後の部分文字列は、以下のいずれかでなければならない: ['txt'、'exe'、'dll']。\n 例:\n file_name_check(\"example.txt\") # => 'Yes'\n file_name_check(\"1example.dll\") # => 'No' (名前は英文字で始まらないといけない)", "code": "def file_name_check(file_name):\n suf = ['txt', 'exe', 'dll']\n lst = file_name.split(sep='.')\n if len(lst) != 2:\n return 'No'\n if not lst[1] in suf:\n return 'No'\n if len(lst[0]) == 0:\n return 'No'\n if not lst[0][0].isalpha():\n return 'No'\n t = len([x for x in lst[0] if x.isdigit()])\n if t > 3:\n return 'No'\n return 'Yes'\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"example.txt\") == 'Yes'\n assert candidate(\"1example.dll\") == 'No'\n assert candidate('s1sdf3.asd') == 'No'\n assert candidate('K.dll') == 'Yes'\n assert candidate('MY16FILE3.exe') == 'Yes'\n assert candidate('His12FILE94.exe') == 'No'\n assert candidate('_Y.txt') == 'No'\n assert candidate('?aREYA.exe') == 'No'\n assert candidate('/this_is_valid.dll') == 'No'\n assert candidate('this_is_valid.wow') == 'No'\n assert candidate('this_is_valid.txt') == 'Yes'\n assert candidate('this_is_valid.txtexe') == 'No'\n assert candidate('#this2_i4s_5valid.ten') == 'No'\n assert candidate('@this1_is6_valid.exe') == 'No'\n assert candidate('this_is_12valid.6exe4.txt') == 'No'\n assert candidate('all.exe.txt') == 'No'\n assert candidate('I563_No.exe') == 'Yes'\n assert candidate('Is3youfault.txt') == 'Yes'\n assert candidate('no_one#knows.dll') == 'Yes'\n assert candidate('1I563_Yes3.exe') == 'No'\n assert candidate('I563_Yes3.txtt') == 'No'\n assert candidate('final..txt') == 'No'\n assert candidate('final132') == 'No'\n assert candidate('_f4indsartal132.') == 'No'\n \n \n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('.txt') == 'No'\n assert candidate('s.') == 'No'\n\n\ncandidate = file_name_check\ncheck(candidate)", "entry_point": "file_name_check"} +{"task_id": "bt_JHumanEval/142", "prompt": "\"\n この関数は整数のリストを受け取ります。リスト内の各要素に対して、そのインデックスが3の倍数で\n あればその整数を二乗し、インデックスが4の倍数でかつ3の倍数でない場合はその整数を三乗します。\n インデックスが3または4の倍数でない要素については、何も変更しません。最後に、すべての要素の\n 合計値を返します。\n \n 例:\n lst = [1,2,3] の時、返り値は 6\n lst = [] の時、返り値は 0\n lst = [-1,-5,2,-1,-5] の時、返り値は -126", "code": "def sum_squares(lst):\n result =[]\n for i in range(len(lst)):\n if i %3 == 0:\n result.append(lst[i]**2)\n elif i % 4 == 0 and i%3 != 0:\n result.append(lst[i]**3)\n else:\n result.append(lst[i])\n return sum(result)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n \n assert candidate([1,2,3]) == 6\n assert candidate([1,4,9]) == 14\n assert candidate([]) == 0\n assert candidate([1,1,1,1,1,1,1,1,1]) == 9\n assert candidate([-1,-1,-1,-1,-1,-1,-1,-1,-1]) == -3\n assert candidate([0]) == 0\n assert candidate([-1,-5,2,-1,-5]) == -126\n assert candidate([-56,-99,1,0,-2]) == 3030\n assert candidate([-1,0,0,0,0,0,0,0,-1]) == 0\n assert candidate([-16, -9, -2, 36, 36, 26, -20, 25, -40, 20, -4, 12, -26, 35, 37]) == -14196\n assert candidate([-1, -3, 17, -1, -15, 13, -1, 14, -14, -12, -5, 14, -14, 6, 13, 11, 16, 16, 4, 10]) == -1448\n \n \n # Don't remove this line:\n\ncandidate = sum_squares\ncheck(candidate)", "entry_point": "sum_squares"} +{"task_id": "bt_JHumanEval/143", "prompt": "文を表す文字列が与えられ、その文には空白で区切られたいくつかの単語が含まれている。\n 元の文の単語を含みその長さが素数である文字列を返す必要がある。\n 新しい文字列の単語の順序は元の文字列と同じでなければならない。\n\n 例 1:\n 入力: sentence = \"This is a test\"\n 出力: \"is\"\n\n 例 2:\n 入力: sentence = \"lets go for swimming\"\n 出力: \"go for\"\n\n 制約:\n * 1 <= len(sentence) <= 100\n * sentence contains only letters", "code": "def words_in_sentence(sentence):\n new_lst = []\n for word in sentence.split():\n flg = 0\n if len(word) == 1:\n flg = 1\n for i in range(2, len(word)):\n if len(word)%i == 0:\n flg = 1\n if flg == 0 or len(word) == 2:\n new_lst.append(word)\n return \" \".join(new_lst)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"This is a test\") == \"is\"\n assert candidate(\"lets go for swimming\") == \"go for\"\n assert candidate(\"there is no place available here\") == \"there is no place\"\n assert candidate(\"Hi I am Hussein\") == \"Hi am Hussein\"\n assert candidate(\"go for it\") == \"go for it\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"here\") == \"\"\n assert candidate(\"here is\") == \"is\"\n\n\ncandidate = words_in_sentence\ncheck(candidate)", "entry_point": "words_in_sentence"} +{"task_id": "bt_JHumanEval/144", "prompt": "あなたの仕事は、式 x * n を簡単にする関数を実装することです。\n この関数は、x * n が整数になる場合はTrueを、そうでない場合はFalseを\n 返します。xとnはともに分数の文字列表現であり、<分子>/<分母>という形式で、\n 分子と分母はともに正の整数です。\n \n xとnが有効な分数であり、分母がゼロでないことは仮定してかまいません。\n \n simplify(\"1/5\", \"5/1\") = True\n simplify(\"1/6\", \"2/1\") = False\n simplify(\"7/10\", \"10/2\") = False", "code": "def simplify(x, n):\n a, b = x.split(\"/\")\n c, d = n.split(\"/\")\n numerator = int(a) * int(c)\n denom = int(b) * int(d)\n if (numerator/denom == int(numerator/denom)):\n return True\n return False\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"1/5\", \"5/1\") == True, 'test1'\n assert candidate(\"1/6\", \"2/1\") == False, 'test2'\n assert candidate(\"5/1\", \"3/1\") == True, 'test3'\n assert candidate(\"7/10\", \"10/2\") == False, 'test4'\n assert candidate(\"2/10\", \"50/10\") == True, 'test5'\n assert candidate(\"7/2\", \"4/2\") == True, 'test6'\n assert candidate(\"11/6\", \"6/1\") == True, 'test7'\n assert candidate(\"2/3\", \"5/2\") == False, 'test8'\n assert candidate(\"5/2\", \"3/5\") == False, 'test9'\n assert candidate(\"2/4\", \"8/4\") == True, 'test10'\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"2/4\", \"4/2\") == True, 'test11'\n assert candidate(\"1/5\", \"5/1\") == True, 'test12'\n assert candidate(\"1/5\", \"1/5\") == False, 'test13'\n\n\ncandidate = simplify\ncheck(candidate)", "entry_point": "simplify"} +{"task_id": "bt_JHumanEval/145", "prompt": "各数字の桁の合計に基づいて、与えられた整数のリストを昇順に並べる\n 関数を作成してください。\n 注意:もし桁の合計が同じである複数の項目がある場合は、\n 元のリストでの位置に基づいて並べてください。\n 例えば\n >> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11].\n >> order_by_points([]) == [].", "code": "def order_by_points(nums):\n def digits_sum(n):\n neg = 1\n if n < 0: n, neg = -1 * n, -1 \n n = [int(i) for i in str(n)]\n n[0] = n[0] * neg\n return sum(n)\n return sorted(nums, key=digits_sum)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]\n assert candidate([1234,423,463,145,2,423,423,53,6,37,3457,3,56,0,46]) == [0, 2, 3, 6, 53, 423, 423, 423, 1234, 145, 37, 46, 56, 463, 3457]\n assert candidate([]) == []\n assert candidate([1, -11, -32, 43, 54, -98, 2, -3]) == [-3, -32, -98, -11, 1, 2, 43, 54]\n assert candidate([1,2,3,4,5,6,7,8,9,10,11]) == [1, 10, 2, 11, 3, 4, 5, 6, 7, 8, 9]\n assert candidate([0,6,6,-76,-21,23,4]) == [-76, -21, 0, 4, 23, 6, 6]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = order_by_points\ncheck(candidate)", "entry_point": "order_by_points"} +{"task_id": "bt_JHumanEval/146", "prompt": "数値の配列を入力とし、配列中の要素のうち、10より大きく、\n かつ数値の最初と最後の桁の両方が奇数(1, 3, 5, 7, 9)である要素の数を返す関数を書く。\n 例えば\n specialFilter([15, -73, 14, -15]) => 1 \n specialFilter([33, -2, -3, 45, 21, 109]) => 2", "code": "def specialFilter(nums):\n \n count = 0\n for num in nums:\n if num > 10:\n odd_digits = (1, 3, 5, 7, 9)\n number_as_string = str(num)\n if int(number_as_string[0]) in odd_digits and int(number_as_string[-1]) in odd_digits:\n count += 1\n \n return count \n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([5, -2, 1, -5]) == 0 \n assert candidate([15, -73, 14, -15]) == 1\n assert candidate([33, -2, -3, 45, 21, 109]) == 2\n assert candidate([43, -12, 93, 125, 121, 109]) == 4\n assert candidate([71, -2, -33, 75, 21, 19]) == 3\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1]) == 0 \n assert candidate([]) == 0 \n\n\ncandidate = specialFilter\ncheck(candidate)", "entry_point": "specialFilter"} +{"task_id": "bt_JHumanEval/147", "prompt": "正の整数 n が与えられるので、長さ n の整数配列 a を作成せよ。\n 各 i (1 ≤ i ≤ n) に対して、 a[i] = i * i - i + 1 とする。\n i < j < k において、a[i] + a[j] + a[k] が3の倍数となるような三つ組 (a[i], a[j], a[k]) を返す。\n\n 例 :\n 入力: n = 5\n 出力t: 1\n 解説: \n a = [1, 3, 7, 13, 21]\n 唯一の妥当な三つ組は (1, 7, 13)である。", "code": "def get_max_triples(n):\n A = [i*i - i + 1 for i in range(1,n+1)]\n ans = []\n for i in range(n):\n for j in range(i+1,n):\n for k in range(j+1,n):\n if (A[i]+A[j]+A[k])%3 == 0:\n ans += [(A[i],A[j],A[k])]\n return len(ans)\n", "testcode": "def check(candidate):\n\n assert candidate(5) == 1\n assert candidate(6) == 4\n assert candidate(10) == 36\n assert candidate(100) == 53361\n\ncandidate = get_max_triples\ncheck(candidate)", "entry_point": "get_max_triples"} +{"task_id": "bt_JHumanEval/148", "prompt": "私たちの太陽系には8つの惑星があります:太陽に最も近いのはVenus, Earth, Mars, Jupiter, Saturn, \n Uranus, Neptuneです。\n planet1とplanet2という2つの惑星名を文字列として受け取る関数を作成してください。\n この関数は、planet1の軌道とplanet2の軌道の間に位置するすべての惑星を太陽に近い順に並べたタプルを返すべきです。\n planet1またはplanet2が正確な惑星名でない場合、関数は空のタプルを返すべきです。\n 例\n bf(\"Jupiter\", \"Neptune\") ==> (\"Saturn\", \"Uranus\")\n bf(\"Earth\", \"Mercury\") ==> (\"Venus\")\n bf(\"Mercury\", \"Uranus\") ==> (\"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\")", "code": "def bf(planet1, planet2):\n planet_names = (\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\")\n if planet1 not in planet_names or planet2 not in planet_names or planet1 == planet2:\n return ()\n planet1_index = planet_names.index(planet1)\n planet2_index = planet_names.index(planet2)\n if planet1_index < planet2_index:\n return (planet_names[planet1_index + 1: planet2_index])\n else:\n return (planet_names[planet2_index + 1 : planet1_index])\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"Jupiter\", \"Neptune\") == (\"Saturn\", \"Uranus\"), \"First test error: \" + str(len(candidate(\"Jupiter\", \"Neptune\"))) \n assert candidate(\"Earth\", \"Mercury\") == (\"Venus\",), \"Second test error: \" + str(candidate(\"Earth\", \"Mercury\")) \n assert candidate(\"Mercury\", \"Uranus\") == (\"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\"), \"Third test error: \" + str(candidate(\"Mercury\", \"Uranus\")) \n assert candidate(\"Neptune\", \"Venus\") == (\"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\"), \"Fourth test error: \" + str(candidate(\"Neptune\", \"Venus\")) \n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"Earth\", \"Earth\") == ()\n assert candidate(\"Mars\", \"Earth\") == ()\n assert candidate(\"Jupiter\", \"Makemake\") == ()\n\n\ncandidate = bf\ncheck(candidate)", "entry_point": "bf"} +{"task_id": "bt_JHumanEval/149", "prompt": "文字列のリストを引数として受け取る関数を作成してください。\n この関数は、リストから奇数の長さを持つ文字列を削除し、\n 結果として得られるリストを長さで昇順に並べ替えて返します。\n リストは常に文字列のリストであり、数字の配列ではありません。\n また、重複する文字列が含まれる可能性があります。\n リストは各単語の長さで昇順に並べられるべきで、そのルールに従ってソートされたリストを返してください。\n もし二つの単語が同じ長さであれば、リストをアルファベット順に並べ替えてください。\n 関数はソートされた順序で文字列のリストを返すべきです。\n すべての単語が同じ長さを持つと仮定しても構いません。\n 例えば:\n assert list_sort([\"aa\", \"a\", \"aaa\"]) => [\"aa\"]\n assert list_sort([\"ab\", \"a\", \"aaa\", \"cd\"]) => [\"ab\", \"cd\"]", "code": "def sorted_list_sum(lst):\n lst.sort()\n new_lst = []\n for i in lst:\n if len(i)%2 == 0:\n new_lst.append(i)\n return sorted(new_lst, key=len)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([\"aa\", \"a\", \"aaa\"]) == [\"aa\"]\n assert candidate([\"school\", \"AI\", \"asdf\", \"b\"]) == [\"AI\", \"asdf\", \"school\"]\n assert candidate([\"d\", \"b\", \"c\", \"a\"]) == []\n assert candidate([\"d\", \"dcba\", \"abcd\", \"a\"]) == [\"abcd\", \"dcba\"]\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([\"AI\", \"ai\", \"au\"]) == [\"AI\", \"ai\", \"au\"]\n assert candidate([\"a\", \"b\", \"b\", \"c\", \"c\", \"a\"]) == []\n assert candidate(['aaaa', 'bbbb', 'dd', 'cc']) == [\"cc\", \"dd\", \"aaaa\", \"bbbb\"]\n\n\ncandidate = sorted_list_sum\ncheck(candidate)", "entry_point": "sorted_list_sum"} +{"task_id": "bt_JHumanEval/150", "prompt": "素数である場合はxの値を返し、それ以外の場合はyの値を返す簡単なプログラム。\n\n 例:\n for x_or_y(7, 34, 12) == 34\n for x_or_y(15, 8, 5) == 5", "code": "def x_or_y(n, x, y):\n if n == 1:\n return y\n for i in range(2, n):\n if n % i == 0:\n return y\n break\n else:\n return x\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(7, 34, 12) == 34\n assert candidate(15, 8, 5) == 5\n assert candidate(3, 33, 5212) == 33\n assert candidate(1259, 3, 52) == 3\n assert candidate(7919, -1, 12) == -1\n assert candidate(3609, 1245, 583) == 583\n assert candidate(91, 56, 129) == 129\n assert candidate(6, 34, 1234) == 1234\n \n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1, 2, 0) == 0\n assert candidate(2, 2, 0) == 2\n\n\ncandidate = x_or_y\ncheck(candidate)", "entry_point": "x_or_y"} +{"task_id": "bt_JHumanEval/151", "prompt": "数字のリストが与えられた場合、そのリスト内の奇数の数値の二乗の合計を返してください。\n 負の数や整数でない数は無視してください。\n \n double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10\n double_the_difference([-1, -2, 0]) == 0\n double_the_difference([9, -2]) == 81\n double_the_difference([0]) == 0 \n \n 入力リストが空の場合は0を返すようにしてください。", "code": "def double_the_difference(lst):\n return sum([i**2 for i in lst if i > 0 and i%2!=0 and \".\" not in str(i)])\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([]) == 0 , \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([5, 4]) == 25 , \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate([0.1, 0.2, 0.3]) == 0 , \"This prints if this assert fails 3 (good for debugging!)\"\n assert candidate([-10, -20, -30]) == 0 , \"This prints if this assert fails 4 (good for debugging!)\"\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([-1, -2, 8]) == 0, \"This prints if this assert fails 5 (also good for debugging!)\"\n assert candidate([0.2, 3, 5]) == 34, \"This prints if this assert fails 6 (also good for debugging!)\"\n lst = list(range(-99, 100, 2))\n odd_sum = sum([i**2 for i in lst if i%2!=0 and i > 0])\n assert candidate(lst) == odd_sum , \"This prints if this assert fails 7 (good for debugging!)\"\n\n\ncandidate = double_the_difference\ncheck(candidate)", "entry_point": "double_the_difference"} +{"task_id": "bt_JHumanEval/152", "prompt": "待ち望んでいた出来事の結果がようやく判明したときの感覚は、誰もが覚えていると思う。\n その瞬間に抱いた感情や思考は、間違いなくメモして比較する価値がある。\n あなたの仕事は、人がいくつかの試合の結果を正確に予想したかどうかを判断することです。\n スコアと予想の2つの配列が等しい長さで与えられます。各インデックスは1つの試合を示しています。\n 各予想がどれだけ外れていたかを示す同じ長さの配列を返してください。予想が正確であれば、\n その値は0です。そうでなければ、その値は予想とスコアの絶対的な差です。\n \n \n 例:\n\n compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]\n compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]", "code": "def compare(game,guess):\n return [abs(x-y) for x,y in zip(game,guess)]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1,2,3,4,5,1],[1,2,3,4,2,-2])==[0,0,0,0,3,3], \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([0,0,0,0,0,0],[0,0,0,0,0,0])==[0,0,0,0,0,0], \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1,2,3],[-1,-2,-3])==[2,4,6], \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1,2,3,5],[-1,2,3,4])==[2,0,0,1], \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = compare\ncheck(candidate)", "entry_point": "compare"} +{"task_id": "bt_JHumanEval/153", "prompt": "クラスの名前(文字列)と拡張子のリストが与えられます。\n この拡張子は、指定されたクラスに追加のクラスをロードするために使用されます。\n 拡張子の強度は次のように計算されます:CAPは拡張子の名前に含まれる\n 大文字の数、SMは小文字の数です。強度は、CAP - SM で与えられます。\n 最も強い拡張子を見つけて、この形式の文字列を返してください:ClassName.StrongestExtensionName。\n 同じ強度を持つ2つ以上の拡張子がある場合は、リストで最初に来るものを選びます。\n 例えば、\"Slices\"というクラスと、拡張子のリスト['SErviNGSliCes', 'Cheese', 'StuFfed'] が与えられた場合、'\n SErviNGSliCes'が最も強い拡張子(強度は-1)となるため、'Slices.SErviNGSliCes'を返すべきです。\n 例:\n Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'", "code": "def Strongest_Extension(class_name, extensions):\n strong = extensions[0]\n my_val = len([x for x in extensions[0] if x.isalpha() and x.isupper()]) - len([x for x in extensions[0] if x.isalpha() and x.islower()])\n for s in extensions:\n val = len([x for x in s if x.isalpha() and x.isupper()]) - len([x for x in s if x.isalpha() and x.islower()])\n if val > my_val:\n strong = s\n my_val = val\n\n ans = class_name + \".\" + strong\n return ans\n\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('Watashi', ['tEN', 'niNE', 'eIGHt8OKe']) == 'Watashi.eIGHt8OKe'\n assert candidate('Boku123', ['nani', 'NazeDa', 'YEs.WeCaNe', '32145tggg']) == 'Boku123.YEs.WeCaNe'\n assert candidate('__YESIMHERE', ['t', 'eMptY', 'nothing', 'zeR00', 'NuLl__', '123NoooneB321']) == '__YESIMHERE.NuLl__'\n assert candidate('K', ['Ta', 'TAR', 't234An', 'cosSo']) == 'K.TAR'\n assert candidate('__HAHA', ['Tab', '123', '781345', '-_-']) == '__HAHA.123'\n assert candidate('YameRore', ['HhAas', 'okIWILL123', 'WorkOut', 'Fails', '-_-']) == 'YameRore.okIWILL123'\n assert candidate('finNNalLLly', ['Die', 'NowW', 'Wow', 'WoW']) == 'finNNalLLly.WoW'\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('_', ['Bb', '91245']) == '_.Bb'\n assert candidate('Sp', ['671235', 'Bb']) == 'Sp.671235'\n \n\ncandidate = Strongest_Extension\ncheck(candidate)", "entry_point": "Strongest_Extension"} +{"task_id": "bt_JHumanEval/154", "prompt": "2つの単語が与えられる。2番目の単語またはその回転させた文字列が最初の単語の部分文字列である場合、Trueを返す必要がある。\n cycpattern_check(\"abcd\",\"abd\") => False\n cycpattern_check(\"hello\",\"ell\") => True\n cycpattern_check(\"whassup\",\"psus\") => False\n cycpattern_check(\"abab\",\"baa\") => True\n cycpattern_check(\"efef\",\"eeff\") => False\n cycpattern_check(\"himenss\",\"simen\") => True", "code": "def cycpattern_check(a , b):\n l = len(b)\n pat = b + b\n for i in range(len(a) - l + 1):\n for j in range(l + 1):\n if a[i:i+l] == pat[j:j+l]:\n return True\n return False\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n #assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n #assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(\"xyzw\",\"xyw\") == False , \"test #0\"\n assert candidate(\"yello\",\"ell\") == True , \"test #1\"\n assert candidate(\"whattup\",\"ptut\") == False , \"test #2\"\n assert candidate(\"efef\",\"fee\") == True , \"test #3\"\n assert candidate(\"abab\",\"aabb\") == False , \"test #4\"\n assert candidate(\"winemtt\",\"tinem\") == True , \"test #5\"\n\n\ncandidate = cycpattern_check\ncheck(candidate)", "entry_point": "cycpattern_check"} +{"task_id": "bt_JHumanEval/155", "prompt": "整数が与えられた場合、偶数桁数と奇数桁数をそれぞれ持つタプルを返す。\n 例:\n even_odd_count(-12) ==> (1, 1)\n even_odd_count(123) ==> (1, 2)", "code": "def even_odd_count(num):\n even_count = 0\n odd_count = 0\n for i in str(abs(num)):\n if int(i)%2==0:\n even_count +=1\n else:\n odd_count +=1\n return (even_count, odd_count)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(7) == (0, 1)\n assert candidate(-78) == (1, 1)\n assert candidate(3452) == (2, 2)\n assert candidate(346211) == (3, 3)\n assert candidate(-345821) == (3, 3)\n assert candidate(-2) == (1, 0)\n assert candidate(-45347) == (2, 3)\n assert candidate(0) == (1, 0)\n\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = even_odd_count\ncheck(candidate)", "entry_point": "even_odd_count"} +{"task_id": "bt_JHumanEval/156", "prompt": "正の整数が与えられたとき、ローマ数字に相当する文字列を小文字で返す。\n 制限事項1 <= num <= 1000\n 例:\n >>> int_to_mini_roman(19) == 'xix'\n >>> int_to_mini_roman(152) == 'clii'\n >>> int_to_mini_roman(426) == 'cdxxvi'", "code": "def int_to_mini_roman(number):\n num = [1, 4, 5, 9, 10, 40, 50, 90, \n 100, 400, 500, 900, 1000] \n sym = [\"I\", \"IV\", \"V\", \"IX\", \"X\", \"XL\", \n \"L\", \"XC\", \"C\", \"CD\", \"D\", \"CM\", \"M\"] \n i = 12\n res = ''\n while number: \n div = number // num[i] \n number %= num[i] \n while div: \n res += sym[i] \n div -= 1\n i -= 1\n return res.lower()\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(19) == 'xix'\n assert candidate(152) == 'clii'\n assert candidate(251) == 'ccli'\n assert candidate(426) == 'cdxxvi'\n assert candidate(500) == 'd'\n assert candidate(1) == 'i'\n assert candidate(4) == 'iv'\n assert candidate(43) == 'xliii'\n assert candidate(90) == 'xc'\n assert candidate(94) == 'xciv'\n assert candidate(532) == 'dxxxii'\n assert candidate(900) == 'cm'\n assert candidate(994) == 'cmxciv'\n assert candidate(1000) == 'm'\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = int_to_mini_roman\ncheck(candidate)", "entry_point": "int_to_mini_roman"} +{"task_id": "bt_JHumanEval/157", "prompt": "三角形の3辺の長さを与える。三角形が直角三角形ならTrueを、そうでなければFalseを返す。\n 直角三角形とは、1つの角が直角または90度である三角形のことである。\n 例:\n right_angle_triangle(3, 4, 5) == True\n right_angle_triangle(1, 2, 3) == False", "code": "def right_angle_triangle(a, b, c):\n return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(3, 4, 5) == True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(1, 2, 3) == False\n assert candidate(10, 6, 8) == True\n assert candidate(2, 2, 2) == False\n assert candidate(7, 24, 25) == True\n assert candidate(10, 5, 7) == False\n assert candidate(5, 12, 13) == True\n assert candidate(15, 8, 17) == True\n assert candidate(48, 55, 73) == True\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1, 1, 1) == False, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(2, 2, 10) == False\n\n\ncandidate = right_angle_triangle\ncheck(candidate)", "entry_point": "right_angle_triangle"} +{"task_id": "bt_JHumanEval/158", "prompt": "文字列のリストを受け取る関数を書きなさい。\n リストは異なる単語を含む。異なる固有の文字数が最も多い単語を返す。\n 複数の文字列が同じ文字数を持つ場合は、辞書順で最初に来るものを返すことにする。\n \n find_max([\"name\", \"of\", \"string\"]) == \"string\"\n find_max([\"name\", \"enam\", \"game\"]) == \"enam\"\n find_max([\"aaaaaaa\", \"bb\" ,\"cc\"]) == \"\"aaaaaaa\"", "code": "def find_max(words):\n return sorted(words, key = lambda x: (-len(set(x)), x))[0]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert (candidate([\"name\", \"of\", \"string\"]) == \"string\"), \"t1\"\n assert (candidate([\"name\", \"enam\", \"game\"]) == \"enam\"), 't2'\n assert (candidate([\"aaaaaaa\", \"bb\", \"cc\"]) == \"aaaaaaa\"), 't3'\n assert (candidate([\"abc\", \"cba\"]) == \"abc\"), 't4'\n assert (candidate([\"play\", \"this\", \"game\", \"of\",\"footbott\"]) == \"footbott\"), 't5'\n assert (candidate([\"we\", \"are\", \"gonna\", \"rock\"]) == \"gonna\"), 't6'\n assert (candidate([\"we\", \"are\", \"a\", \"mad\", \"nation\"]) == \"nation\"), 't7'\n assert (candidate([\"this\", \"is\", \"a\", \"prrk\"]) == \"this\"), 't8'\n\n # Check some edge cases that are easy to work out by hand.\n assert (candidate([\"b\"]) == \"b\"), 't9'\n assert (candidate([\"play\", \"play\", \"play\"]) == \"play\"), 't10'\n\n\ncandidate = find_max\ncheck(candidate)", "entry_point": "find_max"} +{"task_id": "bt_JHumanEval/159", "prompt": "あなたはお腹を空かせたウサギです。すでに一定数のニンジンを食べました。\n これからさらにニンジンを食べなければその日の食事は完了しません。\n あなたは [ 食事の後に食べたニンジンの総数, 食事の後に残ったニンジンの数 ] の配列を返してください。\n もし残りのニンジンが十分でなければ、あなたは残りのニンジンをすべて食べますが、まだお腹が空いています。\n\n 例:\n * eat(5, 6, 10) -> [11, 4]\n * eat(4, 8, 9) -> [12, 1]\n * eat(1, 10, 10) -> [11, 0]\n * eat(2, 11, 5) -> [7, 0]\n \n 変数:\n @number : 整数\n 食べたニンジンの数。\n @need : 整数\n にんじんを何本食べるか。\n @remaining : 整数\n 残りのニンジンの在庫数\n \n 制約:\n * 0 <= number <= 1000\n * 0 <= need <= 1000\n * 0 <= remaining <= 1000\n\n 楽しんで :)", "code": "def eat(number, need, remaining):\n if(need <= remaining):\n return [ number + need , remaining-need ]\n else:\n return [ number + remaining , 0]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(5, 6, 10) == [11, 4], \"Error\"\n assert candidate(4, 8, 9) == [12, 1], \"Error\"\n assert candidate(1, 10, 10) == [11, 0], \"Error\"\n assert candidate(2, 11, 5) == [7, 0], \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(4, 5, 7) == [9, 2], \"Error\"\n assert candidate(4, 5, 1) == [5, 0], \"Error\"\n\n\ncandidate = eat\ncheck(candidate)", "entry_point": "eat"} +{"task_id": "bt_JHumanEval/160", "prompt": "演算子(operator)とオペランド(operand)の2つのリストが与えられる。ひとつ目のリストは\n 基本的な算術演算を持ち、二つ目のリストは整数のリストである。与えられた2つのリストを\n 使って算術式を構築し、その評価結果を返そう。\n\n 基本的な算術演算:\n 加算 ( + ) \n 減算 ( - ) \n 乗算 ( * )\n 階除算 ( // ) \n 指数化 ( ** )\n \n 例:\n operator['+', '*', '-']\n array = [2, 3, 4, 5]\n result = 2 + 3 * 4 - 5\n => result = 9\n \n 注:演算子のリストの長さは、オペランドのリストの長さから1を引いた長さに等しい。\n オペランドは非負整数のリストである。\n operator は少なくとも1つの演算子を持ち、operand は少なくとも2つのオペランドを持つ。", "code": "def do_algebra(operator, operand):\n expression = str(operand[0])\n for oprt, oprn in zip(operator, operand[1:]):\n expression+= oprt + str(oprn)\n return eval(expression)\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(['**', '*', '+'], [2, 3, 4, 5]) == 37\n assert candidate(['+', '*', '-'], [2, 3, 4, 5]) == 9\n assert candidate(['//', '*'], [7, 3, 4]) == 8, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = do_algebra\ncheck(candidate)", "entry_point": "do_algebra"} +{"task_id": "bt_JHumanEval/161", "prompt": "文字列sが与えられます。\n もしs[i]がアルファベットなら、その文字の大文字と小文字を反転させる。そうでない場合は、そのままにしておく。\n もし文字列にアルファベットが一つも含まれていない場合は、文字列全体を逆順にする。\n 関数は結果の文字列を返すようにします。\n 例\n solve(\"1234\") = \"4321\"\n solve(\"ab\") = \"AB\"\n solve(\"#a@C\") = \"#A@c\"", "code": "def solve(s):\n flg = 0\n idx = 0\n new_str = list(s)\n for i in s:\n if i.isalpha():\n new_str[idx] = i.swapcase()\n flg = 1\n idx += 1\n s = \"\"\n for i in new_str:\n s += i\n if flg == 0:\n return s[len(s)::-1]\n return s\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"AsDf\") == \"aSdF\"\n assert candidate(\"1234\") == \"4321\"\n assert candidate(\"ab\") == \"AB\"\n assert candidate(\"#a@C\") == \"#A@c\"\n assert candidate(\"#AsdfW^45\") == \"#aSDFw^45\"\n assert candidate(\"#6@2\") == \"2@6#\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"#$a^D\") == \"#$A^d\"\n assert candidate(\"#ccc\") == \"#CCC\"\n\n # Don't remove this line:\n\ncandidate = solve\ncheck(candidate)", "entry_point": "solve"} +{"task_id": "bt_JHumanEval/162", "prompt": "文字列 text が与えられたとき、その md5 ハッシュと等価な文字列を返す。\n text' が空文字列の場合は None を返す。\n \n >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'", "code": "def string_to_md5(text):\n import hashlib\n return hashlib.md5(text.encode('ascii')).hexdigest() if text else None\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'\n assert candidate('') == None\n assert candidate('A B C') == '0ef78513b0cb8cef12743f5aeb35f888'\n assert candidate('password') == '5f4dcc3b5aa765d61d8327deb882cf99'\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n\ncandidate = string_to_md5\ncheck(candidate)", "entry_point": "string_to_md5"} +{"task_id": "bt_JHumanEval/163", "prompt": "正の整数aとbが与えられたとき、aとbの間にある偶数の数字を昇順で返してください。\n\n 例えば:\n generate_integers(2, 8) => [2, 4, 6, 8]\n generate_integers(8, 2) => [2, 4, 6, 8]\n generate_integers(10, 14) => []", "code": "def generate_integers(a, b):\n lower = max(2, min(a, b))\n upper = min(8, max(a, b))\n\n return [i for i in range(lower, upper+1) if i % 2 == 0]\n", "testcode": "def check(candidate):\n\n # Check some simple cases\n assert candidate(2, 10) == [2, 4, 6, 8], \"Test 1\"\n assert candidate(10, 2) == [2, 4, 6, 8], \"Test 2\"\n assert candidate(132, 2) == [2, 4, 6, 8], \"Test 3\"\n assert candidate(17,89) == [], \"Test 4\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n\ncandidate = generate_integers\ncheck(candidate)", "entry_point": "generate_integers"}