diff --git "a/data/test.jsonl" "b/data/test.jsonl" --- "a/data/test.jsonl" +++ "b/data/test.jsonl" @@ -1,164 +1,164 @@ -{"task_id":"HumanEval\/0","prompt":"from typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\"ตรวจสอบว่าในรายการตัวเลขที่กำหนดไว้ มีตัวเลขสองตัวใดที่อยู่ใกล้กันมากกว่าเกณฑ์ที่กำหนดไว้หรือไม่\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\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"has_close_elements"} -{"task_id":"HumanEval\/1","prompt":"from typing import List\n\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\"อินพุตของฟังก์ชันนี้คือสตริงที่มีวงเล็บซ้อนกันหลายกลุ่ม เป้าหมายของคุณคือแยกกลุ่มเหล่านั้นออกเป็นสตริงแยกกันและส่งคืนรายการของกลุ่มเหล่านั้น กลุ่มที่แยกจากกันจะสมดุลกัน (วงเล็บเปิดแต่ละอันปิดอย่างถูกต้อง) และไม่ซ้อนกัน ไม่สนใจช่องว่างใดๆ ในสตริงอินพุต\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"separate_paren_groups"} -{"task_id":"HumanEval\/2","prompt":"\n\ndef truncate_number(number: float) -> float:\n \"\"\"เมื่อกำหนดจำนวนจุดลอยตัวเป็นบวก ตัวเลขดังกล่าวสามารถแยกออกเป็นส่วนจำนวนเต็ม (จำนวนเต็มที่มากที่สุดที่เล็กกว่าจำนวนที่กำหนด) และทศนิยม (ส่วนที่เหลือจะเล็กกว่า 1 เสมอ) ส่งคืนส่วนทศนิยมของตัวเลข\n >>> truncate_number(3.5)\n 0.5\"\"\"\n","canonical_solution":" return number % 1.0\n","test":"\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","entry_point":"truncate_number"} -{"task_id":"HumanEval\/3","prompt":"from typing import List\n\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\"คุณจะได้รับรายการการฝากและถอนเงินในบัญชีธนาคารที่เริ่มต้นด้วยยอดเงินคงเหลือเป็นศูนย์ งานของคุณคือตรวจจับว่าเมื่อใดยอดเงินคงเหลือในบัญชีจะลดลงต่ำกว่าศูนย์ และเมื่อถึงจุดนั้น ฟังก์ชันควรส่งคืนค่��� True มิฉะนั้น ฟังก์ชันควรส่งคืนค่า False\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\"\"\"\n","canonical_solution":" balance = 0\n\n for op in operations:\n balance += op\n if balance < 0:\n return True\n\n return False\n","test":"\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","entry_point":"below_zero"} -{"task_id":"HumanEval\/4","prompt":"from typing import List\n\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\"สำหรับรายการตัวเลขอินพุตที่กำหนด ให้คำนวณค่าเบี่ยงเบนสัมบูรณ์เฉลี่ยรอบค่าเฉลี่ยของชุดข้อมูลนี้ ค่าเบี่ยงเบนสัมบูรณ์เฉลี่ยคือความแตกต่างสัมบูรณ์เฉลี่ยระหว่างแต่ละองค์ประกอบและจุดศูนย์กลาง (ค่าเฉลี่ยในกรณีนี้): MAD = ค่าเฉลี่ย | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\"\"\"\n","canonical_solution":" mean = sum(numbers) \/ len(numbers)\n return sum(abs(x - mean) for x in numbers) \/ len(numbers)\n","test":"\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","entry_point":"mean_absolute_deviation"} -{"task_id":"HumanEval\/5","prompt":"from typing import List\n\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\"แทรก \'ตัวแบ่ง\' ตัวเลขระหว่างองค์ประกอบ \'ตัวเลข\' สององค์ประกอบติดต่อกันของรายการอินพุต\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"intersperse"} -{"task_id":"HumanEval\/6","prompt":"from typing import List\n\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\"อินพุตของฟังก์ชันนี้คือสตริงที่แสดงกลุ่มต่างๆ หลายกลุ่มสำหรับวงเล็บซ้อนที่คั่นด้วยช่องว่าง สำหรับแต่ละกลุ่ม ให้แสดงระดับการซ้อนวงเล็บที่ลึกที่สุด ตัวอย่างเช่น (()()) มีระดับการซ้อนสูงสุดสองระดับในขณะที่ ((())) มีสามระดับ\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"parse_nested_parens"} -{"task_id":"HumanEval\/7","prompt":"from typing import List\n\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\"กรองรายการอินพุตของสตริงเฉพาะที่มีสตริงย่อยที่กำหนดเท่านั้น\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\"\"\"\n","canonical_solution":" return [x for x in strings if substring in x]\n","test":"\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","entry_point":"filter_by_substring"} -{"task_id":"HumanEval\/8","prompt":"from typing import List, Tuple\n\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\"สำหรับรายการจำนวนเต็มที่กำหนด ให้ส่งคืนทูเพิลที่ประกอบด้วยผลรวมและผลคูณของจำนวนเต็มทั้งหมดในรายการ ผลรวมว่างควรเท่ากับ 0 และผลคูณว่างควรเท่ากับ 1\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"sum_product"} -{"task_id":"HumanEval\/9","prompt":"from typing import List, Tuple\n\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\"จากรายการจำนวนเต็มที่กำหนดให้ สร้างรายการขององค์ประกอบสูงสุดที่หมุนเวียนที่พบจนถึงช่วงเวลาที่กำหนดในลำดับ\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"rolling_max"} -{"task_id":"HumanEval\/10","prompt":"\n\ndef is_palindrome(string: str) -> bool:\n \"\"\"ทดสอบว่าสตริงที่กำหนดเป็นพาลินโดรม \"\"\" return string == string[::-1] def make_palindrome(string: str) -> str:\n >>>\"\"\" Find the shortest palindrome that begins with a supplied string.\n Algorithm idea is simple:\n - Find the longest postfix of supplied string that is a palindrome.\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"make_palindrome"} -{"task_id":"HumanEval\/11","prompt":"from typing import List\n\n\ndef string_xor(a: str, b: str) -> str:\n \"\"\"อินพุตเป็นสตริงสองตัวคือ a และ b ที่ประกอบด้วย 1 และ 0 เท่านั้น ดำเนินการ XOR แบบไบนารีกับอินพุตเหล่านี้และส่งคืนผลลัพธ์เป็นสตริงด้วยเช่นกัน\n >>> string_xor('010', '110')\n '100'\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"string_xor"} -{"task_id":"HumanEval\/12","prompt":"from typing import List, Optional\n\n\ndef longest(strings: List[str]) -> Optional[str]:\n \"\"\"จากรายการสตริง ให้ส่งคืนสตริงที่ยาวที่สุด ส่งคืนสตริงแรกในกรณีที่มีสตริงหลายตัวที่มีความยาวเท่ากัน ส่งคืน None ในกรณีที่รายการอินพุตว่างเปล่า\n >>> longest([])\n\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"longest"} -{"task_id":"HumanEval\/13","prompt":"\n\ndef greatest_common_divisor(a: int, b: int) -> int:\n \"\"\"คืนค่าตัวหารร่วมมากของจำนวนเต็มสองจำนวนคือ a และ b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\"\"\"\n","canonical_solution":" while b:\n a, b = b, a % b\n return a\n","test":"\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","entry_point":"greatest_common_divisor"} -{"task_id":"HumanEval\/14","prompt":"from typing import List\n\n\ndef all_prefixes(string: str) -> List[str]:\n \"\"\"แสดงรายการคำนำหน้าทั้งหมดตั้งแต่สั้นที่สุดไปจนถึงยาวที่สุดของสตริงอินพุต\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']\"\"\"\n","canonical_solution":" result = []\n\n for i in range(len(string)):\n result.append(string[:i+1])\n return result\n","test":"\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","entry_point":"all_prefixes"} -{"task_id":"HumanEval\/15","prompt":"\n\ndef string_sequence(n: int) -> str:\n \"\"\"ส่งคืนสตริงที่มีตัวเลขที่คั่นด้วยช่องว่างตั้งแต่ 0 ถึง n\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\"\"\"\n","canonical_solution":" return ' '.join([str(x) for x in range(n + 1)])\n","test":"\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","entry_point":"string_sequence"} -{"task_id":"HumanEval\/16","prompt":"\n\ndef count_distinct_characters(string: str) -> int:\n \"\"\"กำหนดสตริง ให้หาว่ามีอักขระที่แตกต่างกันกี่ตัว (โดยไม่คำนึงถึงตัวพิมพ์ใหญ่เล็ก) ที่ประกอบด้วย\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\"\"\"\n","canonical_solution":" return len(set(string.lower()))\n","test":"\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","entry_point":"count_distinct_characters"} -{"task_id":"HumanEval\/17","prompt":"from typing import List\n\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\"อินพุตสำหรับฟังก์ชันนี้คือสตริงที่แสดงโน้ตดนตรีในรูปแบบ ASCII พิเศษ งานของคุณคือวิเคราะห์สตริงนี้และส่งคืนรายการจำนวนเต็มที่สอดคล้องกับจำนวนจังหวะที่แต่ละจังหวะไม่คงอยู่ ต่อไปนี้คือคำอธิบาย: \'o\' - โน้ตตัวเต็ม ยาวนานสี่จังหวะ \'o|\' - โน้ตตัวครึ่ง ยาวนานสองจังหวะ \'.|\' - โน้ตตัวกลาง ยาวนานหนึ่งจังหวะ\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\"\"\"\n","canonical_solution":" note_map = {'o': 4, 'o|': 2, '.|': 1}\n return [note_map[x] for x in music_string.split(' ') if x]\n","test":"\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","entry_point":"parse_music"} -{"task_id":"HumanEval\/18","prompt":"\n\ndef how_many_times(string: str, substring: str) -> int:\n \"\"\"ค้นหาว่าสามารถพบซับสตริงที่กำหนดได้กี่ครั้งในสตริงต้นฉบับ นับกรณีที่ทับซ้อนกัน\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"how_many_times"} -{"task_id":"HumanEval\/19","prompt":"from typing import List\n\n\ndef sort_numbers(numbers: str) -> str:\n \"\"\"อินพุตเป็นสตริงตัวเลขที่คั่นด้วยช่องว่างตั้งแต่ \'ศูนย์\' ถึง \'เก้า\' ตัวเลือกที่ถูกต้องคือ \'ศูนย์\' \'หนึ่ง\' \'สอง\' \'สาม\' \'สี่\' \'ห้า\' \'หก\' \'เจ็ด\' \'แปด\' และ \'เก้า\' ส่งคืนสตริงที่มีตัวเลขเรียงจากน้อยไปมาก\n >>> sort_numbers('three one five')\n 'one three five'\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"sort_numbers"} -{"task_id":"HumanEval\/20","prompt":"from typing import List, Tuple\n\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n \"\"\"จากรายการตัวเลขที่จัดทำไว้ (ความยาวอย่างน้อย 2) ให้เลือกตัวเลข 2 ตัวที่อยู่ใกล้กันมากที่สุด แล้วส่งคืนตามลำดับ (ตัวเลขที่น้อยกว่า ตัวเลขที่มากกว่า)\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)\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"find_closest_elements"} -{"task_id":"HumanEval\/21","prompt":"from typing import List\n\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \"\"\"กำหนดรายการตัวเลข (อย่างน้อย 2 องค์ประกอบ) ใช้การแปลงเชิงเส้นกับรายการนั้น โดยที่ตัวเลขที่เล็กที่สุดจะกลายเป็น 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]\"\"\"\n","canonical_solution":" min_number = min(numbers)\n max_number = max(numbers)\n return [(x - min_number) \/ (max_number - min_number) for x in numbers]\n","test":"\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","entry_point":"rescale_to_unit"} -{"task_id":"HumanEval\/22","prompt":"from typing import List, Any\n\n\ndef filter_integers(values: List[Any]) -> List[int]:\n \"\"\"กรองรายการค่า Python ที่กำหนดไว้เฉพาะสำหรับจำนวนเต็มเท่านั้น\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', {}, []])\n [1, 2, 3]\"\"\"\n","canonical_solution":" return [x for x in values if isinstance(x, int)]\n","test":"\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","entry_point":"filter_integers"} -{"task_id":"HumanEval\/23","prompt":"\n\ndef strlen(string: str) -> int:\n \"\"\"ส่งคืนความยาวของสตริงที่กำหนด\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3\"\"\"\n","canonical_solution":" return len(string)\n","test":"\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","entry_point":"strlen"} -{"task_id":"HumanEval\/24","prompt":"\n\ndef largest_divisor(n: int) -> int:\n \"\"\"สำหรับจำนวน n ที่กำหนด หาจำนวนที่มากที่สุดที่หาร n ได้ลงตัว ซึ่งมีค่าน้อยกว่า n\n >>> largest_divisor(15)\n 5\"\"\"\n","canonical_solution":" for i in reversed(range(n)):\n if n % i == 0:\n return i\n","test":"\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","entry_point":"largest_divisor"} -{"task_id":"HumanEval\/25","prompt":"from typing import List\n\n\ndef factorize(n: int) -> List[int]:\n \"\"\"ส่งคืนรายการปัจจัยเฉพาะของจำนวนเต็มที่กำหนดให้ตามลำดับจากน้อยไปหามาก ปัจจัยแต่ละตัวควรแสดงรายการตามจำนวนครั้งที่ปรากฏในการแยกตัวประกอบ จำนวนอินพุตควรเท่ากับผลคูณของปัจจัยทั้งหมด\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"factorize"} -{"task_id":"HumanEval\/26","prompt":"from typing import List\n\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\"จากรายการจำนวนเ��็ม ให้ลบองค์ประกอบทั้งหมดที่เกิดขึ้นมากกว่าหนึ่งครั้งออก รักษาลำดับขององค์ประกอบให้เหมือนเดิมกับในอินพุต\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\"\"\"\n","canonical_solution":" import collections\n c = collections.Counter(numbers)\n return [n for n in numbers if c[n] <= 1]\n","test":"\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","entry_point":"remove_duplicates"} -{"task_id":"HumanEval\/27","prompt":"\n\ndef flip_case(string: str) -> str:\n \"\"\"สำหรับสตริงที่กำหนด ให้เปลี่ยนตัวอักษรตัวพิมพ์เล็กเป็นตัวพิมพ์ใหญ่ และเปลี่ยนตัวอักษรตัวพิมพ์ใหญ่เป็นตัวพิมพ์เล็ก\n >>> flip_case('Hello')\n 'hELLO'\"\"\"\n","canonical_solution":" return string.swapcase()\n","test":"\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","entry_point":"flip_case"} -{"task_id":"HumanEval\/28","prompt":"from typing import List\n\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\"เชื่อมโยงรายการสตริงเข้าเป็นสตริงเดียว\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\"\"\"\n","canonical_solution":" return ''.join(strings)\n","test":"\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","entry_point":"concatenate"} -{"task_id":"HumanEval\/29","prompt":"from typing import List\n\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\"กรองรายการอินพุตของสตริงเฉพาะรายการที่เริ่มต้นด้วยคำนำหน้าที่กำหนดเท่านั้น\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\"\"\"\n","canonical_solution":" return [x for x in strings if x.startswith(prefix)]\n","test":"\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","entry_point":"filter_by_prefix"} -{"task_id":"HumanEval\/30","prompt":"\n\ndef get_positive(l: list):\n \"\"\"กลับเฉพาะตัวเลขบวกในรายการ\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]\"\"\"\n","canonical_solution":" return [e for e in l if e > 0]\n","test":"\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","entry_point":"get_positive"} -{"task_id":"HumanEval\/31","prompt":"\n\ndef is_prime(n):\n \"\"\"คืนค่าเป็นจริงถ้าตัวเลขที่กำหนดเป็นจำนวนเฉพาะ และคืนค่าเท็จถ้าไม่เป็นเช่นนั้น\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\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"is_prime"} -{"task_id":"HumanEval\/32","prompt":"import math\n\n\ndef poly(xs: list, x: float):\n \"\"\"ประเมินพหุนามที่มีค่าสัมประสิทธิ์ xs ที่จุด x ส่งคืน xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n\n >>>\"\"\"\n return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])\n\n\ndef find_zero(xs: list):\"\"\" xs are coefficients of a polynomial.\n find_zero find x such that poly(x) = 0.\n find_zero returns only only zero point, even if there are many.\n Moreover, find_zero only takes list xs having even number of coefficients\n and largest non zero coefficient as it guarantees\n a solution.\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\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"find_zero"} -{"task_id":"HumanEval\/33","prompt":"\n\ndef sort_third(l: list):\n \"\"\"ฟังก์ชันนี้ใช้รายการ l และส่งคืนรายการ l\' โดยที่ l\' จะเหมือนกับ l ในดัชนีที่หารด้วยสามไม่ลงตัว ในขณะที่ค่าของ l ในดัชนีที่หารด้วยสามลงตัวจะเท่ากับค่าของดัชนีที่สอดคล้องกันของ l แต่ได้รับการเรียงลำดับ\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]\"\"\"\n","canonical_solution":" l = list(l)\n l[::3] = sorted(l[::3])\n return l\n","test":"\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","entry_point":"sort_third"} -{"task_id":"HumanEval\/34","prompt":"\n\ndef unique(l: list):\n \"\"\"ส่งคืนองค์ประกอบที่ไม่ซ้ำกันที่เรียงลำดับในรายการ\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [0, 2, 3, 5, 9, 123]\"\"\"\n","canonical_solution":" return sorted(list(set(l)))\n","test":"\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","entry_point":"unique"} -{"task_id":"HumanEval\/35","prompt":"\n\ndef max_element(l: list):\n \"\"\"ส่งคืนองค์ประกอบสูงสุดในรายการ\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\"\"\"\n","canonical_solution":" m = l[0]\n for e in l:\n if e > m:\n m = e\n return m\n","test":"\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","entry_point":"max_element"} -{"task_id":"HumanEval\/36","prompt":"\n\ndef fizz_buzz(n: int):\n \"\"\"คืนจำนวนครั้งที่หลัก 7 ปรากฏในจำนวนเต็มที่น้อยกว่า n ซึ่งหารด้วย 11 หรือ 13 ลงตัว\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"fizz_buzz"} -{"task_id":"HumanEval\/37","prompt":"\n\ndef sort_even(l: list):\n \"\"\"ฟังก์ชันนี้ใช้รายการ l และส่งคืนรายการ l\' โดยที่ l\' จะเหมือนกับ l ในดัชนีคี่ ในขณะที่ค่าในดัชนีคู่จะเท่ากับค่าของดัชนีคู่ของ l แต่ได้รับการเรียงลำดับ\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"sort_even"} -{"task_id":"HumanEval\/38","prompt":"\n\ndef encode_cyclic(s: str):\n \"\"\"ส่งคืนสตริงที่เข้ารหัสโดยการหมุนเวียนกลุ่มอักขระสามตัว\n \"\"\"\n # split string to groups. Each of length 3.\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) \/\/ 3)]\n # cycle elements in each group. Unless group has fewer elements than 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 takes as input string encoded with encode_cyclic function. Returns decoded string.\"\"\"\n","canonical_solution":" return encode_cyclic(encode_cyclic(s))\n","test":"\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","entry_point":"decode_cyclic"} -{"task_id":"HumanEval\/39","prompt":"\n\ndef prime_fib(n: int):\n \"\"\"prime_fib คืนค่าตัวเลขที่ n ซึ่งเป็นตัวเลข Fibonacci และเป็นจำนวนเฉพาะด้วย\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\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"prime_fib"} -{"task_id":"HumanEval\/40","prompt":"\n\ndef triples_sum_to_zero(l: list):\n \"\"\"triples_sum_to_zero จะรับรายการจำนวนเต็มเป็นอินพุต โดยจะคืนค่า True หากมีองค์ประกอบที่แตกต่างกันสามองค์ประกอบในรายการที่ผลรวมเป็นศูนย์ และคืนค่า False หากไม่เป็นเช่นนั้น\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\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"triples_sum_to_zero"} -{"task_id":"HumanEval\/41","prompt":"\n\ndef car_race_collision(n: int):\n \"\"\"ลองนึกภาพถนนที่ตรงและยาวไม่มีที่สิ้นสุด มีรถยนต์ n คันขับจากซ้ายไปขวา ในขณะเดียวกัน รถยนต์อีก n คันขับจากขวาไปซ้าย รถทั้งสองคันเริ่มอยู่ห่างกันมาก รถทุกคันเคลื่อนที่ด้วยความเร็วเท่ากัน กล่าวกันว่ารถสองคันจะชนกันเมื่อรถที่เคลื่อนที่จากซ้ายไปขวาชนกับรถที่เคลื่อนที่จากขวาไปซ้าย อย่างไรก็ตาม รถทั้งสองคันมีความแข็งแรงและมั่นคงอย่างไม่มีที่สิ้นสุด ดังนั้น รถทั้งสองคันจึงยังคงเคลื่อนที่ตามวิถีของมันราวกับว่าไม่ได้ชนกัน ฟังก์ชันนี้จะแสดงผลจำนวนการชนดังกล่าว\n \"\"\"\n","canonical_solution":" return n**2\n","test":"\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","entry_point":"car_race_collision"} -{"task_id":"HumanEval\/42","prompt":"\n\ndef incr_list(l: list):\n \"\"\"กลับรายการที่มีองค์ประกอบเพิ่มขึ้นทีละ 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]\"\"\"\n","canonical_solution":" return [(e + 1) for e in l]\n","test":"\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","entry_point":"incr_list"} -{"task_id":"HumanEval\/43","prompt":"\n\ndef pairs_sum_to_zero(l):\n \"\"\"pairs_sum_to_zero จะรับรายการจำนวนเต็มเป็นอินพุต โดยจะคืนค่า True หากมีองค์ประกอบที่แตกต่างกันสององค์ประกอบในรายการซึ่งผลรวมเป็นศูนย์ และคืนค่า 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\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"pairs_sum_to_zero"} -{"task_id":"HumanEval\/44","prompt":"\n\ndef change_base(x: int, base: int):\n \"\"\"เปลี่ยนฐานตัวเลขของเลขอินพุต x ให้เป็นฐาน ส่งคืนการแสดงสตริงหลังจากการแปลง เลขฐานน้อยกว่า 10\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\"\"\"\n","canonical_solution":" ret = \"\"\n while x > 0:\n ret = str(x % base) + ret\n x \/\/= base\n return ret\n","test":"\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","entry_point":"change_base"} -{"task_id":"HumanEval\/45","prompt":"\n\ndef triangle_area(a, h):\n \"\"\"กำหนดความยาวด้านและพื้นที่ส่งคืนสูงสำหรับสามเหลี่ยม\n >>> triangle_area(5, 3)\n 7.5\"\"\"\n","canonical_solution":" return a * h \/ 2.0\n","test":"\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","entry_point":"triangle_area"} -{"task_id":"HumanEval\/46","prompt":"\n\ndef fib4(n: int):\n \"\"\"ลำดับตัวเลข Fib4 เป็นลำดับที่คล้ายกับลำดับ Fibbonacci ซึ่งกำหนดดังนี้: fib4(0) -> 0 fib4(1) -> 0 fib4(2) -> 2 fib4(3) -> 0 fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4) โปรดเขียนฟังก์ชันเพื่อคำนวณองค์ประกอบที่ n ของลำดับตัวเลข fib4 อย่างมีประสิทธิภาพ อย่าใช้การเรียกซ้ำ\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"fib4"} -{"task_id":"HumanEval\/47","prompt":"\n\ndef median(l: list):\n \"\"\"คืนค่ามัธยฐานขององค์ประกอบในรายการ l\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"median"} -{"task_id":"HumanEval\/48","prompt":"\n\ndef is_palindrome(text: str):\n \"\"\"ตรวจสอบว่าสตริงที่กำหนดเป็นพาลินโดรมหรือไม่\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False\"\"\"\n","canonical_solution":" for i in range(len(text)):\n if text[i] != text[len(text) - 1 - i]:\n return False\n return True\n","test":"\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","entry_point":"is_palindrome"} -{"task_id":"HumanEval\/49","prompt":"\n\ndef modp(n: int, p: int):\n \"\"\"ส่งกลับ 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\"\"\"\n","canonical_solution":" ret = 1\n for i in range(n):\n ret = (2 * ret) % p\n return ret\n","test":"\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","entry_point":"modp"} -{"task_id":"HumanEval\/50","prompt":"\n\ndef encode_shift(s: str):\n \"\"\"ส่งคืนสตริงที่เข้ารหัสโดยการเลื่อนอักขระแต่ละตัวทีละ 5 ตัวในตัวอักษร\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 takes as input string encoded with encode_shift function. Returns decoded string.\"\"\"\n","canonical_solution":" return \"\".join([chr(((ord(ch) - 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n","test":"\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","entry_point":"decode_shift"} -{"task_id":"HumanEval\/51","prompt":"\n\ndef remove_vowels(text):\n \"\"\"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'\"\"\"\n","canonical_solution":" return \"\".join([s for s in text if s.lower() not in [\"a\", \"e\", \"i\", \"o\", \"u\"]])\n","test":"\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","entry_point":"remove_vowels"} -{"task_id":"HumanEval\/52","prompt":"\n\ndef below_threshold(l: list, t: int):\n \"\"\"คืนค่า True ถ้าตัวเลขทั้งหมดในรายการ l ต่ำกว่าเกณฑ์ t\n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False\"\"\"\n","canonical_solution":" for e in l:\n if e >= t:\n return False\n return True\n","test":"\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","entry_point":"below_threshold"} -{"task_id":"HumanEval\/53","prompt":"\n\ndef add(x: int, y: int):\n \"\"\"บวกเลขสองตัวคือ x และ y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\"\"\"\n","canonical_solution":" return x + y\n","test":"\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","entry_point":"add"} -{"task_id":"HumanEval\/54","prompt":"\n\ndef same_chars(s0: str, s1: str):\n \"\"\"ตรวจสอบว่าคำสองคำมีอักขระเดียวกันหรือไม่\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\"\"\"\n","canonical_solution":" return set(s0) == set(s1)\n","test":"\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","entry_point":"same_chars"} -{"task_id":"HumanEval\/55","prompt":"\n\ndef fib(n: int):\n \"\"\"ส่งคืนเลข Fibonacci อันดับที่ n\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21\"\"\"\n","canonical_solution":" if n == 0:\n return 0\n if n == 1:\n return 1\n return fib(n - 1) + fib(n - 2)\n","test":"\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","entry_point":"fib"} -{"task_id":"HumanEval\/56","prompt":"\n\ndef correct_bracketing(brackets: str):\n \"\"\"วงเล็บเป็นสตริงของ \"<\" และ \">\" คืนค่า True หากวงเล็บเปิดทุกอันมีวงเล็บปิดที่สอดคล้องกัน\n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"correct_bracketing"} -{"task_id":"HumanEval\/57","prompt":"\n\ndef monotonic(l: list):\n \"\"\"ค่า Return 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\"\"\"\n","canonical_solution":" if l == sorted(l) or l == sorted(l, reverse=True):\n return True\n return False\n","test":"\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","entry_point":"monotonic"} -{"task_id":"HumanEval\/58","prompt":"\n\ndef common(l1: list, l2: list):\n \"\"\"ส่งคืนองค์ประกอบทั่วไปที่ไม่ซ้ำกันที่เรียงลำดับสำหรับสองรายการ\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]\n\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"common"} -{"task_id":"HumanEval\/59","prompt":"\n\ndef largest_prime_factor(n: int):\n \"\"\"ส่งคืนตัวประกอบเฉพาะที่ใหญ่ที่สุดของ n ถือว่า n > 1 และไม่ใช่ตัวประกอบเฉพาะ\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"largest_prime_factor"} -{"task_id":"HumanEval\/60","prompt":"\n\ndef sum_to_n(n: int):\n \"\"\"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\"\"\"\n","canonical_solution":" return sum(range(n + 1))\n","test":"\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","entry_point":"sum_to_n"} -{"task_id":"HumanEval\/61","prompt":"\n\ndef correct_bracketing(brackets: str):\n \"\"\"วงเล็บเป็นสตริงของ \"(\" และ \")\" คืนค่า True หากวงเล็บเปิดทุกอันมีวงเล็บปิดที่สอดคล้องกัน\n >>> correct_bracketing(\"(\")\n False\n >>> correct_bracketing(\"()\")\n True\n >>> correct_bracketing(\"(()())\")\n True\n >>> correct_bracketing(\")(()\")\n False\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"correct_bracketing"} -{"task_id":"HumanEval\/62","prompt":"\n\ndef derivative(xs: list):\n \"\"\"xs แทนค่าสัมประสิทธิ์ของพหุนาม xs[0] + xs[1] * x + xs[2] * x^2 + .... ส่งกลับอนุพันธ์ของพหุนามนี้ในรูปแบบเดียวกัน\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\"\"\"\n","canonical_solution":" return [(i * x) for i, x in enumerate(xs)][1:]\n","test":"\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","entry_point":"derivative"} -{"task_id":"HumanEval\/63","prompt":"\n\ndef fibfib(n: int):\n \"\"\"ลำดับตัวเลข FibFib เป็นลำดับที่คล้ายกับลำดับ Fibbonacci ซึ่งกำหนดดังนี้: fibfib(0) == 0 fibfib(1) == 0 fibfib(2) == 1 fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3) โปรดเขียนฟังก์ชันเพื่อคำนวณองค์ประกอบที่ n ของลำดับตัวเลข FibFib อย่างมีประสิทธิภาพ\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\"\"\"\n","canonical_solution":" 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","test":"\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","entry_point":"fibfib"} -{"task_id":"HumanEval\/64","prompt":"\nFIX = \"\"\"\nAdd more test cases.\n\"\"\"\n\ndef vowels_count(s):\n \"\"\"เขียนฟังก์ชัน vowels_count ซึ่งรับสตริงที่แสดงคำเป็นอินพุตและส่งคืนจำนวนสระในสตริง สระในกรณีนี้คือ \'a\', \'e\', \'i\', \'o\', \'u\' ในที่นี้ \'y\' ก็เป็นสระเช่นกัน แต่จะต้องอยู่ท้ายคำที่กำหนดเท่านั้น ตัวอย่าง:\n >>> vowels_count(\"abcde\")\n 2\n >>> vowels_count(\"ACEDY\")\n 3\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"vowels_count"} -{"task_id":"HumanEval\/65","prompt":"\ndef circular_shift(x, shift):\n \"\"\"การเลื่อนตัวเลขของจำนวนเต็ม x แบบวงกลม เลื่อนตัวเลขไปทางขวาโดยการเลื่อน แล้วส่งคืนผลลัพธ์เป็นสตริง หากการเลื่อน > จำนวนตัวเลข ให้ส่งคืนตัวเลขที่ย้อนกลับ\n >>> circular_shift(12, 1)\n \"21\"\n >>> circular_shift(12, 2)\n \"12\"\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"circular_shift"} -{"task_id":"HumanEval\/66","prompt":"\ndef digitSum(s):\n \"\"\"งาน เขียนฟังก์ชันที่รับสตริงเป็นอินพุตและส่งคืนผ��รวมของรหัส ASCII ของอักขระตัวบนเท่านั้น ตัวอย่าง: digitSum(\"\") => 0 digitSum(\"abAB\") => 131 digitSum(\"abcCd\") => 67 digitSum(\"helloE\") => 69 digitSum(\"woArBld\") => 131 digitSum(\"aAaaaXa\") => 153\n \"\"\"\n","canonical_solution":" if s == \"\": return 0\n return sum(ord(char) if char.isupper() else 0 for char in s)\n","test":"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","entry_point":"digitSum"} -{"task_id":"HumanEval\/67","prompt":"\ndef fruit_distribution(s,n):\n \"\"\"ในงานนี้ คุณจะได้รับสตริงที่แสดงถึงจำนวนแอปเปิ้ลและส้มที่กระจายอยู่ในตะกร้าผลไม้ ตะกร้านี้ประกอบด้วยแอปเปิ้ล ส้ม และมะม่วง เมื่อกำหนดสตริงที่แสดงถึงจำนวนส้มและแอปเปิ้ลทั้งหมด และจำนวนเต็มที่แสดงถึงจำนวนผลไม้ทั้งหมดในตะกร้า ให้ส่งคืนจำนวนผลมะม่วงในตะกร้า ตัวอย่างเช่น fruit_distribution(\"5 apples and 6 oranges\", 19) ->19 - 5 - 6 = 8 fruit_distribution(\"0 apples and 1 oranges\",3) -> 3 - 0 - 1 = 2 fruit_distribution(\"2 apples and 3 oranges\", 100) -> 100 - 2 - 3 = 95 fruit_distribution(\"100 apples and 1 oranges\",120) -> 120 - 100 - 1 = 19\n \"\"\"\n","canonical_solution":" lis = list()\n for i in s.split(' '):\n if i.isdigit():\n lis.append(int(i))\n return n - sum(lis)\n","test":"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","entry_point":"fruit_distribution"} -{"task_id":"HumanEval\/68","prompt":"\ndef pluck(arr):\n \"\"\"\"เมื่อกำหนดอาร์เรย์ที่แสดงถึงสาขาของต้นไม้ที่มีโหนดจำนวนเต็มที่ไม่เป็นลบ งานของคุณคือเลือกโหนดหนึ่งและส่งคืน โหนดที่คัดมาควรเป็นโหนดที่มีค่าคู่ที่เล็กที่สุด หากพบโหนดหลายโหนดที่มีค่าคู่ที่เล็กที่สุดเท่ากัน ให้ส่งคืนโหนดที่มีดัชนีที่เล็กที่สุด โหนดที่คัดมาควรส่งคืนในรายการ [ smalest_value, ดัชนีของโหนดนั้น ] ถ้าไม่มีค่าคู่หรืออาร์เรย์ที่กำหนดว่างเปล่า ให้ส่งคืน [] ตัวอย่าง 1: อินพุต: [4,2,3] เอาต์พุต: [2, 1] คำอธิบาย: 2 มีค่าคู่ที่เล็กที่สุด และ 2 มีดัชนีที่เล็กที่สุด ตัวอย่าง 2: อินพุต: [1,2,3] เอาต์พุต: [2, 1] คำอธิบาย: 2 มีค่าคู่ที่เล็กที่สุด และ 2 มีดัชนีที่เล็กที่สุด ตัวอย่าง 3: อินพุต: [] เอาต์พุต: [] ตัวอย่าง 4: อินพุต: [5, 0, 3, 0, 4, 2] ผลลัพธ์: [0, 1] คำอธิบาย: 0 คือค่าที่เล็กที่สุด แต่มีศูนย์สองตัว ดังนั้นเราจะเลือกศูนย์ตัวแรกซึ่งมีดัชนีที่เล็กที่สุด ข้อจำกัด: * 1 <= nodes.length <= 10000 * 0 <= node.value\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"pluck"} -{"task_id":"HumanEval\/69","prompt":"\ndef search(lst):\n '''คุณจะได้รับรายการจำนวนเต็มบวกที่ไม่ว่าง ส่งคืนจำนวนเต็มที่มากที่สุดที่มากกว่าศูนย์และมีความถี่มากกว่าหรือเท่ากับค่าของจำนวนเต็มนั้นเอง ความถี่ของจำนวนเต็มคือจำนวนครั้งที่จำนวนเต็มนั้นปรากฏในรายการ หากไม่มีค่าดังกล่าว ให้ส่งคืน -1 ตัวอย่าง: search([4, 1, 2, 2, 3, 1]) == 2 search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3 search([5, 5, 4, 4, 4]) == -1\n '''\n","canonical_solution":" 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","test":"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","entry_point":"search"} -{"task_id":"HumanEval\/70","prompt":"\ndef strange_sort_list(lst):\n '''กำหนดให้รายการจำนวนเต็มแสดงรายการในลำดับที่แปลกประหลาด การเรียงลำดับที่แปลกประหลาดคือเมื่อคุณเริ่มต้นด้วยค่าต่ำสุด จากนั้นจึงเป็นค่าสูงสุดของจำนวนเต็มที่เหลือ จากนั้นจึงเป็นค่าต่ำสุด และเป็นเช่นนี้ไปเรื่อยๆ ตัวอย่าง: strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3] strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5] strange_sort_list([]) == []\n '''\n","canonical_solution":" 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\n","test":"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","entry_point":"strange_sort_list"} -{"task_id":"HumanEval\/71","prompt":"\ndef triangle_area(a, b, c):\n '''กำหนดความยาวของด้านทั้งสามของสามเหลี่ยม ส่งคืนพื้นที่ของสามเหลี่ยมที่ปัดเศษเป็นทศนิยม 2 ตำแหน่งหากด้านทั้งสามประกอบเป็นสามเหลี่ยมที่ถูกต้อง มิฉะนั้น ส่งคืน -1 ด้านทั้งสามประกอบเป็นสามเหลี่ยมที่ถูกต้องเมื่อผลรวมของด้านสองด้านใดๆ มากกว่าด้านที่สาม ตัวอย่าง: triangle_area(3, 4, 5) == 6.00 triangle_area(1, 2, 10) == -1\n '''\n","canonical_solution":" 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","test":"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","entry_point":"triangle_area"} -{"task_id":"HumanEval\/72","prompt":"\ndef will_it_fly(q,w):\n '''เขียนฟังก์ชันที่คืนค่า True หากวัตถุ q จะบิน และคืนค่า False หากไม่เป็นเช่นนั้น วัตถุ q จะบินได้หากมีความสมดุล (เป็นรายการพาลินโดรม) และผลรวมขององค์ประกอบน้อยกว่าหรือเท่ากับน้ำหนักสูงสุดที่เป็นไปได้ w ตัวอย่าง: will_it_fly([1, 2], 5) ➞ False # 1+2 น้อยกว่าน้ำหนักสูงสุดที่เป็นไปได้ แต่ไม่สมดุล will_it_fly([3, 2, 3], 1) ➞ False # มีความสมดุล แต่ 3+2+3 มากกว่าน้ำหนักสูงสุดที่เป็นไปได้ will_it_fly([3, 2, 3], 9) ➞ True # 3+2+3 น้อยกว่าน้ำหนักสูงสุดที่เป็นไปได้ และสมดุลแล้ว will_it_fly([3], 5) ➞ True # 3 น้อยกว่าน้ำหนักสูงสุดที่เป็นไปได้ และสมดุลแล้ว\n '''\n","canonical_solution":" if sum(q) > w:\n return False\n\n i, j = 0, len(q)-1\n while i true is_simple_power(2, 2) => true is_simple_power(8, 2) => true is_simple_power(3, 2) => false is_simple_power(3, 1) => false is_simple_power(5, 3) => false\n \"\"\"\n","canonical_solution":" if (n == 1): \n return (x == 1) \n power = 1\n while (power < x): \n power = power * n \n return (power == x) \n","test":"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","entry_point":"is_simple_power"} -{"task_id":"HumanEval\/77","prompt":"\ndef iscube(a):\n '''เขียนฟังก์ชันที่รับจำนวนเต็ม a และส่งคืนค่า True หากจำนวนเต็มนี้เป็นกำลังสามของจำนวนเต็มบางตัว หมายเหตุ: คุณอาจถือว่าอินพุตนั้นถูกต้องเสมอ ตัวอย่าง: iscube(1) ==> True iscube(2) ==> False iscube(-1) ==> True iscube(64) ==> True iscube(0) ==> True iscube(180) ==> False\n '''\n","canonical_solution":" a = abs(a)\n return int(round(a ** (1. \/ 3))) ** 3 == a\n","test":"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","entry_point":"iscube"} -{"task_id":"HumanEval\/78","prompt":"\ndef hex_key(num):\n \"\"\"คุณได้รับมอบหมายให้เขียนฟังก์ชันที่รับเลขฐานสิบหกเป็นสตริงและนับจำนวนหลักฐานสิบหกที่เป็นจำนวนเฉพาะ (จำนวนเฉพาะหรือจำนวนเฉพาะคือจำนวนธรรมชาติที่มากกว่า 1 ซึ่งไม่ใช่ผลคูณของจำนวนธรรมชาติที่เล็กกว่าสองตัว) หลักฐานสิบหกคือ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F จำนวนเฉพาะคือ 2, 3, 5, 7, 11, 13, 17,... ดังนั้นคุณต้องกำหนดจำนวนหลักต่อไปนี้: 2, 3, 5, 7, B (= ทศนิยม 11), D (= ทศนิยม 13) หมายเหตุ: คุณอาจถือว่าอินพุตถูกต้องเสมอหรือเป็นสตริงว่าง และสัญลักษณ์ A, B, C, D, E, F เป็นตัวพิมพ์ใหญ่เสมอ ตัวอย่าง: สำหรับ num = \"AB\" ผลลัพธ์ควรเป็น 1 สำหรับ num = \"1077E\" ผลลัพธ์ควรเป็น 2 สำหรับ num = \"ABED1A33\" ผลลัพธ์ควรเป็น 4 สำหรับ num = \"123456789ABCDEF0\" ผลลัพธ์ควรเป็น 6 สำหรับ num = \"2020\" ผลลัพธ์ควรเป็น 2\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"hex_key"} -{"task_id":"HumanEval\/79","prompt":"\ndef decimal_to_binary(decimal):\n \"\"\"คุณจะได้รับตัวเลขในรูปแบบทศนิยม และงานของคุณคือการแปลงตัวเลขดังกล่าวเป็นรูปแบบไบนารี ฟังก์ชันควรส่งคืนสตริง โดยแต่ละอักขระจะแสดงเป็นเลขฐานสอง อักขระแต่ละตัวในสตริงจะเป็น \"0\" หรือ \"1\" โดยจะมีอักขระพิเศษอีกสองตัวคือ \"db\" ที่จุดเริ่มต้นและจุดสิ้นสุดของสตริง อักขระพิเศษเหล่านี้จะช่วยในการจัดรูปแบบ ตัวอย่าง: decimal_to_binary(15) # ส่งคืน \"db1111db\" decimal_to_binary(32) # ส่งคืน \"db100000db\"\n \"\"\"\n","canonical_solution":" return \"db\" + bin(decimal)[2:] + \"db\"\n","test":"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","entry_point":"decimal_to_binary"} -{"task_id":"HumanEval\/80","prompt":"\ndef is_happy(s):\n \"\"\"คุณจะได้รับสตริง s งานของคุณคือตรวจสอบว่าสตริงมีความสุขหรือไม่ สตริงจะมีความสุขหากมีความยาวอย่างน้อย 3 และตัวอักษรที่ต่อเนื่องกัน 3 ตัวนั้นแตกต่างกัน ตัวอย่างเช่น: is_happy(a) => False is_happy(aa) => False is_happy(abcd) => True is_happy(aabb) => False is_happy(adb) => True is_happy(xyy) => False\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"is_happy"} -{"task_id":"HumanEval\/81","prompt":"\ndef numerical_letter_grade(grades):\n \"\"\"ตอนนี้เป็นสัปดาห์สุดท้ายของภาคการศึกษาและครูต้องให้เกรดกับนักเรียน ครูได้สร้างอัลกอริทึมสำหรับการให้เกรดของเธอเอง ปัญหาเดียวคือ ครูทำรหัสที่ใช้ในการให้เกรดหายไป ครูได้ให้รายการ GPA ของนักเรียนบางคนแก่คุณ และคุณต้องเขียนฟังก์ชันที่สามารถแสดงรายการเกรดเป็นตัวอักษรโดยใช้ตารางต่อไปนี้: GPA | เกรดเป็นตัวอักษร 4.0 A+ > 3.7 A > 3.3 A- > 3.0 B+ > 2.7 B > 2.3 B- > 2.0 C+ > 1.7 C > 1.3 C- > 1.0 D+ > 0.7 D > 0.0 D- 0.0 E ตัวอย่าง: grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> [\'A+\', \'B\', \'C-\', \'C\', \'A-\']\n \"\"\"\n","canonical_solution":"\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","test":"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","entry_point":"numerical_letter_grade"} -{"task_id":"HumanEval\/82","prompt":"\ndef prime_length(string):\n \"\"\"เขียนฟังก์ชันที่รับสตริงและส่งคืน True หากความยาวสตริงเป็นจำนวนเฉพาะหรือส่งคืน False หากไม่เช่นนั้น ตัวอย่าง prime_length(\'Hello\') == True prime_length(\'abcdcba\') == True prime_length(\'kittens\') == True prime_length(\'orange\') == False\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"prime_length"} -{"task_id":"HumanEval\/83","prompt":"\ndef starts_one_ends(n):\n \"\"\"กำหนดจำนวนเต็มบวก n ให้ส่งคืนจำนวนเต็มบวก n หลักที่เริ่มต้นหรือลงท้ายด้วย 1\n \"\"\"\n","canonical_solution":" if n == 1: return 1\n return 18 * (10 ** (n - 2))\n","test":"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","entry_point":"starts_one_ends"} -{"task_id":"HumanEval\/84","prompt":"\ndef solve(N):\n \"\"\"กำหนดจำนวนเต็มบวก N ให้ส่งคืนผลรวมทั้งหมดของตัวเลขในรูปแบบไบนารี ตัวอย่าง สำหรับ N = 1000 ผลรวมของตัวเลขจะเท่ากับ 1 ผลลัพธ์ควรเป็น \"1\" สำหรับ N = 150 ผลรวมของตัวเลขจะเท่ากับ 6 ผลลัพธ์ควรเป็น \"110\" สำหรับ N = 147 ผลรวมของตัวเลขจะเท่ากับ 12 ผลลัพธ์ควรเป็น \"1100\" ตัวแปร: @N จำนวนเต็ม ข้อจำกัด: 0 ≤ N ≤ 10000 ผลลัพธ์: สตริงของตัวเลขไบนารี\n \"\"\"\n","canonical_solution":" return bin(sum(int(i) for i in str(N)))[2:]\n","test":"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","entry_point":"solve"} -{"task_id":"HumanEval\/85","prompt":"\ndef add(lst):\n \"\"\"กำหนดรายการจำนวนเต็มที่ไม่ว่าง lst. เพิ่มอ��ค์ประกอบคู่ที่มีดัชนีคี่ ตัวอย่าง: add([4, 2, 6, 7]) ==> 2\n \"\"\"\n","canonical_solution":" return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])\n","test":"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","entry_point":"add"} -{"task_id":"HumanEval\/86","prompt":"\ndef anti_shuffle(s):\n \"\"\"เขียนฟังก์ชันที่รับสตริงและส่งคืนเวอร์ชันที่เรียงลำดับของสตริงนั้น เวอร์ชันที่เรียงลำดับของสตริงคือสตริงที่คำทั้งหมด (คั่นด้วยช่องว่าง) จะถูกแทนที่ด้วยคำใหม่ โดยที่อักขระทั้งหมดจะเรียงตามลำดับจากน้อยไปมากตามค่า ASCII หมายเหตุ: คุณควรคงลำดับของคำและช่องว่างในประโยคไว้ ตัวอย่างเช่น: anti_shuffle(\'Hi\') ส่งคืน \'Hi\' anti_shuffle(\'hello\') ส่งคืน \'ehllo\' anti_shuffle(\'Hello World!!!\') ส่งคืน \'Hello !!!Wdlor\'\n \"\"\"\n","canonical_solution":" return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])\n","test":"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","entry_point":"anti_shuffle"} -{"task_id":"HumanEval\/87","prompt":"\ndef get_row(lst, x):\n \"\"\"คุณจะได้รับข้อมูล 2 มิติในรูปแบบรายการซ้อน ซึ่งคล้ายกับเมทริกซ์ อย่างไรก็ตาม ต่างจากเมทริกซ์ ตรงที่แต่ละแถวอาจมีจำนวนคอลัมน์ต่างกัน เมื่อกำหนด lst และจำนวนเต็ม x ให้ค้นหาจำนวนเต็ม x ในรายการ และส่งคืนรายการของทูเพิล [(x1, y1), (x2, y2) ...] โดยที่แต่ละทูเพิลเป็นพิกัด - (แถว คอลัมน์) เริ่มต้นด้วย 0 เรียงลำดับพิกัดเบื้องต้นตามแถวในลำดับจากน้อยไปมาก นอกจากนี้ ให้เรียงลำดับพิกัดของแถวตามคอลัมน์ในลำดับจากมากไปน้อย ตัวอย่าง: get_row([ [1,2,3,4,5,6], [1,2,3,4,1,6], [1,2,3,4,5,1] ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)] get_row([], 1) == [] get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"get_row"} -{"task_id":"HumanEval\/88","prompt":"\ndef sort_array(array):\n \"\"\"กำหนดอาร์เรย์ของจำนวนเต็มที่ไม่เป็นลบ ให้ส่งคืนสำเนาของอ��ร์เรย์ที่กำหนดหลังจากการเรียงลำดับ คุณจะเรียงลำดับอาร์เรย์ที่กำหนดในลำดับจากน้อยไปมาก หากผลรวม (ค่าดัชนีแรก ค่าดัชนีสุดท้าย) เป็นเลขคี่ หรือเรียงลำดับในลำดับจากมากไปน้อย หากผลรวม (ค่าดัชนีแรก ค่าดัชนีสุดท้าย) เป็นเลขคู่ หมายเหตุ: * อย่าเปลี่ยนแปลงอาร์เรย์ที่กำหนด ตัวอย่าง: * sort_array([]) => [] * sort_array([5]) => [5] * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5] * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]\n \"\"\"\n","canonical_solution":" return [] if len(array) == 0 else sorted(array, reverse= (array[0]+array[-1]) % 2 == 0) \n","test":"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","entry_point":"sort_array"} -{"task_id":"HumanEval\/89","prompt":"\ndef encrypt(s):\n \"\"\"สร้างฟังก์ชัน encrypt ที่รับสตริงเป็นอาร์กิวเมนต์และส่งคืนสตริงที่เข้ารหัสด้วยตัวอักษรที่หมุน ตัวอักษรควรหมุนในลักษณะที่ตัวอักษรเลื่อนลงสองคูณสองตำแหน่ง ตัวอย่างเช่น: encrypt(\'hi\') ส่งคืน \'lm\' encrypt(\'asdfghjkl\') ส่งคืน \'ewhjklnop\' encrypt(\'gf\') ส่งคืน \'kj\' encrypt(\'et\') ส่งคืน \'ix\'\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"encrypt"} -{"task_id":"HumanEval\/90","prompt":"\ndef next_smallest(lst):\n \"\"\"คุณจะได้รับรายการจำนวนเต็ม เขียนฟังก์ชัน next_smallest() ที่ส่งคืนองค์ประกอบที่เล็กเป็นอันดับ 2 ของรายการ ส่งคืน None หากไม่มีองค์ประกอบดังกล่าว next_smallest([1, 2, 3, 4, 5]) == 2 next_smallest([5, 1, 4, 3, 2]) == 2 next_smallest([]) == None next_smallest([1, 1]) == None\n \"\"\"\n","canonical_solution":" lst = sorted(set(lst))\n return None if len(lst) < 2 else lst[1]\n","test":"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","entry_point":"next_smallest"} -{"task_id":"HumanEval\/91","prompt":"\ndef is_bored(S):\n \"\"\"��ุณจะได้รับคำจำนวนหนึ่ง และงานของคุณคือนับจำนวนความเบื่อหน่าย ความเบื่อหน่ายคือประโยคที่เริ่มต้นด้วยคำว่า \"I\" ประโยคจะถูกคั่นด้วย \'.\', \'?\' หรือ \'!\' ตัวอย่างเช่น:\n >>> is_bored(\"Hello world\")\n 0\n >>> is_bored(\"The sky is blue. The sun is shining. I love this weather\")\n 1\"\"\"\n","canonical_solution":" import re\n sentences = re.split(r'[.?!]\\s*', S)\n return sum(sentence[0:2] == 'I ' for sentence in sentences)\n","test":"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","entry_point":"is_bored"} -{"task_id":"HumanEval\/92","prompt":"\ndef any_int(x, y, z):\n '''สร้างฟังก์ชันที่ใช้ตัวเลข 3 ตัว คืนค่าเป็นจริงหากตัวเลขตัวหนึ่งมีค่าเท่ากับผลรวมของอีกสองตัว และตัวเลขทั้งหมดเป็นจำนวนเต็ม คืนค่าเท็จในกรณีอื่น ๆ ตัวอย่าง any_int(5, 2, 7) ➞ True any_int(3, 2, 2) ➞ False any_int(3, -2, 1) ➞ True any_int(3.6, -2.2, 2) ➞ False\n '''\n","canonical_solution":" \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","test":"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","entry_point":"any_int"} -{"task_id":"HumanEval\/93","prompt":"\ndef encode(message):\n \"\"\"จงเขียนฟังก์ชันที่รับข้อความและเข้ารหัสโดยเปลี่ยนตัวพิมพ์ใหญ่-เล็กของตัวอักษรทั้งหมด และแทนที่สระทั้งหมดในข้อความด้วยตัวอักษรที่ปรากฏอยู่ข้างหน้าสระนั้น 2 ตำแหน่งในตัวอักษรภาษาอังกฤษ โดยถือว่ามีเฉพาะตัวอักษรเท่านั้น ตัวอย่าง:\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"encode"} -{"task_id":"HumanEval\/94","prompt":"\n\ndef skjkasdkd(lst):\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 สำหรับ lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] ผลลัพธ์ควรเป็น 25 สำหรับ lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] ผลลัพธ์ควรเป็น 13 สำหรับ lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] ผลลัพธ์ควรเป็น 11 สำหรับ lst = [0,81,12,3,1,21] ผลลัพธ์ควรเป็น 3 สำหรับ lst = [0,8,1,2,1,7] ผลลัพธ์ควรเป็น 7\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"skjkasdkd"} -{"task_id":"HumanEval\/95","prompt":"\ndef check_dict_case(dict):\n \"\"\"ให้พจนานุกรมส่งกลับค่า True หากคีย์ทั้งหมดเป็นสตริงตัวพิมพ์เล็กหรือคีย์ทั้งหมดเป็นสตริงตัวพิมพ์ใหญ่ มิฉะนั้นให้ส่งกลับค่า False ฟังก์ชันควรส่งกลับค่า False หากพจนานุกรมที่กำหนดว่างเปล่า ตัวอย่าง: check_dict_case({\"a\":\"apple\", \"b\":\"banana\"}) ควรส่งกลับค่า True check_dict_case({\"a\":\"apple\", \"A\":\"banana\", \"B\":\"banana\"}) ควรส่งกลับค่า False check_dict_case({\"a\":\"apple\", 8:\"banana\", \"a\":\"apple\"}) ควรส่งกลับค่า False check_dict_case({\"Name\":\"John\", \"Age\":\"36\", \"City\":\"Houston\"}) ควรส่งกลับค่า False check_dict_case({\"STATE\":\"NC\", \"ZIP\":\"12345\" }) ควรส่งกลับค่า True\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"check_dict_case"} -{"task_id":"HumanEval\/96","prompt":"\ndef count_up_to(n):\n \"\"\"ใช้ฟังก์ชันที่รับจำนวนเต็มที่ไม่เป็นลบและส่งคืนอาร์เรย์ของจำนวนเต็ม n แรกที่เป็นจำนวนเฉพาะและน้อยกว่า n ตัวอย่างเช่น: count_up_to(5) => [2,3] count_up_to(11) => [2,3,5,7] count_up_to(0) => [] count_up_to(20) => [2,3,5,7,11,13,17,19] count_up_to(1) => [] count_up_to(18) => [2,3,5,7,11,13,17]\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"count_up_to"} -{"task_id":"HumanEval\/97","prompt":"\ndef multiply(a, b):\n \"\"\"ดำเนินการฟังก์ชันที่รับจำนวนเต็มสองจำนวนและส่งคืนผลคูณของหลักหน่วยของจำนวนเต็มเหล่านั้นให้สมบูรณ์ สมมติว่าอินพุตนั้นถูกต้องเสมอ ตัวอย่าง: multiply(148, 412) ควรส่งคืน 16, multiply(19, 28) ควรส่งคืน 72, multiply(2020, 1851) ควรส่งคืน 0, multiply(14,-15) ควรส่งคืน 20\n \"\"\"\n","canonical_solution":" return abs(a % 10) * abs(b % 10)\n","test":"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","entry_point":"multiply"} -{"task_id":"HumanEval\/98","prompt":"\ndef count_upper(s):\n \"\"\"กำหนดสตริง s ให้นับจำนวนสระตัวพิมพ์ใหญ่ในดัชนีคู่ ตัวอย่างเช่น count_upper(\'aBCdEf\') คืนค่า 1 count_upper(\'abcdefg\') คืนค่า 0 count_upper(\'dBBE\') คืนค่า 0\n \"\"\"\n","canonical_solution":" count = 0\n for i in range(0,len(s),2):\n if s[i] in \"AEIOU\":\n count += 1\n return count\n","test":"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","entry_point":"count_upper"} -{"task_id":"HumanEval\/99","prompt":"\ndef closest_integer(value):\n '''สร้างฟังก์ชันที่รับค่า (สตริง) ที่แสดงถึงตัวเลขและส่งคืนจำนวนเต็มที่ใกล้เคียงที่สุดกับตัวเลขนั้น หากตัวเลขมีระยะห่างเท่ากันจากจำนวนเต็มสองจำนวน ให้ปัดเศษออกจากศูนย์ ตัวอย่าง >>> Closest_integer(\"10\") 10 >>> Closest_integer(\"15.3\") 15 หมายเหตุ: การปัดเศษออกจากศูนย์หมายความว่าหากตัวเลขที่กำหนดมีระยะห่างเท่ากันจากจำนวนเต็มสองจำนวน จำนวนที่คุณควรส่งคืนคือจำนวนที่อยู่ห่างจากศูนย์มากที่สุด ตัวอย่างเช่น Closest_integer(\"14.5\") ควรส่งคืน 15 และ Closest_integer(\"-14.5\") ควรส่งคืน -15\n '''\n","canonical_solution":" 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","test":"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","entry_point":"closest_integer"} -{"task_id":"HumanEval\/100","prompt":"\ndef make_a_pile(n):\n \"\"\"เมื่อกำหนดจำนวนเต็มบวก n คุณต้องสร้างกองหิน n ระดับ ระดับแรกมีหิน n ก้อน จำนวนหินในระดับถัดไปคือ - จำนวนคี่ถัดไปถ้า n เป็นคี่ - จำนวนคู่ถัดไปถ้า n เป็นคู่ ส่งคืนจำนวนหินในแต่ละระดับในรายการ โดยที่องค์ประกอบที่ดัชนี i แสดงถึงจำนวนหินในระดับ (i+1) ตัวอย่าง:\n >>> make_a_pile(3)\n [3, 5, 7]\"\"\"\n","canonical_solution":" return [n + 2*i for i in range(n)]\n","test":"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","entry_point":"make_a_pile"} -{"task_id":"HumanEval\/101","prompt":"\ndef words_string(s):\n \"\"\"คุณจะได้รับสตริงคำที่คั่นด้วยเครื่องหมายจุลภาคหรือช่องว่าง งานของคุณคือแยกสตริงออกเป็นคำและส่งคืนอาร์เรย์ของคำเหล่านั้น ตัวอย่างเช่น: words_string(\"Hi, my name is John\") == [\"Hi\", \"my\", \"name\", \"is\", \"John\"] words_string(\"One, two, three, four, five, six\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"words_string"} -{"task_id":"HumanEval\/102","prompt":"\ndef choose_num(x, y):\n \"\"\"ฟังก์ชันนี้ใช้ค่า x และ y เป็นจำนวนบวกสองค่า และส่งคืนจำนวนเต็มคู่ที่มากที่สุดที่อยู่ในช่วง [x, y] รวม หากไม่มีค่าดังกล่าว ฟังก์ชันควรส่งคืน -1 ตัวอย่างเช่น: choose_num(12, 15) = 14 choose_num(13, 12) = -1\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"choose_num"} -{"task_id":"HumanEval\/103","prompt":"\ndef rounded_avg(n, m):\n \"\"\"คุณได้รับจำนวนเต็มบวกสองจำนวนคือ n และ m และงานของคุณคือคำนวณค่าเฉลี่ยของจำนวนเต็มตั้งแต่ n ถึง m (รวมทั้ง n และ m) ปัดเศษคำตอบเป็นจำนวนเต็มที่ใกล้เคียงที่สุดและแปลงเป็นเลขฐานสอง หาก n มากกว่า m ให้ส่งคืน -1 ตัวอย่าง: rounded_avg(1, 5) => \"0b11\" rounded_avg(7, 5) => -1 rounded_avg(10, 20) => \"0b1111\" rounded_avg(20, 33) => \"0b11010\"\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"rounded_avg"} -{"task_id":"HumanEval\/104","prompt":"\ndef unique_digits(x):\n \"\"\"กำหนดรายการของจำนวนเต็มบวก x ให้ส่งคืนรายการที่เรียงลำดับขององค์ประกอบทั้งหมดที่ไม่มีเลขคู่ หมายเหตุ: รายการที่ส่งคืนควรเรียงลำดับตามลำดับเพิ่มขึ้น ตัวอย่างเช่น:\n >>> unique_digits([15, 33, 1422, 1])\n [1, 15, 33]\n >>> unique_digits([152, 323, 1422, 10])\n []\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"unique_digits"} -{"task_id":"HumanEval\/105","prompt":"\ndef by_length(arr):\n \"\"\"กำหนดอาร์เรย์ของจำนวนเต็ม ให้เรียงลำดับจำนวนเต็มที่อยู่ระหว่าง 1 ถึง 9 รวมทั้งหมด ย้อนกลับอาร์เรย์ผลลัพธ์ แล้วแทนที่แต่ละหลักด้วยชื่อที่สอดคล้องกันจาก \"หนึ่ง\" \"สอง\" \"สาม\" \"สี่\" \"ห้า\" \"หก\" \"เจ็ด\" \"แปด\" \"เก้า\" ตัวอย่���ง: arr = [2, 1, 1, 4, 5, 8, 2, 3] -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8] -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1] return [\"Eight\", \"Five\", \"Four\", \"Three\", \"Two\", \"Two\", \"One\", \"One\"] ถ้าอาร์เรย์ว่างเปล่า ให้ส่งคืนอาร์เรย์ว่าง: arr = [] return [] ถ้าอาร์เรย์มีตัวเลขแปลกๆ ให้ละเว้น: arr = [1, -1 , 55] -> sort arr -> [-1, 1, 55] -> reverse arr -> [55, 1, -1] return = [\'One\']\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"by_length"} -{"task_id":"HumanEval\/106","prompt":"\ndef f(n):\n \"\"\"นำฟังก์ชัน f ที่รับ n เป็นพารามิเตอร์มาใช้งาน และส่งคืนรายการขนาด n โดยที่ค่าขององค์ประกอบที่ดัชนี i จะเป็นแฟกทอเรียลของ i หาก i เป็นเลขคู่ หรือเป็นผลรวมของตัวเลขตั้งแต่ 1 ถึง i ในกรณีอื่น i เริ่มจาก 1 แฟกทอเรียลของ i คือการคูณตัวเลขตั้งแต่ 1 ถึง i (1 * 2 * ... * i) ตัวอย่าง: f(5) == [1, 2, 6, 24, 15]\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"f"} -{"task_id":"HumanEval\/107","prompt":"\ndef even_odd_palindrome(n):\n \"\"\"กำหนดจำนวนเต็มบวก n ให้ส่งคืนทูเพิลที่มีจำนวนพาลินโดรมจำนวนเต็มคู่และคี่ที่อยู่ในช่วง (1, n) รวม ตัวอย่าง 1: อินพุต: 3 เอาต์พุต: (1, 2) คำอธิบาย: พาลินโดรมจำนวนเต็มคือ 1, 2, 3 โดยหนึ่งในนั้นเป็นจำนวนคู่ และอีกสองอันเป็นจำนวนคี่ ตัวอย่าง 2: อินพุต: 12 เอาต์พุต: (4, 6) คำอธิบาย: พาลินโดรมจำนวนเต็มคือ 1, 2, 3, 4, 5, 6, 7, 8, 9, 11 โดยสี่อันเป็นจำนวนคู่ และอีก 6 อันเป็นจำนวนคี่ หมายเหตุ: 1. 1 <= n <= 10^3 2. ทูเพิลที่ส่งคืนมีจำนวนพาลินโดรมจำนวนเต็มคู่และคี่ตามลำดับ\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"even_odd_palindrome"} -{"task_id":"HumanEval\/108","prompt":"\ndef count_nums(arr):\n \"\"\"เขียนฟังก์ชัน count_nums ซึ่งรับอาร์เรย์ของจำนวนเต็ม และส่งคืนจำนวนองค์ประกอบที่ผลรวมของตัวเลข > 0 หากตัวเลขเป็นค่าลบ ตัวเลขที่มีเครื่องหมายตัวแรกจะเป็นค่าลบ เช่น -123 มีตัวเลขที่มีเครื่องหมายคือ -1, 2 และ 3\n >>> count_nums([]) == 0\n >>> count_nums([-1, 11, -11]) == 1\n >>> count_nums([1, 1, 2]) == 3\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"count_nums"} -{"task_id":"HumanEval\/109","prompt":"\ndef move_one_ball(arr):\n \"\"\"เรามีอาร์เรย์ \'arr\' ของจำนวนเต็ม N ตัว arr[1], arr[2], ..., arr[N] ตัวเลขในอาร์เรย์จะถูกเรียงลำดับแบบสุ่ม งานของคุณคือตรวจสอบว่าเป็นไปได้หรือไม่ที่จะเรียงลำดับอาร์เรย์ในลำดับที่ไม่ลดลงโดยดำเนินการต่อไปนี้กับอาร์เรย์ที่กำหนด: คุณสามารถเลื่อนไปทางขวาได้หลายครั้งเท่าที่ต้องการ การเลื่อนไปทางขวาหนึ่งครั้งหมายถึงการเลื่อนองค์ประกอบทั้งหมดในอาร์เรย์ไปหนึ่งตำแหน่งในทิศทางที่ถูกต้อง องค์ประกอบสุดท้ายของอาร์เรย์จะย้ายไปที่ตำแหน่งเริ่มต้นในอาร์เรย์ เช่น ดัชนีที่ 0 หากสามารถรับอาร์เรย์ที่เรียงลำดับได้โดยดำเนินการข้างต้น ให้ส่งคืนค่า True มิฉะนั้นให้ส่งคืนค่า False หากอาร์เรย์ที่กำหนดว่างเปล่า ให้ส่งคืนค่า True หมายเหตุ: รายการที่กำหนดให้มีองค์ประกอบที่ไม่ซ้ำกันอย่างแน่นอน ตัวอย่างเช่น: move_one_ball([3, 4, 5, 1, 2])==>True คำอธิบาย: โดยการเลื่อนไปทางขวา 2 ครั้ง จะทำให้ได้ลำดับที่ไม่ลดลงสำหรับอาร์เรย์ที่กำหนด move_one_ball([3, 5, 4, 1, 2])==>เท็จ คำอธิบาย: ไม่สามารถรับลำดับที่ไม่ลดลงสำหรับอาร์เรย์ที่กำหนดได้โดยดำเนินการเลื่อนไปทางขวาจำนวนใดๆ ก็ได้\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"move_one_ball"} -{"task_id":"HumanEval\/110","prompt":"\ndef exchange(lst1, lst2):\n \"\"\"ในปัญหานี้ คุณจะใช้ฟังก์ชันที่รับรายการตัวเลขสองรายการ และพิจารณาว่าเป็นไปได้หรือไม่ที่จะทำการแลกเปลี่ยนองค์ประกอบระหว่างรายการเหล่านั้นเพื่อทำให้ lst1 เป็นรายการของตัวเลขคู่เท่านั้น ไม่มีข้อจำกัดเกี่ยวกับจำนวนองค์ประกอบที่แลกเปลี่ยนระหว่าง lst1 และ lst2 หากสามารถแลกเปลี่ยนองค์ประกอบระหว่าง lst1 และ lst2 เพื่อทำให้องค์ประกอบทั้งหมดของ lst1 เป็นเลขคู่ ให้ส่งคืน \"YES\" มิฉะนั้น ให้ส่งคืน \"NO\" ตัวอย่างเช่น: exchange([1, 2, 3, 4], [1, 2, 3, 4]) => \"YES\" exchange([1, 2, 3, 4], [1, 5, 3, 4]) => \"NO\" ถือว่ารายการอินพุตจะไม่ว่างเปล่า\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"exchange"} -{"task_id":"HumanEval\/111","prompt":"\ndef histogram(test):\n \"\"\"กำหนดสตริงที่แสดงถึงตัวอักษรตัวเล็กที่คั่นด้วยช่องว่าง ให้ส่งคืนพจนานุกรมของตัวอักษรที่มีการทำซ้ำมากที่สุดและมีจำนวนที่สอดคล้องกัน หากมีตัวอักษรหลายตัวปรากฏเหมือนกัน ให้ส่งคืนทั้งหมด ตัวอย่าง: histogram(\'ab c\') == {\'a\': 1, \'b\': 1, \'c\': 1} histogram(\'abb a\') == {\'a\': 2, \'b\': 2} histogram(\'abca b\') == {\'a\': 2, \'b\': 2} histogram(\'bbbb a\') == {\'b\': 4} histogram(\'\') == {}\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"histogram"} -{"task_id":"HumanEval\/112","prompt":"\ndef reverse_delete(s,c):\n \"\"\"งาน เราได้รับสตริง 2 ตัวคือ s และ c คุณต้องลบตัวอักษรทั้งหมดใน s ที่เท่ากับตัวอักษรใดๆ ใน c จากนั้นตรวจสอบว่าสตริงผลลัพธ์เป็นพาลินโดรมหรือไม่ สตริงจะถูกเรียกว���าพาลินโดรมหากอ่านแบบย้อนกลับและไปข้างหน้าเหมือนกัน คุณควรส่งคืนทูเพิลที่มีสตริงผลลัพธ์และค่า True\/False สำหรับการตรวจสอบ ตัวอย่าง สำหรับ s = \"abcde\", c = \"ae\" ผลลัพธ์ควรเป็น (\'bcd\',False) สำหรับ s = \"abcdef\", c = \"b\" ผลลัพธ์ควรเป็น (\'acdef\',False) สำหรับ s = \"abcdedcba\", c = \"ab\" ผลลัพธ์ควรเป็น (\'cdedc\',True)\n \"\"\"\n","canonical_solution":" s = ''.join([char for char in s if char not in c])\n return (s,s[::-1] == s)\n","test":"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","entry_point":"reverse_delete"} -{"task_id":"HumanEval\/113","prompt":"\ndef odd_count(lst):\n \"\"\"ให้รายการสตริงที่มีเฉพาะตัวเลข ให้ส่งคืนรายการ องค์ประกอบ i แต่ละตัวของเอาต์พุตควรเป็น \"จำนวนองค์ประกอบคี่ในสตริง i ของอินพุต\" โดยที่ i ทั้งหมดควรถูกแทนที่ด้วยจำนวนหลักคี่ในสตริงที่ i ของอินพุต\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.\"]\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"odd_count"} -{"task_id":"HumanEval\/114","prompt":"\ndef minSubArraySum(nums):\n \"\"\"กำหนดอาร์เรย์ของจำนวนเต็ม nums หาผลรวมขั้นต่ำของอาร์เรย์ย่อยของ nums ที่ไม่ว่าง ตัวอย่าง minSubArraySum([2, 3, 4, 1, 2, 4]) == 1 minSubArraySum([-1, -2, -3]) == -6\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"minSubArraySum"} -{"task_id":"HumanEval\/115","prompt":"\ndef max_fill(grid, capacity):\n import math\n \"\"\"คุณจะได้รับตารางบ่อน้ำรูปสี่เหลี่ยมผืนผ้า แต่ละแถวแทนบ่อน้ำ 1 บ่อ และแต่ละบ่อน้ำในแถวแทนน้ำ 1 หน่วย แต่ละบ่อน้ำจะมีถังที่สอดคล้องกันซึ่งใช้สำหรับตักน้ำออกจากบ่อ และถังทั้งหมดจะมีความจุเท่ากัน หน้าที่ของคุณคือใช้ถังเพื่อเทน้ำออกจากบ่อ กำหนดจำนวนครั้งที่คุณต้องการลดถังลง ตัวอย่างที่ 1: อินพุต: grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]] bucket_capacity : 1 เอาต์พุต: 6 ตัวอย่างที่ 2: อินพุต: grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]] bucket_capacity : 2 เอาต์พุต: 5 ตัวอย่างที่ 3: อินพุต: grid : [[0,0,0], [0,0,0]] bucket_capacity : 5 เอาต์พุต: 0 ข้อจำกัด: * บ่อน้ำทั้งหมดมีความยาวเท่ากัน * 1 <= grid.length <= 10^2 * 1 <= grid[:,1].length <= 10^2 * grid[i][j] -> 0 | 1 * 1 <= ความจุ <= 10\n \"\"\"\n","canonical_solution":" return sum([math.ceil(sum(arr)\/capacity) for arr in grid])\n","test":"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","entry_point":"max_fill"} -{"task_id":"HumanEval\/116","prompt":"\ndef sort_array(arr):\n \"\"\"ใน Kata นี้ คุณต้องเรียงลำดับอาร์เรย์ของจำนวนเต็มที่ไม่เป็นลบตามจำนวนเลขฐานสองที่แสดงเป็นเลขฐานสองจากน้อยไปมาก สำหรับจำนวนเลขฐานสองที่ใกล้เคียงกัน ให้เรียงลำดับตามค่าทศนิยม ซึ่งจะต้องดำเนินการดังนี้:\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]\"\"\"\n","canonical_solution":" return sorted(sorted(arr), key=lambda x: bin(x)[2:].count('1'))\n","test":"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","entry_point":"sort_array"} -{"task_id":"HumanEval\/117","prompt":"\ndef select_words(s, n):\n \"\"\"เมื่อกำหนดสตริง s และจำนวนธรรมชาติ n คุณได้รับมอบหมายให้ใช้งานฟังก์ชันที่ส่งคืนรายการคำทั้งหมดจากสตริง s ที่มีพยัญชนะ n ตัวพอดี โดยคำเหล่านี้จะปรากฏตามลำดับในสตริง s หากสตริง s ว่างเปล่า ฟังก์ชันควรส่งคืนรายการว่างเปล่า หมายเหตุ: คุณอาจถือว่าสตริงอินพุตมีเฉพาะตัวอักษรและช่องว่างเท่านั้น ตัวอย่าง: select_words(\"Mary had a little lamb\", 4) ==> [\"little\"] select_words(\"Mary had a little lamb\", 3) ==> [\"Mary\", \"lamb\"] select_words(\"simple white space\", 2) ==> [] select_words(\"Hello world\", 4) ==> [\"world\"] select_words(\"Uncle sam\", 3) ==> [\"Uncle\"]\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"select_words"} -{"task_id":"HumanEval\/118","prompt":"\ndef get_closest_vowel(word):\n \"\"\"คุณจะได้รับคำศัพท์หนึ่งคำ งานของคุณคือค้นหาสระที่ใกล้เคียงที่สุดที่อยู่ระหว่างพยัญชนะสองตัวจากด้านขวาของคำ (ต้องตรงตามตัวพิมพ์ใหญ่-เล็ก) สระในตอนต้นและตอนท้ายไม่นับ ส่งคืนสตริงว่างหากคุณไม่พบสระที่ตรงตามเงื่อนไขข้างต้น คุณอาจถือว่าสตริงที่กำหนดมีเฉพาะตัวอักษรภาษาอังกฤษเท่านั้น ตัวอย่าง: get_closest_vowel(\"yogurt\") ==> \"u\" get_closest_vowel(\"FULL\") ==> \"U\" get_closest_vowel(\"quick\") ==> \"\" get_closest_vowel(\"ab\") ==> \"\"\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"get_closest_vowel"} -{"task_id":"HumanEval\/119","prompt":"\ndef match_parens(lst):\n '''คุณจะได้รับรายการสตริงสองสตริง โดยสตริงทั้งสองประกอบด้วยวงเล็บเปิด \'(\' หรือวงเล็บปิด \')\' เท่านั้น งานของคุณคือตรวจสอบว่าสามารถต่อสตริงทั้งสองเข้าด้วยกันในลำดับใด ๆ ได้หรือไม่ สตริงที่ได้จะดีหรือไม่ สตริง S จะถือว่าดีก็ต่อเมื่อวงเล็บทั้งหมดใน S สมดุลกัน ตัวอย่างเช่น สตริง \'(())()\' ดีในขณะที่สตริง \'())\' ไม่ดี ให้ส่งคืน \'ใช่\' หากมีวิธีสร้างสตริงที่ดี และส่งคืน \'ไม่ใช่\' หากไม่เป็นเช่นนั้น ตัวอย่าง: match_parens([\'()(\', \')\']) == \'ใช่\' match_parens([\')\', \')\']) == \'ไม่\'\n '''\n","canonical_solution":" 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","test":"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","entry_point":"match_parens"} -{"task_id":"HumanEval\/120","prompt":"\ndef maximum(arr, k):\n \"\"\"กำหนดอาร์เรย์ arr ของจำนวนเต็มและจำนวนเต็มบวก k ให้ส่งคืนรายการที่เรียงลำดับความยาว k พร้อมตัวเลขสูงสุด k ตัวใน arr ตัวอย่างที่ 1: อินพุต: arr = [-3, -4, 5], k = 3 เอาต์พุต: [-4, -3, 5] ตัวอย่างที่ 2: อินพุต: arr = [4, -4, 4], k = 2 เอาต์พุต: [4, 4] ตัวอย่างที่ 3: อินพุต: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1 เอาต์พุต: [2] หมายเหตุ: 1. ความยาวของอาร์เรย์จะอยู่ในช่วง [1, 1000] 2. องค์ประกอบในอาร์เรย์จะอยู่ในช่วง [-1000, 1000] 3. 0 <= k <= len(arr)\n \"\"\"\n","canonical_solution":" if k == 0:\n return []\n arr.sort()\n ans = arr[-k:]\n return ans\n","test":"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","entry_point":"maximum"} -{"task_id":"HumanEval\/121","prompt":"\ndef solution(lst):\n \"\"\"กำหนดรายการจำนวนเต็มที่ไม่ว่าง ให้ส่งคืนผลรวมขององค์ประกอบคี่ทั้งหมดที่อยู่ในตำแหน่งคู่ ตัวอย่าง solution([5, 8, 7, 1]) ==> 12 solution([3, 3, 3, 3, 3]) ==> 9 solution([30, 13, 24, 321]) ==>0\n \"\"\"\n","canonical_solution":" return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])\n","test":"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","entry_point":"solution"} -{"task_id":"HumanEval\/122","prompt":"\ndef add_elements(arr, k):\n \"\"\"กำหนดอาร์เรย์ของจำนวนเต็ม arr และจำนวนเต็ม k ที่ไม่ว่าง ให้ส่งคืนผลรวมขององค์ประกอบที่มีตัวเลขไม่เกินสองหลักจากองค์ประกอบ k แรกของ arr ตัวอย่าง: อินพุต: arr = [111,21,3,4000,5,6,7,8,9], k = 4 เอาต์พุต: 24 # ผลรวมของ 21 + 3 เงื่อนไข: 1. 1 <= len(arr) <= 100 2. 1 <= k <= len(arr)\n \"\"\"\n","canonical_solution":" return sum(elem for elem in arr[:k] if len(str(elem)) <= 2)\n","test":"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","entry_point":"add_elements"} -{"task_id":"HumanEval\/123","prompt":"\ndef get_odd_collatz(n):\n \"\"\"กำหนดจำนวนเต็มบวก n ให้ส่งคืนรายการที่เรียงลำดับแล้วที่มีจำนวนคี่ในลำดับคอลลาตซ์ สมมติฐานคอลลาตซ์เป็นสมมติฐานทางคณิตศาสตร์ที่เกี่ยวข้องกับลำดับที่กำหนดดังต่อไปนี้: เริ่มต้นด้วยจำนวนเต็มบวก n ใดๆ จากนั้นแต่ละเทอมจะได้มาจากเทอมก่อนหน้าดังนี้: ถ้าเทอมก่อนหน้าเป็นเลขคู่ เทอมถัดไปจะเป็นครึ่งหนึ่งของเทอมก่อนหน้า ถ้าเทอมก่อนหน้าเป็นเลขคี่ เทอมถัดไปจะเป็น 3 เท่าของเทอมก่อนหน้าบวก 1 สมมติฐานคือไม่ว่าค่า n จะเป็นเท่าใด ลำดับจะถึง 1 เสมอ หมายเหตุ: 1. Collatz(1) คือ [1] 2. ส่งคืนรายการที่เรียงลำดับจากน้อยไปมาก ตัวอย่างเช่น: get_odd_collatz(5) ส่งคืน [1, 5] # ลำดับคอลลาตซ์สำหรับ 5 คือ [5, 16, 8, 4, 2, 1] ดังนั้นเลขคี่จึงเป็น 1 และ 5 เท่านั้น\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"get_odd_collatz"} -{"task_id":"HumanEval\/124","prompt":"\ndef valid_date(date):\n \"\"\"คุณต้องเขียนฟังก์ชันที่ตรวจสอบสตริงวันที่ที่กำหนดและส่งคืนค่า True หากวันที่นั้นถูกต้อง มิฉะนั้นจะส่งคืนค่า False วันที่นั้นจะถูกต้องหากเป็นไปตามกฎทั้งหมดต่อไปนี้: 1. สตริงวันที่ไม่ว่างเปล่า 2. จำนวนวันไม่น้อยกว่า 1 วันหรือสูงกว่า 31 วันสำหรับเดือน 1,3,5,7,8,10,12 และจำนวนวันไม่น้อยกว่า 1 วันหรือสูงกว่า 30 วันสำหรับเดือน 4,6,9,11 และจำนวนวันต้องไม่น้อยกว่า 1 และไม่สูงกว่า 29 สำหรับเดือนที่ 2 3. เดือนไม่ควรน้อยกว่า 1 และไม่สูงกว่า 12 4. วันที่ควรอยู่ในรูปแบบ mm-dd-yyyy เช่น valid_date(\'03-11-2000\') => True valid_date(\'15-01-2012\') => False valid_date(\'04-0-2040\') => False valid_date(\'06-04-2020\') => True valid_date(\'06\/04\/2020\') => False\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"valid_date"} -{"task_id":"HumanEval\/125","prompt":"\ndef split_words(txt):\n '''กำหนดสตริงของคำ ให้ส่งคืนรายการคำที่แบ่งตามช่องว่าง ถ้าไม่มีช่องว่างในข้อความ คุณควรแบ่งด้วยเครื่องหมายจุลภาค \' ถ้าไม่มีเครื่องหมายจุลภาค คุณควรส่งคืนจำนวนตัวอักษรพิมพ์เล็กที่มีลำดับคี่ในตัวอักษร ord(\'a\') = 0, ord(\'b\') = 1, ... ord(\'z\') = 25 ตัวอย่าง split_words(\"Hello world!\") ➞ [\"Hello\", \"world!\"] split_words(\"Hello,world!\") ➞ [\"Hello\", \"world!\"] split_words(\"abcdef\") == 3\n '''\n","canonical_solution":" 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","test":"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","entry_point":"split_words"} -{"task_id":"HumanEval\/126","prompt":"\ndef is_sorted(lst):\n '''ให้แสดงรายการตัวเลข ให้ส่งคืนว่าตัวเลขเหล่านั้นเรียงลำดับจากน้อยไปมากหรือไม่ หากรายการมีตัวเลขเดียวกันซ้ำกันมากกว่า 1 ตัว ให้ส่งคืนค่า False สมมติว่าไม่มีตัวเลขติดลบและมีเพียงจำนวนเต็มเท่านั้น ตัวอย่าง is_sorted([5]) ➞ True is_sorted([1, 2, 3, 4, 5]) ➞ True is_sorted([1, 3, 2, 4, 5]) ➞ False is_sorted([1, 2, 3, 4, 5, 6]) ➞ True is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False is_sorted([1, 2, 2, 3, 3, 4]) ➞ True is_sorted([1, 2, 2, 2, 3, 4]) ➞ False\n '''\n","canonical_solution":" 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","test":"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","entry_point":"is_sorted"} -{"task_id":"HumanEval\/127","prompt":"\ndef intersection(interval1, interval2):\n \"\"\"คุณจะได้รับช่วงสองช่วง โดยแต่ละช่วงเป็นคู่ของจำนวนเต็ม ตัวอย่างเช่น ช่วง = (start, end) = (1, 2) ช่วงที่กำหนดเป็นช่วงปิด ซึ่งหมายความว่าช่วง (start, end) ประกอบด้วยทั้ง start และ end สำหรับแต่ละช่วงที่กำหนด จะถือว่า start น้อยกว่าหรือเท่ากับ end งานของคุณคือการกำหนดว่าความยาวของจุดตัดของช่วง���ั้งสองนี้เป็นจำนวนเฉพาะหรือไม่ ตัวอย่างเช่น จุดตัดของช่วง (1, 3), (2, 4) คือ (2, 3) ซึ่งมีความยาวเท่ากับ 1 ซึ่งไม่ใช่จำนวนเฉพาะ หากความยาวของจุดตัดเป็นจำนวนเฉพาะ ให้ส่งคืน \"YES\" มิฉะนั้น ให้ส่งคืน \"NO\" หากช่วงทั้งสองไม่ตัดกัน ให้ส่งคืน \"NO\" [อินพุต\/เอาต์พุต] ตัวอย่าง: จุดตัด ((1, 2), (2, 3)) ==> \"ไม่ใช่\" จุดตัด ((-1, 1), (0, 4)) ==> \"ไม่ใช่\" จุดตัด ((-3, -1), (-5, 5)) ==> \"ใช่\"\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"intersection"} -{"task_id":"HumanEval\/128","prompt":"\ndef prod_signs(arr):\n \"\"\"คุณจะได้รับอาร์เรย์ arr ของจำนวนเต็ม และคุณต้องส่งคืนผลรวมของขนาดของจำนวนเต็มคูณด้วยผลคูณของเครื่องหมายทั้งหมดของแต่ละจำนวนในอาร์เรย์ ซึ่งแสดงด้วย 1, -1 หรือ 0 หมายเหตุ: ส่งคืน None สำหรับ arr ที่ว่างเปล่า ตัวอย่าง:\n >>> prod_signs([1, 2, 2, -4]) == -9\n >>> prod_signs([0, 1]) == 0\n >>> prod_signs([]) == None\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"prod_signs"} -{"task_id":"HumanEval\/129","prompt":"\ndef minPath(grid, k):\n \"\"\"กำหนดตารางที่มี N แถวและ N คอลัมน์ (N >= 2) และจำนวนเต็มบวก k เซลล์แต่ละเซลล์ของตารางจะมีค่า จำนวนเต็มทุกจำนวนในช่วง [1, N * N] รวมอยู่ด้วยจะปรากฏบนเซลล์ของตารางเพียงครั้งเดียว คุณต้องค้นหาเส้นทางที่สั้นที่สุดของความยาว k ในตาราง คุณสามารถเริ่มต้นจากเซลล์ใดก็ได้ และในแต่ละขั้นตอน คุณสามารถย้ายไปยังเซลล์ข้างเคียงเซลล์ใดก็ได้ กล่าวอีกนัยหนึ่งคือ คุณสามารถไปยังเซลล์ที่แบ่งปันขอบกับเซลล์ปัจจุบันของคุณได้ โปรดทราบว่าเส้นทางที่มีความยาว k หมายถึงการเยี่ยมชมเซลล์ k พอดี (ไม่จำเป็นต้องแยกจากกัน) คุณไม่สามารถออกจากตารางได้ เส้นทาง A (ความยาว k) ถือว่าน้อยกว่าเส้นทาง B (ความยาว k) หากหลังจากสร้างรายการค่าตามลำดับในเซลล์ที่ A และ B ผ่าน (เรียกว่า lst_A และ lst_B) แล้ว lst_A จะน้อยกว่า lst_B ตามพจนานุกรม กล่าวอีกนัยหนึ่งคือ มีดัชนีจำนวนเต็ม i (1 <= i <= k) ที่ทำให้ lst_A[i] < lst_B[i] และสำหรับ j ใดๆ (1 <= j < i) เราจะได้ lst_A[j] = lst_B[j] รับประกันว่าคำตอบจะไม่ซ้ำกัน ส่งคืนรายการค่าตามลำดับในเซลล์ที่เส้นทางขั้นต่ำผ่าน ตัวอย่าง: อินพุต: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3 เอาต์พุต: [1, 2, 1] อินพุต: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1 เอาต์พุต: [1]\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"minPath"} -{"task_id":"HumanEval\/130","prompt":"\ndef tri(n):\n \"\"\"ทุกคนรู้จักลำดับฟีโบนัชชี ซึ่งนักคณิตศาสตร์ได้ศึกษาอย่างลึกซึ้งในช่วงสองศตวรรษที่ผ่านมา อย่างไรก็ตาม สิ่งที่ผู้คนไม่รู้ก็คือลำดับทริโบนัชชี ลำดับทริโบนัชชีถูกกำหนดโดยการเกิดซ้ำ: tri(1) = 3 tri(n) = 1 + n \/ 2 ถ้า n เป็นเลขคู่ tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1) ถ้า n เป็นเลขคี่ ตัวอย่างเช่น: tri(2) = 1 + (2 \/ 2) = 2 tri(4) = 3 tri(3) = tri(2) + tri(1) + tri(4) = 2 + 3 + 3 = 8 คุณได้รับเลขจำนวนเต็มที่ไม่เป็นลบ n คุณต้องส่งคืนรายการของตัวเลข n + 1 แรกของลำดับทริโบนัชชี ตัวอย่าง: tri(3) = [1, 3, 2, 8]\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"tri"} -{"task_id":"HumanEval\/131","prompt":"\ndef digits(n):\n \"\"\"กำหนดจำนวนเต็มบวก n ให้ส่งคืนผลคูณของหลักคี่ ส่งคืน 0 ถ้าหลักทั้งหมดเป็นเลขคู่ ตัวอย่างเช่น: digits(1) == 1 digits(4) == 0 digits(235) == 15\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"digits"} -{"task_id":"HumanEval\/132","prompt":"\ndef is_nested(string):\n '''สร้างฟังก์ชันที่รับสตริงเป็นอินพุตซึ่งประกอบด้วยวงเล็บเหลี่ยมเท่านั้น ฟังก์ชันควรส่งคืนค่า True ก็ต่อเมื่อมีลำดับย่อยที่ถูกต้องของวงเล็บซึ่งวงเล็บอย่างน้อยหนึ่งอันในลำดับย่อยนั้นซ้อนกัน is_nested(\'[[]]\') ➞ True is_nested(\'[[]]]]]]][[[[[]\') ➞ False is_nested(\'[][]\') ➞ False is_nested(\'[[][]\') ➞ False is_nested(\'[[][]]\') ➞ True is_nested(\'[[]][[\') ➞ True\n '''\n","canonical_solution":" 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","test":"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","entry_point":"is_nested"} -{"task_id":"HumanEval\/133","prompt":"\n\ndef sum_squares(lst):\n \"\"\"คุณจะได้รับรายการตัวเลข คุณต้องส่งคืนผลรวมของตัวเลขยกกำลังสองในรายการที่กำหนด ปัดเศษแต่ละองค์ประกอบในรายการเป็น int(Ceiling) บนสุดก่อน ตัวอย่าง: สำหรับ lst = [1,2,3] ผลลัพธ์ควรเป็น 14 สำหรับ lst = [1,4,9] ผลลัพธ์ควรเป็น 98 สำหรับ lst = [1,3,5,7] ผลลัพธ์ควรเป็น 84 สำหรับ lst = [1.4,4.2,0] ผลลัพธ์ควรเป็น 29 สำหรับ lst = [-2.4,1,1] ผลลัพธ์ควรเป็น 6\n \"\"\"\n","canonical_solution":" import math\n squared = 0\n for i in lst:\n squared += math.ceil(i)**2\n return squared\n","test":"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","entry_point":"sum_squares"} -{"task_id":"HumanEval\/134","prompt":"\ndef check_if_last_char_is_a_letter(txt):\n '''สร้างฟังก์ชันที่ส่งคืนค่า True หากอักขระตัวสุดท้ายของสตริงที่กำหนดเป็นอักขระตัวอักษรและไม่ใช่ส่วนหนึ่งของคำ และส่งคืนค่า False หากไม่เป็นเช่นนั้น หมายเหตุ: \"word\" คือกลุ่มอักขระที่คั่นด้วยช่องว่าง ตัวอย่าง: check_if_last_char_is_a_letter(\"apple pie\") ➞ False check_if_last_char_is_a_letter(\"apple pi e\") ➞ True check_if_last_char_is_a_letter(\"apple pi e \") ➞ False check_if_last_char_is_a_letter(\"\") ➞ False\n '''\n","canonical_solution":" \n check = txt.split(' ')[-1]\n return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False\n","test":"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","entry_point":"check_if_last_char_is_a_letter"} -{"task_id":"HumanEval\/135","prompt":"\ndef can_arrange(arr):\n \"\"\"สร้างฟังก์ชันที่ส่งคืนดัชนีที่ใหญ่ที่สุดขององค์ประกอบซึ่งไม่มากกว่าหรือเท่ากับองค์ประกอบก่อนหน้าทันที หากไม่มีองค์ประกอบดังกล่าว ให้ส่งคืน -1 อาร์เรย์ที่กำหนดจะไม่มีค่าซ้ำกัน ตัวอย่าง: can_arrange([1,2,4,3,5]) = 3 can_arrange([1,2,3]) = -1\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"largest_smallest_integers"} -{"task_id":"HumanEval\/137","prompt":"\ndef compare_one(a, b):\n \"\"\"สร้างฟังก์ชันที่ใช้จำนวนเต็ม จำนวนทศนิยม หรือสตริงที่แสดงถึงจำนวนจริง และส่งคืนตัวแปรที่มีค่ามากกว่าในประเภทตัวแปรที่กำหนด ส่งคืนค่า None หากค่าเท่ากัน หมายเหตุ: หากแสดงจำนวนจริงเป็นสตริง จุดทศนิยมอาจเป็น . หรือ , compare_one(1, 2.5) ➞ 2.5 compare_one(1, \"2,3\") ➞ \"2,3\" compare_one(\"5,1\", \"6\") ➞ \"6\" compare_one(\"1\", 1) ➞ None\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"compare_one"} -{"task_id":"HumanEval\/138","prompt":"\ndef is_equal_to_sum_even(n):\n \"\"\"ประเมินว่าตัวเลข n ที่กำหนดสามารถเขียนเป็นผลรวมของจำนวนคู่บวก 4 จำนวนพอดีหรือไม่ ตัวอย่าง is_equal_to_sum_even(4) == False is_equal_to_sum_even(6) == False is_equal_to_sum_even(8) == True\n \"\"\"\n","canonical_solution":" return n%2 == 0 and n >= 8\n","test":"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","entry_point":"is_equal_to_sum_even"} -{"task_id":"HumanEval\/139","prompt":"\ndef special_factorial(n):\n \"\"\"แฟกทอเรียลของบราซิลถูกกำหนดเป็น: brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! โดยที่ n > 0 ตัวอย่างเช่น:\n >>> special_factorial(4)\n 288\n\n The function will receive an integer as input and should return the special\n factorial of this integer.\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"special_factorial"} -{"task_id":"HumanEval\/140","prompt":"\ndef fix_spaces(text):\n \"\"\"กำหนดข้อความสตริง ให้แทนที่ช่องว่างทั้งหมดด้วยเครื่องหมายขีดล่าง และถ้าสตริงมีช่องว่างติดต่อกันมากกว่า 2 ช่องว่าง ให้แทนที่ช่องว่างติดต่อกันทั้งหมดด้วย - fix_spaces(\"Example\") == \"Example\" fix_spaces(\"Example 1\") == \"Example_1\" fix_spaces(\" Example 2\") == \"_Example_2\" fix_spaces(\" Example 3\") == \"_Example-3\"\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"fix_spaces"} -{"task_id":"HumanEval\/141","prompt":"\ndef file_name_check(file_name):\n \"\"\"สร้างฟังก์ชันที่รับสตริงที่แสดงชื่อไฟล์ และส่งคืน \'ใช่\' หากชื่อไฟล์ถูกต้อง และส่งกลับ \'ไม่ใช่\' หากไม่เป็นเช่นนั้น ชื่อไฟล์จะถือว่าถูกต้องก็ต่อเมื่อตรงตามเงื่อนไขต่อไปนี้ทั้งหมดเท่านั้น: - ชื่อไฟล์ไม่ควรมีตัวเลขเกินสามหลัก (\'0\'-\'9\') - ชื่อไฟล์มีจุด \".\' เพียงหนึ่งจุด - สตริงย่อยก่อนจุดไม่ควรว่างเปล่า และเริ่มต้นด้วยตัวอักษรจากภาษาละติน alphapet (\'a\'-\'z\' และ \'A\'-\'Z\') - สตริงย่อยหลังจุดควรเป็นอย่างใดอย่างหนึ่งจากนี้: [\'txt\', \'exe\', \'dll\'] ตัวอย่าง: file_name_check(\"example.txt\") # => \'Yes\' file_name_check(\"1example.dll\") # => \'No\' (ชื่อควรเริ่มต้นด้วยตัวอักษรละติน alphapet)\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"file_name_check"} -{"task_id":"HumanEval\/142","prompt":"\n\n\ndef sum_squares(lst):\n \"\"\"\" ฟังก์ชันนี้จะใช้รายการจำนวนเต็ม สำหรับรายการทั้งหมดในรายการ ฟังก์ชันจะต้องยกกำลังรายการจำนวนเต็มหากดัชนีของฟังก์ชันเป็นผลคูณของ 3 และจะยกกำลังรายการจำนวนเต็มหากดัชนีของฟังก์ชันเป็นผลคูณของ 4 และไม่ใช่เป็นผลคูณของ 3 ฟังก์ชันจะไม่เปลี่ยนแปลงรายการในรายการที่มีดัชนีไม่ใช่ผลคูณของ 3 หรือ 4 ฟังก์ชันจะส่งคืนผลรวมของรายการทั้งหมด ตัวอย่าง: สำหรับ lst = [1,2,3] ผลลัพธ์ควรเป็น 6 สำหรับ lst = [] ผลลัพธ์ควรเป็น 0 สำหรับ lst = [-1,-5,2,-1,-5] ผลลัพธ์ควรเป็น -126\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"sum_squares"} -{"task_id":"HumanEval\/143","prompt":"\ndef words_in_sentence(sentence):\n \"\"\"คุณจะได้รับสตริงที่แสดงถึงประโยค ประโยคประกอบด้วยคำบางคำที่คั่นด้วยช่องว่าง และคุณต้องส่งคืนสตริงที่มีคำจากประโยคเดิม ซึ่งความยาวเป็นจำนวนเฉพาะ ลำดับของคำในสตริงใหม่ควรเหมือนกับของเดิม ตัวอย่างที่ 1: อินพุต: ประโยค = \"This is a test\" เอาต์พุต: \"is\" ตัวอย่างที่ 2: อินพุต: ประโยค = \"lets go for swimming\" เอาต์พุต: \"go for\" ข้อจำกัด: * 1 <= len(sentence) <= 100 * ประโยคประกอบด้วยตัวอักษรเท่านั้น\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"words_in_sentence"} -{"task_id":"HumanEval\/144","prompt":"\ndef simplify(x, n):\n \"\"\"งานของคุณคือการใช้ฟังก์ชันที่จะทำให้นิพจน์ x * n ง่ายขึ้น ฟังก์ชันนี้จะคืนค่า True หาก x * n ประเมินผลเป็นจำนวนเต็ม และคืนค่า False หากไม่เช่นนั้น ทั้ง x และ n ต่างก็เป็นสตริงที่แสดงเศษส่วน และมีรูปแบบดังต่อไปนี้ - โดยที่ตัวเศษและตัวส่วนเป็นจำนวนเต็มบวกทั้งคู่ คุณสามารถถือว่า x และ n เป็นเศษส่วนที่ถูกต้อง และไม่มีศูนย์เป็นตัวส่วน simplify(\"1\/5\", \"5\/1\") = True simplify(\"1\/6\", \"2\/1\") = False simplify(\"7\/10\", \"10\/2\") = False\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"simplify"} -{"task_id":"HumanEval\/145","prompt":"\ndef order_by_points(nums):\n \"\"\"เขียนฟังก์ชันที่เรียงลำดับรายการจำนวนเต็มที่กำหนดตามลำดับจากน้อยไปมากตามผลรวมของตัวเลข หมายเหตุ: หากมีรายการหลายรายการที่ผลรวมของตัวเลขใกล้เคียงกัน ให้เรียงลำดับตามดัชนีในรายการเดิม ตัวอย่างเช่น:\n >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]\n >>> order_by_points([]) == []\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"order_by_points"} -{"task_id":"HumanEval\/146","prompt":"\ndef specialFilter(nums):\n \"\"\"เขียนฟังก์ชันที่รับอาร์เรย์ของตัวเลขเป็นอินพุตและส่งคืนจำนวนองค์ประกอบในอาร์เรย์ที่มากกว่า 10 และหลักแรกและหลักสุดท้ายของตัวเลขเป็นเลขคี่ (1, 3, 5, 7, 9) ตัวอย่างเช่น: specialFilter([15, -73, 14, -15]) => 1 specialFilter([33, -2, -3, 45, 21, 109]) => 2\n \"\"\"\n","canonical_solution":" \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","test":"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","entry_point":"specialFilter"} -{"task_id":"HumanEval\/147","prompt":"\ndef get_max_triples(n):\n \"\"\"คุณได้รับจำนวนเต็มบวก n คุณต้องสร้างอาร์เรย์จำนวนเต็ม a ที่มีความยาว n สำหรับแต่ละ i (1 ≤ i ≤ n) ค่าของ a[i] = i * i - i + 1 ส่งกลับจำนวนสาม (a[i], a[j], a[k]) ของ a โดยที่ i < j < k และ a[i] + a[j] + a[k] เป็นทวีคูณของ 3 ตัวอย่าง: อินพุต: n = 5 เอาต์พุต: 1 คำอธิบาย: a = [1, 3, 7, 13, 21] สามที่ถูกต้องคือ (1, 7, 13) เท่านั้น\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"get_max_triples"} -{"task_id":"HumanEval\/148","prompt":"\ndef bf(planet1, planet2):\n '''ในระบบสุริยะของเรามีดาวเคราะห์ 8 ดวง ดวงที่อยู่ใกล้ดวงอาทิตย์ที่สุดคือดาวพุธ ดวงถัดมาคือดาวศุกร์ จากนั้นคือโลก ดาวอังคาร ดาวพฤหัสบดี ดาวเสาร์ ดาวยูเรนัส ดาวเนปจูน เขียนฟังก์ชันที่รับชื่อดาวเคราะห์ 2 ดวงเป็นสตริง ได้แก่ planet1 และ planet2 ฟังก์ชันควรส่งคืนทูเพิลที่มีดาวเคราะห์ทั้งหมดที่มีวงโคจรอยู่ระหว่างวงโคจรของ planet1 และวงโคจรของ planet2 โดยเรียงลำดับตามระยะห่างจากดวงอาทิตย์ ฟังก์ชันควรส่งคืนทูเพิลว่างหาก planet1 หรือ planet2 ไม่ใช่ชื่อดาวเคราะห์ที่ถูกต้อง ตัวอย่าง bf(\"Jupiter\", \"Neptune\") ==> (\"Saturn\", \"Uranus\") bf(\"Earth\", \"Mercury\") ==> (\"Venus\") bf(\"Mercury\", \"Uranus\") ==> (\"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\")\n '''\n","canonical_solution":" 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","test":"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","entry_point":"bf"} -{"task_id":"HumanEval\/149","prompt":"\ndef sorted_list_sum(lst):\n \"\"\"เขียนฟังก์ชันที่ยอมรับรายการสตริงเป็นพารามิเตอร์ ลบสตริงที่มีความยาวคี่ และส่งคืนรายการผลลัพธ์ที่มีลำดับการเรียงลำดับ รายการจะเป็นรายการสตริงเสมอ ไม่ใช่เป็นอาร์เรย์ของตัวเลข และอาจมีรายการที่ซ้ำกันได้ ลำดับของรายการควรเรียงจากน้อยไปมากตามความยาวของคำแต่ละคำ และคุณควรส่งคืนรายการที่เรียงลำดับตามกฎนั้น หากคำสองคำมีความยาวเท่ากัน ให้เรียงลำดับรายการตามตัวอักษร ฟังก์ชันควรส่งคืนรายการสตริงที่เรียงลำดับแล้ว คุณอาจถือว่าคำทั้งหมดจะมีความยาวเท่ากัน ตัวอย่างเช่น: assert list_sort([\"aa\", \"a\", \"aaa\"]) => [\"aa\"] assert list_sort([\"ab\", \"a\", \"aaa\", \"cd\"]) => [\"ab\", \"cd\"]\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"sorted_list_sum"} -{"task_id":"HumanEval\/150","prompt":"\ndef x_or_y(n, x, y):\n \"\"\"โปรแกรมง่ายๆ ที่ควรส่งคืนค่าของ x หาก n เป็นจำนวนเฉพาะ และควรส่งคืนค่าของ y ในกรณีอื่น ตัวอย่าง: for x_or_y(7, 34, 12) == 34 for x_or_y(15, 8, 5) == 5\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"x_or_y"} -{"task_id":"HumanEval\/151","prompt":"\ndef double_the_difference(lst):\n '''กำหนดรายการตัวเลข ให้ส่งคืนผลรวมของกำลังสองของตัวเลขในรายการที่เป็นเลขคี่ ไม่ต้องสนใจตัวเลขที่เป็นจำนวนเต็มลบหรือไม่ใช่จำนวนเต็ม double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10 double_the_difference([-1, -2, 0]) == 0 double_the_difference([9, -2]) == 81 double_the_difference([0]) == 0 ถ้ารายการอินพุตว่างเปล่า ให้ส่งคืน 0\n '''\n","canonical_solution":" return sum([i**2 for i in lst if i > 0 and i%2!=0 and \".\" not in str(i)])\n","test":"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","entry_point":"double_the_difference"} -{"task_id":"HumanEval\/152","prompt":"\ndef compare(game,guess):\n \"\"\"ฉันคิดว่าเราทุกคนคงจำความรู้สึกนั้นได้เมื่อผลลัพธ์ของเหตุการณ์ที่รอคอยมานานในที่สุดก็ถูกเปิดเผย ความรู้สึกและความคิดที่คุณมีในขณะนั้นคุ้มค่าแก่การจดบันทึกและเปรียบเทียบอย่างแน่นอน หน้าที่ของคุณคือตรวจสอบว่าบุคคลนั้นเดาผลลัพธ์ของการจับคู่จำนวนหนึ่งได้ถูกต้องหรือไม่ คุณจะได้รับอาร์เรย์คะแนนและการเดาสองชุดที่มีความยาวเท่ากัน โดยแต่ละดัชนีจะแสดงการจับคู่ที่ตรงกัน ส่งคืนอาร์เรย์ที่มีความยาวเท่ากันเพื่อระบุว่าการเดาแต่ละครั้งนั้นคลาดเคลื่อนแค่ไหน หากพวกเขาเดาถูก ค่าจะเป็น 0 และหากไม่ใช่ ค่าจะเป็นความแตกต่างสัมบูรณ์ระหว่างการเดาและคะแนน ตัวอย่าง: compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3] compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]\n \"\"\"\n","canonical_solution":" return [abs(x-y) for x,y in zip(game,guess)]\n","test":"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","entry_point":"compare"} -{"task_id":"HumanEval\/153","prompt":"\ndef Strongest_Extension(class_name, extensions):\n \"\"\"คุณจะได้รับชื่อของคลาส (สตริง) และรายการส่วนขยาย ส่วนขยายเหล่านี้จะถูกใช้เพื่อโหลดคลาสเพิ่มเติมให้กับคลาส ความแข็งแกร่งของส่วนขยายมีดังนี้ ให้ CAP เป็นจำนวนตัวอักษรพิมพ์ใหญ่ในชื่อส่วนขยาย และให้ SM เป็นจำนวนตัวอักษรพิมพ์เล็กในชื่อส่วนขยาย ความแข็งแกร่งจะกำหนดโดยเศษส่วน CAP - SM คุณควรค้นหาส่วนขยายที่แข็งแกร่งที่สุดและส่งคืนสตริงในรูปแบบนี้: ClassName.StrongestExtensionName หากมีส่วนขยายสองรายการขึ้นไปที่มีความแข็งแกร่งเท่ากัน คุณควรเลือกส่วนขยายที่อยู่อันดับแรกในรายการ ตัวอย่างเช่น หากคุณได้รับ \"Slices\" เป็นคลาสและรายการส่วนขยาย: [\'SErviNGSliCes\', \'Cheese\', \'StuFfed\'] คุณควรส่งคืน \'Slices.SErviNGSliCes\' เนื่องจาก \'SErviNGSliCes\' เป็นส่วนขยายที่แข็งแกร่งที่สุด (ความแข็งแกร่งคือ -1) ตัวอย่าง: สำหรับ Strongest_Extension(\'my_class\', [\'AA\', \'Be\', \'CC\']) == \'my_class.AA\'\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"Strongest_Extension"} -{"task_id":"HumanEval\/154","prompt":"\ndef cycpattern_check(a , b):\n \"\"\"คุณได้รับ 2 คำ คุณต้องคืนค่า True หากคำที่สองหรือการหมุนเวียนใดๆ ของคำนั้นเป็นสตริงย่อยในคำแรก cycpattern_check(\"abcd\",\"abd\") => False cycpattern_check(\"hello\",\"ell\") => True cycpattern_check(\"whassup\",\"psus\") => False cycpattern_check(\"abab\",\"baa\") => True cycpattern_check(\"efef\",\"eeff\") => False cycpattern_check(\"himenss\",\"simen\") => True\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"cycpattern_check"} -{"task_id":"HumanEval\/155","prompt":"\ndef even_odd_count(num):\n \"\"\"เมื่อกำหนดจำนวนเต็ม ให้ส่งคืนทูเพิลที่มีจำนวนหลักคู่และหลักคี่ตามลำดับ ตัวอย่าง: even_odd_count(-12) ==> (1, 1) even_odd_count(123) ==> (1, 2)\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"even_odd_count"} -{"task_id":"HumanEval\/156","prompt":"\ndef int_to_mini_roman(number):\n \"\"\"เมื่อกำหนดจำนวนเต็มบวก ให้หาค่าเทียบเท่าตัวเลขโรมันเป็นสตริง แล้วส่งคืนเป็นตัวพิมพ์เล็ก ข้อจำกัด: 1 <= num <= 1000 ตัวอย่าง:\n >>> int_to_mini_roman(19) == 'xix'\n >>> int_to_mini_roman(152) == 'clii'\n >>> int_to_mini_roman(426) == 'cdxxvi'\"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"int_to_mini_roman"} -{"task_id":"HumanEval\/157","prompt":"\ndef right_angle_triangle(a, b, c):\n '''กำหนดความยาวของด้านทั้งสามของรูปสามเหลี่ยม คืนค่า True หากด้านทั้งสามประกอบกันเป็นรูปสามเหลี่ยมมุมฉาก คืนค่า False หากไม่เป็นเช่นนั้น รูปสามเหลี่ยมมุมฉากคือรูปสามเหลี่ยมที่มีมุมหนึ่งเป็นมุมฉากหรือ 90 องศา ตัวอย่าง: right_angle_triangle(3, 4, 5) == True right_angle_triangle(1, 2, 3) == False\n '''\n","canonical_solution":" return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b\n","test":"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","entry_point":"right_angle_triangle"} -{"task_id":"HumanEval\/158","prompt":"\ndef find_max(words):\n \"\"\"เขียนฟังก์ชันที่รับรายการสตริง รายการประกอบด้วยคำต่างๆ ส่งคืนคำที่มีจำนวนอักขระที่ไม่ซ้ำกันสูงสุด หากสตร��งหลายรายการมีอักขระที่ไม่ซ้ำกันสูงสุด ให้ส่งคืนสตริงที่มาก่อนตามลำดับตัวอักษร find_max([\"name\", \"of\", \"string\"]) == \"string\" find_max([\"name\", \"enam\", \"game\"]) == \"enam\" find_max([\"aaaaaaa\", \"bb\" ,\"cc\"]) == \"\"aaaaaaa\"\n \"\"\"\n","canonical_solution":" return sorted(words, key = lambda x: (-len(set(x)), x))[0]\n","test":"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","entry_point":"find_max"} -{"task_id":"HumanEval\/159","prompt":"\ndef eat(number, need, remaining):\n \"\"\"คุณเป็นกระต่ายที่หิวโหย และคุณได้กินแครอทไปจำนวนหนึ่งแล้ว แต่ตอนนี้คุณต้องกินแครอทเพิ่มเพื่อให้ครบมื้อของวัน คุณควรส่งคืนอาร์เรย์ของ [ จำนวนแครอทที่กินทั้งหมดหลังมื้ออาหารของคุณ จำนวนแครอทที่เหลือหลังมื้ออาหารของคุณ ] ถ้าแครอทเหลือไม่เพียงพอ คุณจะกินแครอทที่เหลือทั้งหมด แต่จะยังคงหิวอยู่ ตัวอย่าง: * eat(5, 6, 10) -> [11, 4] * eat(4, 8, 9) -> [12, 1] * eat(1, 10, 10) -> [11, 0] * eat(2, 11, 5) -> [7, 0] ตัวแปร: @number : integer จำนวนแครอทที่คุณกิน @need : integer จำนวนแครอทที่คุณต้องกิน @remaining : integer คือ จำนวนแครอทที่เหลืออยู่ในสต็อก Constrain: * 0 <= จำนวน <= 1000 * 0 <= ความต้องการ <= 1000 * 0 <= ที่เหลือ <= 1000 สนุกนะ :)\n \"\"\"\n","canonical_solution":" if(need <= remaining):\n return [ number + need , remaining-need ]\n else:\n return [ number + remaining , 0]\n","test":"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","entry_point":"eat"} -{"task_id":"HumanEval\/160","prompt":"\ndef do_algebra(operator, operand):\n \"\"\"กำหนดตัวดำเนินการรายการสองตัวและตัวดำเนินการ รายการแรกมีการดำเนินการพีชคณิตพื้นฐาน และรายการที่สองเป็นรายการของจำนวนเต็ม ใช้รายการทั้งสองที่กำหนดเพื่อสร้างนิพจน์พีชคณิตและส่งคืนการประเมินนิพจน์นี้ การดำเนินการพีชคณิตพื้นฐาน: การบวก ( + ) การลบ ( - ) การคูณ ( * ) การหารด้วยเลขฐานสอง ( \/\/ ) การยกกำลัง ( ** ) ตัวอย่าง: ตัวดำเนินการ[\'+\', \'*\', \'-\'] อาร์เรย์ = [2, 3, 4, 5] ผลลัพธ์ = 2 + 3 * 4 - 5 => ผลลัพธ์ = 9 หมายเหตุ: ความยาวของตัวดำเนินการรายการเท่ากับความยาวของตัวดำเนินการรายการลบหนึ่ง ตัวดำเ��ินการคือรายการของจำนวนเต็มที่ไม่เป็นลบ ตัวดำเนินการรายการมีตัวดำเนินการอย่างน้อยหนึ่งตัว และตัวดำเนินการรายการมีตัวดำเนินการอย่างน้อยสองตัว\n \"\"\"\n","canonical_solution":" expression = str(operand[0])\n for oprt, oprn in zip(operator, operand[1:]):\n expression+= oprt + str(oprn)\n return eval(expression)\n","test":"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","entry_point":"do_algebra"} -{"task_id":"HumanEval\/161","prompt":"\ndef solve(s):\n \"\"\"คุณจะได้รับสตริง s หาก s[i] เป็นตัวอักษร ให้กลับตัวพิมพ์จากตัวพิมพ์เล็กเป็นตัวพิมพ์ใหญ่หรือในทางกลับกัน มิฉะนั้น ให้คงไว้ตามเดิม หากสตริงไม่มีตัวอักษร ให้กลับตัวพิมพ์ ฟังก์ชันควรส่งคืนสตริงที่ได้ ตัวอย่าง solve(\"1234\") = \"4321\" solve(\"ab\") = \"AB\" solve(\"#a@C\") = \"#A@c\"\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"solve"} -{"task_id":"HumanEval\/162","prompt":"\ndef string_to_md5(text):\n \"\"\"เมื่อได้รับสตริง \'text\' ให้ส่งคืนสตริงเทียบเท่าแฮช md5 หาก \'text\' เป็นสตริงว่าง ให้ส่งคืน None\n >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'\"\"\"\n","canonical_solution":" import hashlib\n return hashlib.md5(text.encode('ascii')).hexdigest() if text else None\n","test":"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","entry_point":"string_to_md5"} -{"task_id":"HumanEval\/163","prompt":"\ndef generate_integers(a, b):\n \"\"\"กำหนดจำนวนเต็มบวกสองจำนวนคือ a และ b ให้ส่งคืนเลขคู่ระหว่าง a และ b ตามลำดับจากน้อยไปมาก ตัวอย่างเช่น generate_integers(2, 8) => [2, 4, 6, 8] generate_integers(8, 2) => [2, 4, 6, 8] generate_integers(10, 14) => []\n \"\"\"\n","canonical_solution":" 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","test":"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","entry_point":"generate_integers"} +{"task_id":"HumanEval\\/0","prompt":"from typing import List\\n\\n\\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\\n \"\"\"ตรวจสอบว่าในรายการตัวเลขที่กำหนดไว้ มีตัวเลขสองตัวใดที่อยู่ใกล้กันมากกว่าเกณฑ์ที่กำหนดไว้หรือไม่\\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\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"has_close_elements"} +{"task_id":"HumanEval\\/1","prompt":"from typing import List\\n\\n\\ndef separate_paren_groups(paren_string: str) -> List[str]:\\n \"\"\"อินพุตของฟังก์ชันนี้คือสตริงที่มีวงเล็บซ้อนกันหลายกลุ่ม เป้าหมายของคุณคือแยกกลุ่มเหล่านั้นออกเป็นสตริงแยกกันและส่งคืนรายการของกลุ่มเหล่านั้น กลุ่มที่แยกจากกันจะสมดุลกัน (วงเล็บเปิดแต่ละอันปิดอย่างถูกต้อง) และไม่ซ้อนกัน ไม่สนใจช่องว่างใดๆ ในสตริงอินพุต\\n >>> separate_paren_groups('( ) (( )) (( )( ))')\\n ['()', '(())', '(()())']\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"separate_paren_groups"} +{"task_id":"HumanEval\\/2","prompt":"\\n\\ndef truncate_number(number: float) -> float:\\n \"\"\"เมื่อกำหนดจำนวนจุดลอยตัวเป็นบวก ตัวเลขดังกล่าวสามารถแยกออกเป็นส่วนจำนวนเต็ม (จำนวนเต็มที่มากที่สุดที่เล็กกว่าจำนวนที่กำหนด) และทศนิยม (ส่วนที่เหลือจะเล็กกว่า 1 เสมอ) ส่งคืนส่วนทศนิยมของตัวเลข\\n >>> truncate_number(3.5)\\n 0.5\"\"\"\\n","canonical_solution":" return number % 1.0\\n","test":"\\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","entry_point":"truncate_number"} +{"task_id":"HumanEval\\/3","prompt":"from typing import List\\n\\n\\ndef below_zero(operations: List[int]) -> bool:\\n \"\"\"คุณจะได้รับรายการการฝากและถอนเงินในบัญชีธนาคารที่เริ่มต้นด้วยยอดเงินคงเหลือเป็นศูนย์ งานของคุณคือตรวจจับว่าเมื่อใดยอดเงินคงเหลือในบัญชีจะลดลงต่ำกว่าศูนย์ และเมื่อถึงจุดนั้น ฟังก์ชันควรส่งคืนค่า True มิฉะนั้น ฟังก์ชันควรส่งคืนค่า False\\n >>> below_zero([1, 2, 3])\\n False\\n >>> below_zero([1, 2, -4, 5])\\n True\"\"\"\\n","canonical_solution":" balance = 0\\n\\n for op in operations:\\n balance += op\\n if balance < 0:\\n return True\\n\\n return False\\n","test":"\\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","entry_point":"below_zero"} +{"task_id":"HumanEval\\/4","prompt":"from typing import List\\n\\n\\ndef mean_absolute_deviation(numbers: List[float]) -> float:\\n \"\"\"สำหรับรายการตัวเลขอินพุตที่กำหนด ให้คำนวณค่าเบี่ยงเบนสัมบูรณ์เฉลี่ยรอบค่าเฉลี่ยของชุดข้อมูลนี้ ค่าเบี่ยงเบนสัมบูรณ์เฉลี่ยคือความแตกต่างสัมบูรณ์เฉลี่ยระหว่างแต่ละองค์ประกอบและจุดศูนย์กลาง (ค่าเฉลี่ยในกรณีนี้): MAD = ค่าเฉลี่ย | x - x_mean |\\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\\n 1.0\"\"\"\\n","canonical_solution":" mean = sum(numbers) \\/ len(numbers)\\n return sum(abs(x - mean) for x in numbers) \\/ len(numbers)\\n","test":"\\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","entry_point":"mean_absolute_deviation"} +{"task_id":"HumanEval\\/5","prompt":"from typing import List\\n\\n\\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\\n \"\"\"แทรก \\'ตัวแบ่ง\\' ตัวเลขระหว่างองค์ประกอบ \\'ตัวเลข\\' สององค์ประกอบติดต่อกันของรายการอินพุต\\n >>> intersperse([], 4)\\n []\\n >>> intersperse([1, 2, 3], 4)\\n [1, 4, 2, 4, 3]\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"intersperse"} +{"task_id":"HumanEval\\/6","prompt":"from typing import List\\n\\n\\ndef parse_nested_parens(paren_string: str) -> List[int]:\\n \"\"\"อินพุตของฟังก์ชันนี้คือสตริงที่แสดงกลุ่มต่างๆ หลายกลุ่มสำหรับวงเล็บซ้อนที่คั่นด้วยช่องว่าง สำหรับแต่ละกลุ่ม ให้แสดงระดับการซ้อนวงเล็บที่ลึกที่สุด ตัวอย่างเช่น (()()) มีระดับการซ้อนสูงสุดสองระดับในขณะที่ ((())) มีสามระดับ\\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\\n [2, 3, 1, 3]\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"parse_nested_parens"} +{"task_id":"HumanEval\\/7","prompt":"from typing import List\\n\\n\\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\\n \"\"\"กรองรายการอินพุตของสตริงเฉพาะที่มีสตริงย่อยที่กำหนดเท่านั้น\\n >>> filter_by_substring([], 'a')\\n []\\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\\n ['abc', 'bacd', 'array']\"\"\"\\n","canonical_solution":" return [x for x in strings if substring in x]\\n","test":"\\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","entry_point":"filter_by_substring"} +{"task_id":"HumanEval\\/8","prompt":"from typing import List, Tuple\\n\\n\\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\\n \"\"\"สำหรับรายการจำนวนเต็มที่กำหนด ให้ส่งคืนทูเพิลที่ประกอบด้วยผลรวมและผลคูณของจำนวนเต็มทั้งหมดในรายการ ผลรวมว่างควรเท่ากับ 0 และผลคูณว่างควรเท่ากับ 1\\n >>> sum_product([])\\n (0, 1)\\n >>> sum_product([1, 2, 3, 4])\\n (10, 24)\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"sum_product"} +{"task_id":"HumanEval\\/9","prompt":"from typing import List, Tuple\\n\\n\\ndef rolling_max(numbers: List[int]) -> List[int]:\\n \"\"\"จากรายการจำนวนเต็มที่กำหนดให้ สร้างรายการขององค์ประกอบสูงสุดที่หมุนเวียนที่พบจนถึงช่วงเวลาที่กำหนดในลำดับ\\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\\n [1, 2, 3, 3, 3, 4, 4]\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"rolling_max"} +{"task_id":"HumanEval\\/10","prompt":"\\n\\ndef is_palindrome(string: str) -> bool:\\n \"\"\"ทดสอบว่าสตริงที่กำหนดเป็นพาลินโดรม \"\"\" return string == string[::-1] def make_palindrome(string: str) -> str:\\n >>>\"\"\" Find the shortest palindrome that begins with a supplied string.\\n Algorithm idea is simple:\\n - Find the longest postfix of supplied string that is a palindrome.\\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\\n >>> make_palindrome('')\\n ''\\n >>> make_palindrome('cat')\\n 'catac'\\n >>> make_palindrome('cata')\\n 'catac'\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"make_palindrome"} +{"task_id":"HumanEval\\/11","prompt":"from typing import List\\n\\n\\ndef string_xor(a: str, b: str) -> str:\\n \"\"\"อินพุตเป็นสตริงสองตัวคือ a และ b ที่ประกอบด้วย 1 และ 0 เท่านั้น ดำเนินการ XOR แบบไบนารีกับอินพุตเหล่านี้และส่งคืนผลลัพธ์เป็นสตริงด้วยเช่นกัน\\n >>> string_xor('010', '110')\\n '100'\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"string_xor"} +{"task_id":"HumanEval\\/12","prompt":"from typing import List, Optional\\n\\n\\ndef longest(strings: List[str]) -> Optional[str]:\\n \"\"\"จากรายการสตริง ให้ส่งคืนสตริงที่ยาวที่สุด ส่งคืนสตริงแรกในกรณีที่มีสตริงหลายตัวที่มีความยาวเท่ากัน ส่งคืน None ในกรณีที่รายการอินพุตว่างเปล่า\\n >>> longest([])\\n\\n >>> longest(['a', 'b', 'c'])\\n 'a'\\n >>> longest(['a', 'bb', 'ccc'])\\n 'ccc'\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"longest"} +{"task_id":"HumanEval\\/13","prompt":"\\n\\ndef greatest_common_divisor(a: int, b: int) -> int:\\n \"\"\"คืนค่าตัวหารร่วมมากของจำนวนเต็มสองจำนวนคือ a และ b\\n >>> greatest_common_divisor(3, 5)\\n 1\\n >>> greatest_common_divisor(25, 15)\\n 5\"\"\"\\n","canonical_solution":" while b:\\n a, b = b, a % b\\n return a\\n","test":"\\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","entry_point":"greatest_common_divisor"} +{"task_id":"HumanEval\\/14","prompt":"from typing import List\\n\\n\\ndef all_prefixes(string: str) -> List[str]:\\n \"\"\"แสดงรายการคำนำหน้าทั้งหมดตั้งแต่สั้นที่สุดไปจนถึงยาวที่สุดของสตริงอินพุต\\n >>> all_prefixes('abc')\\n ['a', 'ab', 'abc']\"\"\"\\n","canonical_solution":" result = []\\n\\n for i in range(len(string)):\\n result.append(string[:i+1])\\n return result\\n","test":"\\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","entry_point":"all_prefixes"} +{"task_id":"HumanEval\\/15","prompt":"\\n\\ndef string_sequence(n: int) -> str:\\n \"\"\"ส่งคืนสตริงที่มีตัวเลขที่คั่นด้วยช่องว่างตั้งแต่ 0 ถึง n\\n >>> string_sequence(0)\\n '0'\\n >>> string_sequence(5)\\n '0 1 2 3 4 5'\"\"\"\\n","canonical_solution":" return ' '.join([str(x) for x in range(n + 1)])\\n","test":"\\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","entry_point":"string_sequence"} +{"task_id":"HumanEval\\/16","prompt":"\\n\\ndef count_distinct_characters(string: str) -> int:\\n \"\"\"กำหนดสตริง ให้หาว่ามีอักขระที่แตกต่างกันกี่ตัว (โดยไม่คำนึงถึงตัวพิมพ์ใหญ่เล็ก) ที่ประกอบด้วย\\n >>> count_distinct_characters('xyzXYZ')\\n 3\\n >>> count_distinct_characters('Jerry')\\n 4\"\"\"\\n","canonical_solution":" return len(set(string.lower()))\\n","test":"\\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","entry_point":"count_distinct_characters"} +{"task_id":"HumanEval\\/17","prompt":"from typing import List\\n\\n\\ndef parse_music(music_string: str) -> List[int]:\\n \"\"\"อินพุตสำหรับฟังก์ชันนี้คือสตริงที่แสดงโน้ตดนตรีในรูปแบบ ASCII พิเศษ งานของคุณคือวิเคราะห์สตริงนี้และส่งคืนรายการจำนวนเต็มที่สอดคล้องกับจำนวนจังหวะที่แต่ละจังหวะไม่คงอยู่ ต่อไปนี้คื���คำอธิบาย: \\'o\\' - โน้ตตัวเต็ม ยาวนานสี่จังหวะ \\'o|\\' - โน้ตตัวครึ่ง ยาวนานสองจังหวะ \\'.|\\' - โน้ตตัวกลาง ยาวนานหนึ่งจังหวะ\\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\"\"\"\\n","canonical_solution":" note_map = {'o': 4, 'o|': 2, '.|': 1}\\n return [note_map[x] for x in music_string.split(' ') if x]\\n","test":"\\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","entry_point":"parse_music"} +{"task_id":"HumanEval\\/18","prompt":"\\n\\ndef how_many_times(string: str, substring: str) -> int:\\n \"\"\"ค้นหาว่าสามารถพบซับสตริงที่กำหนดได้กี่ครั้งในสตริงต้นฉบับ นับกรณีที่ทับซ้อนกัน\\n >>> how_many_times('', 'a')\\n 0\\n >>> how_many_times('aaa', 'a')\\n 3\\n >>> how_many_times('aaaa', 'aa')\\n 3\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"how_many_times"} +{"task_id":"HumanEval\\/19","prompt":"from typing import List\\n\\n\\ndef sort_numbers(numbers: str) -> str:\\n \"\"\"อินพุตเป็นสตริงตัวเลขที่คั่นด้วยช่องว่างตั้งแต่ \\'ศูนย์\\' ถึง \\'เก้า\\' ตัวเลือกที่ถูกต้องคือ \\'ศูนย์\\' \\'หนึ่ง\\' \\'สอง\\' \\'สาม\\' \\'สี่\\' \\'ห้า\\' \\'หก\\' \\'เจ็ด\\' \\'แปด\\' และ \\'เก้า\\' ส่งคืนสตริงที่มีตัวเลขเรียงจากน้อยไปมาก\\n >>> sort_numbers('three one five')\\n 'one three five'\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"sort_numbers"} +{"task_id":"HumanEval\\/20","prompt":"from typing import List, Tuple\\n\\n\\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\\n \"\"\"จากรายการตัวเลขที่จัดทำไว้ (ความยาวอย่างน้อย 2) ให้เลือกตัวเลข 2 ตัวที่อยู่ใกล้กันมากที่สุด แล้วส่งคืนตามลำดับ (ตัวเลขที่น้อยกว่า ตัวเลขที่มากกว่า)\\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)\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"find_closest_elements"} +{"task_id":"HumanEval\\/21","prompt":"from typing import List\\n\\n\\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\\n \"\"\"กำหนดรายการตัวเลข (อย่างน้อย 2 องค์ประกอบ) ใช้การแปลงเชิงเส้นกับรายการนั้น โดยที่ตัวเลขที่เล็กที่สุดจะกลายเป็น 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]\"\"\"\\n","canonical_solution":" min_number = min(numbers)\\n max_number = max(numbers)\\n return [(x - min_number) \\/ (max_number - min_number) for x in numbers]\\n","test":"\\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","entry_point":"rescale_to_unit"} +{"task_id":"HumanEval\\/22","prompt":"from typing import List, Any\\n\\n\\ndef filter_integers(values: List[Any]) -> List[int]:\\n \"\"\"กรองรายการค่า Python ที่กำหนดไว้เฉพาะสำหรับจำนวนเต็มเท่านั้น\\n >>> filter_integers(['a', 3.14, 5])\\n [5]\\n >>> filter_integers([1, 2, 3, 'abc', {}, []])\\n [1, 2, 3]\"\"\"\\n","canonical_solution":" return [x for x in values if isinstance(x, int)]\\n","test":"\\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","entry_point":"filter_integers"} +{"task_id":"HumanEval\\/23","prompt":"\\n\\ndef strlen(string: str) -> int:\\n \"\"\"ส่งคืนความยาวของสตริงที่กำหนด\\n >>> strlen('')\\n 0\\n >>> strlen('abc')\\n 3\"\"\"\\n","canonical_solution":" return len(string)\\n","test":"\\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","entry_point":"strlen"} +{"task_id":"HumanEval\\/24","prompt":"\\n\\ndef largest_divisor(n: int) -> int:\\n \"\"\"สำหรับจำนวน n ที่กำหนด หาจำนวนที่มากที่สุดที่หาร n ได้ลงตัว ซึ่งมีค่าน้อยกว่า n\\n >>> largest_divisor(15)\\n 5\"\"\"\\n","canonical_solution":" for i in reversed(range(n)):\\n if n % i == 0:\\n return i\\n","test":"\\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","entry_point":"largest_divisor"} +{"task_id":"HumanEval\\/25","prompt":"from typing import List\\n\\n\\ndef factorize(n: int) -> List[int]:\\n \"\"\"ส่งคืนรายการปัจจัยเฉพาะของจำนวนเต็มที่กำหนดให้ตามลำดับจากน้อยไปหามาก ปัจจัยแต่ละตัวควรแสดงรายการตามจำนวนครั้งที่ปรากฏในการแยกตัวประกอบ จำนวนอินพุตควรเท่ากับผลคูณของปัจจัยทั้งหมด\\n >>> factorize(8)\\n [2, 2, 2]\\n >>> factorize(25)\\n [5, 5]\\n >>> factorize(70)\\n [2, 5, 7]\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"factorize"} +{"task_id":"HumanEval\\/26","prompt":"from typing import List\\n\\n\\ndef remove_duplicates(numbers: List[int]) -> List[int]:\\n \"\"\"จากรายการจำนวนเต็ม ให้ลบองค์ประกอบทั้งหมดที่เกิดขึ้นมากกว่าหนึ่งครั้งออก รักษาลำดับขององค์ประกอบให้เหมือนเดิมกับในอินพุต\\n >>> remove_duplicates([1, 2, 3, 2, 4])\\n [1, 3, 4]\"\"\"\\n","canonical_solution":" import collections\\n c = collections.Counter(numbers)\\n return [n for n in numbers if c[n] <= 1]\\n","test":"\\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","entry_point":"remove_duplicates"} +{"task_id":"HumanEval\\/27","prompt":"\\n\\ndef flip_case(string: str) -> str:\\n \"\"\"สำหรับสตริงที่กำหนด ให้เปลี่ยนตัวอักษรตัวพิมพ์เล็กเป็นตัวพิมพ์ใหญ่ และเปลี่ยนตัวอักษรตัวพิมพ์ใหญ่เป็นตัวพิมพ์เล็ก\\n >>> flip_case('Hello')\\n 'hELLO'\"\"\"\\n","canonical_solution":" return string.swapcase()\\n","test":"\\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","entry_point":"flip_case"} +{"task_id":"HumanEval\\/28","prompt":"from typing import List\\n\\n\\ndef concatenate(strings: List[str]) -> str:\\n \"\"\"เชื่อมโยงรายการสตริงเข้าเป็นสตริงเดียว\\n >>> concatenate([])\\n ''\\n >>> concatenate(['a', 'b', 'c'])\\n 'abc'\"\"\"\\n","canonical_solution":" return ''.join(strings)\\n","test":"\\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","entry_point":"concatenate"} +{"task_id":"HumanEval\\/29","prompt":"from typing import List\\n\\n\\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\\n \"\"\"กรองรายการอินพุตของสตริงเฉพาะรายการที่เริ่มต้นด้วยคำนำหน้าที่กำหนดเท่านั้น\\n >>> filter_by_prefix([], 'a')\\n []\\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\\n ['abc', 'array']\"\"\"\\n","canonical_solution":" return [x for x in strings if x.startswith(prefix)]\\n","test":"\\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","entry_point":"filter_by_prefix"} +{"task_id":"HumanEval\\/30","prompt":"\\n\\ndef get_positive(l: list):\\n \"\"\"กลับเฉพาะตัวเลขบวกในรายการ\\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]\"\"\"\\n","canonical_solution":" return [e for e in l if e > 0]\\n","test":"\\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","entry_point":"get_positive"} +{"task_id":"HumanEval\\/31","prompt":"\\n\\ndef is_prime(n):\\n \"\"\"คืนค่าเป็นจริงถ้าตัวเลขที่กำหนดเป็นจำนวนเฉพาะ และคืนค่าเท็จถ้าไม่เป็นเช่นนั้น\\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\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"is_prime"} +{"task_id":"HumanEval\\/32","prompt":"import math\\n\\n\\ndef poly(xs: list, x: float):\\n \"\"\"ประเมินพหุนามที่มีค่าสัมประสิทธิ์ xs ที่จุด x ส่งคืน xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n\\n >>>\"\"\"\\n return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])\\n\\n\\ndef find_zero(xs: list):\"\"\" xs are coefficients of a polynomial.\\n find_zero find x such that poly(x) = 0.\\n find_zero returns only only zero point, even if there are many.\\n Moreover, find_zero only takes list xs having even number of coefficients\\n and largest non zero coefficient as it guarantees\\n a solution.\\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\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"find_zero"} +{"task_id":"HumanEval\\/33","prompt":"\\n\\ndef sort_third(l: list):\\n \"\"\"ฟังก์ชันนี้ใช้รายการ l และส่งคืนรายการ l\\' โดยที่ l\\' จะเหมือนกับ l ในดัชนีที่หารด้วยสามไม่ลงตัว ในขณะที่ค่าของ l ในดัชนีที่หารด้วยสามลงตัวจะเท่ากับค่าของดัชนีที่สอดคล้องกันของ l แต่ได้รับการเรียงลำดับ\\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]\"\"\"\\n","canonical_solution":" l = list(l)\\n l[::3] = sorted(l[::3])\\n return l\\n","test":"\\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","entry_point":"sort_third"} +{"task_id":"HumanEval\\/34","prompt":"\\n\\ndef unique(l: list):\\n \"\"\"ส่งคืนองค์ประกอบที่ไม่ซ้ำกันที่เรียงลำดับในรายการ\\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\\n [0, 2, 3, 5, 9, 123]\"\"\"\\n","canonical_solution":" return sorted(list(set(l)))\\n","test":"\\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","entry_point":"unique"} +{"task_id":"HumanEval\\/35","prompt":"\\n\\ndef max_element(l: list):\\n \"\"\"ส่งคืนองค์ประกอบสูงสุดในรายการ\\n >>> max_element([1, 2, 3])\\n 3\\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\\n 123\"\"\"\\n","canonical_solution":" m = l[0]\\n for e in l:\\n if e > m:\\n m = e\\n return m\\n","test":"\\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","entry_point":"max_element"} +{"task_id":"HumanEval\\/36","prompt":"\\n\\ndef fizz_buzz(n: int):\\n \"\"\"คืนจำนวนครั้งที่หลัก 7 ปรากฏในจำนวนเต็มที่น้อยกว่า n ซึ่งหารด้วย 11 หรือ 13 ลงตัว\\n >>> fizz_buzz(50)\\n 0\\n >>> fizz_buzz(78)\\n 2\\n >>> fizz_buzz(79)\\n 3\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"fizz_buzz"} +{"task_id":"HumanEval\\/37","prompt":"\\n\\ndef sort_even(l: list):\\n \"\"\"ฟังก์ชันนี้ใช้รายการ l และส่งคืนรายการ l\\' โดยที่ l\\' จะเหมือนกับ l ในดัชนีคี่ ในขณะที่ค่าในดัชนีคู่จะเท่ากับค่าของดัชนีคู่ของ l แต่ได้รับการเรียงลำดับ\\n >>> sort_even([1, 2, 3])\\n [1, 2, 3]\\n >>> sort_even([5, 6, 3, 4])\\n [3, 6, 5, 4]\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"sort_even"} +{"task_id":"HumanEval\\/38","prompt":"\\n\\ndef encode_cyclic(s: str):\\n \"\"\"ส่งคืนสตริงที่เข้ารหัสโดยการหมุนเวียนกลุ่มอักขระสามตัว\\n \"\"\"\\n # split string to groups. Each of length 3.\\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) \\/\\/ 3)]\\n # cycle elements in each group. Unless group has fewer elements than 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 takes as input string encoded with encode_cyclic function. Returns decoded string.\"\"\"\\n","canonical_solution":" return encode_cyclic(encode_cyclic(s))\\n","test":"\\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","entry_point":"decode_cyclic"} +{"task_id":"HumanEval\\/39","prompt":"\\n\\ndef prime_fib(n: int):\\n \"\"\"prime_fib คืนค่าตัวเลขที่ n ซึ่งเป็นตัวเลข Fibonacci และเป็นจำนวนเฉพาะด้วย\\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\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"prime_fib"} +{"task_id":"HumanEval\\/40","prompt":"\\n\\ndef triples_sum_to_zero(l: list):\\n \"\"\"triples_sum_to_zero จะรับรายการจำนวนเต็มเป็นอินพุต โดยจะคืนค่า True หากมีองค์ประกอบที่แตกต่างกันสามองค์ประกอบในร��ยการที่ผลรวมเป็นศูนย์ และคืนค่า False หากไม่เป็นเช่นนั้น\\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\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"triples_sum_to_zero"} +{"task_id":"HumanEval\\/41","prompt":"\\n\\ndef car_race_collision(n: int):\\n \"\"\"ลองนึกภาพถนนที่ตรงและยาวไม่มีที่สิ้นสุด มีรถยนต์ n คันขับจากซ้ายไปขวา ในขณะเดียวกัน รถยนต์อีก n คันขับจากขวาไปซ้าย รถทั้งสองคันเริ่มอยู่ห่างกันมาก รถทุกคันเคลื่อนที่ด้วยความเร็วเท่ากัน กล่าวกันว่ารถสองคันจะชนกันเมื่อรถที่เคลื่อนที่จากซ้ายไปขวาชนกับรถที่เคลื่อนที่จากขวาไปซ้าย อย่างไรก็ตาม รถทั้งสองคันมีความแข็งแรงและมั่นคงอย่างไม่มีที่สิ้นสุด ดังนั้น รถทั้งสองคันจึงยังคงเคลื่อนที่ตามวิถีของมันราวกับว่าไม่ได้ชนกัน ฟังก์ชันนี้จะแสดงผลจำนวนการชนดังกล่าว\\n \"\"\"\\n","canonical_solution":" return n**2\\n","test":"\\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","entry_point":"car_race_collision"} +{"task_id":"HumanEval\\/42","prompt":"\\n\\ndef incr_list(l: list):\\n \"\"\"กลับรายการที่มีองค์ประกอบเพิ่มขึ้นทีละ 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]\"\"\"\\n","canonical_solution":" return [(e + 1) for e in l]\\n","test":"\\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","entry_point":"incr_list"} +{"task_id":"HumanEval\\/43","prompt":"\\n\\ndef pairs_sum_to_zero(l):\\n \"\"\"pairs_sum_to_zero จะรับรายการจำนวนเต็มเป็นอินพุต โดยจะคืนค่า True หากมีองค์ประกอบที่แตกต่างกันสององค์ประกอบในรายการซึ่งผลรวมเป็นศูนย์ และคืนค่า 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\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"pairs_sum_to_zero"} +{"task_id":"HumanEval\\/44","prompt":"\\n\\ndef change_base(x: int, base: int):\\n \"\"\"เปลี่ยนฐานตัวเลขของเลขอินพุต x ให้เป็นฐาน ส่งคืนการแสดงสตริงหลังจากการแปลง เลขฐานน้อยกว่า 10\\n >>> change_base(8, 3)\\n '22'\\n >>> change_base(8, 2)\\n '1000'\\n >>> change_base(7, 2)\\n '111'\"\"\"\\n","canonical_solution":" ret = \"\"\\n while x > 0:\\n ret = str(x % base) + ret\\n x \\/\\/= base\\n return ret\\n","test":"\\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","entry_point":"change_base"} +{"task_id":"HumanEval\\/45","prompt":"\\n\\ndef triangle_area(a, h):\\n \"\"\"กำหนดความยาวด้านและพื้นที่ส่งคืนสูงสำหรับสามเหลี่ยม\\n >>> triangle_area(5, 3)\\n 7.5\"\"\"\\n","canonical_solution":" return a * h \\/ 2.0\\n","test":"\\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","entry_point":"triangle_area"} +{"task_id":"HumanEval\\/46","prompt":"\\n\\ndef fib4(n: int):\\n \"\"\"ลำดับตัวเลข Fib4 เป็นลำดับที่คล้ายกับลำดับ Fibbonacci ซึ่งกำหนดดังนี้: fib4(0) -> 0 fib4(1) -> 0 fib4(2) -> 2 fib4(3) -> 0 fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4) โปรดเขียนฟังก์ชันเพื่อคำนวณองค์ประกอบที่ n ของลำดับตัวเลข fib4 อย่างมีประสิทธิภาพ อย่าใช้การเรียกซ้ำ\\n >>> fib4(5)\\n 4\\n >>> fib4(6)\\n 8\\n >>> fib4(7)\\n 14\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"fib4"} +{"task_id":"HumanEval\\/47","prompt":"\\n\\ndef median(l: list):\\n \"\"\"คืนค่ามัธยฐานขององค์ประกอบในรายการ l\\n >>> median([3, 1, 2, 4, 5])\\n 3\\n >>> median([-10, 4, 6, 1000, 10, 20])\\n 15.0\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"median"} +{"task_id":"HumanEval\\/48","prompt":"\\n\\ndef is_palindrome(text: str):\\n \"\"\"ตรวจสอบว่าสตริงที่กำหนดเป็นพาลินโดรมหรือไม่\\n >>> is_palindrome('')\\n True\\n >>> is_palindrome('aba')\\n True\\n >>> is_palindrome('aaaaa')\\n True\\n >>> is_palindrome('zbcd')\\n False\"\"\"\\n","canonical_solution":" for i in range(len(text)):\\n if text[i] != text[len(text) - 1 - i]:\\n return False\\n return True\\n","test":"\\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","entry_point":"is_palindrome"} +{"task_id":"HumanEval\\/49","prompt":"\\n\\ndef modp(n: int, p: int):\\n \"\"\"ส่งกลับ 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\"\"\"\\n","canonical_solution":" ret = 1\\n for i in range(n):\\n ret = (2 * ret) % p\\n return ret\\n","test":"\\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","entry_point":"modp"} +{"task_id":"HumanEval\\/50","prompt":"\\n\\ndef encode_shift(s: str):\\n \"\"\"ส่งคืนสตริงที่เข้ารหัสโดยการเลื่อนอักขระแต่ละตัวทีละ 5 ตัวในตัวอักษร\\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 takes as input string encoded with encode_shift function. Returns decoded string.\"\"\"\\n","canonical_solution":" return \"\".join([chr(((ord(ch) - 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\\n","test":"\\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","entry_point":"decode_shift"} +{"task_id":"HumanEval\\/51","prompt":"\\n\\ndef remove_vowels(text):\\n \"\"\"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'\"\"\"\\n","canonical_solution":" return \"\".join([s for s in text if s.lower() not in [\"a\", \"e\", \"i\", \"o\", \"u\"]])\\n","test":"\\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","entry_point":"remove_vowels"} +{"task_id":"HumanEval\\/52","prompt":"\\n\\ndef below_threshold(l: list, t: int):\\n \"\"\"คืนค่า True ถ้าตัวเลขทั้งหมดในรายการ l ต่ำกว่าเกณฑ์ t\\n >>> below_threshold([1, 2, 4, 10], 100)\\n True\\n >>> below_threshold([1, 20, 4, 10], 5)\\n False\"\"\"\\n","canonical_solution":" for e in l:\\n if e >= t:\\n return False\\n return True\\n","test":"\\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","entry_point":"below_threshold"} +{"task_id":"HumanEval\\/53","prompt":"\\n\\ndef add(x: int, y: int):\\n \"\"\"บวกเลขสองตัวคือ x และ y\\n >>> add(2, 3)\\n 5\\n >>> add(5, 7)\\n 12\"\"\"\\n","canonical_solution":" return x + y\\n","test":"\\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","entry_point":"add"} +{"task_id":"HumanEval\\/54","prompt":"\\n\\ndef same_chars(s0: str, s1: str):\\n \"\"\"ตรวจสอบว่าคำสองคำมีอักขระเดียวกันหรือไม่\\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\"\"\"\\n","canonical_solution":" return set(s0) == set(s1)\\n","test":"\\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","entry_point":"same_chars"} +{"task_id":"HumanEval\\/55","prompt":"\\n\\ndef fib(n: int):\\n \"\"\"ส่งคืนเลข Fibonacci อันดับที่ n\\n >>> fib(10)\\n 55\\n >>> fib(1)\\n 1\\n >>> fib(8)\\n 21\"\"\"\\n","canonical_solution":" if n == 0:\\n return 0\\n if n == 1:\\n return 1\\n return fib(n - 1) + fib(n - 2)\\n","test":"\\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","entry_point":"fib"} +{"task_id":"HumanEval\\/56","prompt":"\\n\\ndef correct_bracketing(brackets: str):\\n \"\"\"วงเล็บเป็นสตริงของ \"<\" และ \">\" คืนค่า True หากวงเล็บเปิดทุกอันมีวงเล็บปิดที่สอดคล้องกัน\\n >>> correct_bracketing(\"<\")\\n False\\n >>> correct_bracketing(\"<>\")\\n True\\n >>> correct_bracketing(\"<<><>>\")\\n True\\n >>> correct_bracketing(\"><<>\")\\n False\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"correct_bracketing"} +{"task_id":"HumanEval\\/57","prompt":"\\n\\ndef monotonic(l: list):\\n \"\"\"ค่า Return 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\"\"\"\\n","canonical_solution":" if l == sorted(l) or l == sorted(l, reverse=True):\\n return True\\n return False\\n","test":"\\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","entry_point":"monotonic"} +{"task_id":"HumanEval\\/58","prompt":"\\n\\ndef common(l1: list, l2: list):\\n \"\"\"ส่งคืนองค์ประกอบทั่วไปที่ไม่ซ้ำกันที่เรียงลำดับสำหรับสองรายการ\\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]\\n\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"common"} +{"task_id":"HumanEval\\/59","prompt":"\\n\\ndef largest_prime_factor(n: int):\\n \"\"\"ส่งคืนตัวประกอบเฉพาะที่ใหญ่ที่สุดของ n ถือว่า n > 1 และไม่ใช่ตัวประกอบเฉพาะ\\n >>> largest_prime_factor(13195)\\n 29\\n >>> largest_prime_factor(2048)\\n 2\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"largest_prime_factor"} +{"task_id":"HumanEval\\/60","prompt":"\\n\\ndef sum_to_n(n: int):\\n \"\"\"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\"\"\"\\n","canonical_solution":" return sum(range(n + 1))\\n","test":"\\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","entry_point":"sum_to_n"} +{"task_id":"HumanEval\\/61","prompt":"\\n\\ndef correct_bracketing(brackets: str):\\n \"\"\"วงเล็บเป็นสตริงของ \"(\" และ \")\" คืนค่า True หากวงเล็บเปิดทุกอันมีวงเล็บปิดที่สอดคล้องกัน\\n >>> correct_bracketing(\"(\")\\n False\\n >>> correct_bracketing(\"()\")\\n True\\n >>> correct_bracketing(\"(()())\")\\n True\\n >>> correct_bracketing(\")(()\")\\n False\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"correct_bracketing"} +{"task_id":"HumanEval\\/62","prompt":"\\n\\ndef derivative(xs: list):\\n \"\"\"xs แทนค่าสัมประสิทธิ์ของพหุนาม xs[0] + xs[1] * x + xs[2] * x^2 + .... ส่งกลับอนุพันธ์ของพหุนามนี้ในรูปแบบเดียวกัน\\n >>> derivative([3, 1, 2, 4, 5])\\n [1, 4, 12, 20]\\n >>> derivative([1, 2, 3])\\n [2, 6]\"\"\"\\n","canonical_solution":" return [(i * x) for i, x in enumerate(xs)][1:]\\n","test":"\\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","entry_point":"derivative"} +{"task_id":"HumanEval\\/63","prompt":"\\n\\ndef fibfib(n: int):\\n \"\"\"ลำดับตัวเลข FibFib เป็นลำดับที่คล้ายกับลำดับ Fibbonacci ซึ่งกำหนดดังนี้: fibfib(0) == 0 fibfib(1) == 0 fibfib(2) == 1 fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3) โปรดเขียนฟังก์ชันเพื่อคำนวณองค์ประกอบที่ n ของลำดับตัวเลข FibFib อย่างมีประสิทธิภาพ\\n >>> fibfib(1)\\n 0\\n >>> fibfib(5)\\n 4\\n >>> fibfib(8)\\n 24\"\"\"\\n","canonical_solution":" 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","test":"\\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","entry_point":"fibfib"} +{"task_id":"HumanEval\\/64","prompt":"\\nFIX = \"\"\"\\nAdd more test cases.\\n\"\"\"\\n\\ndef vowels_count(s):\\n \"\"\"เขียนฟังก์ชัน vowels_count ซึ่งรับสตริงที่แสดงคำเป็นอินพุตและส่งคืนจำนวนสระในสตริง สระในกรณีนี้คือ \\'a\\', \\'e\\', \\'i\\', \\'o\\', \\'u\\' ในที่นี้ \\'y\\' ก็เป็นสระเช่นกัน แต่จะต้องอยู่ท้ายคำที่กำหนดเท่านั้น ตัวอย่าง:\\n >>> vowels_count(\"abcde\")\\n 2\\n >>> vowels_count(\"ACEDY\")\\n 3\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"vowels_count"} +{"task_id":"HumanEval\\/65","prompt":"\\ndef circular_shift(x, shift):\\n \"\"\"การเลื่อนตัวเลขของจำนวนเต็ม x แบบวงกลม เลื่อนตัวเลขไปทางขวาโดยการเลื่อน แล้วส่งคืนผลลัพธ์เป็นสตริง หากการเลื่อน > จำนวนตัวเลข ให้ส่งคืนตัวเลขที่ย้อนกลับ\\n >>> circular_shift(12, 1)\\n \"21\"\\n >>> circular_shift(12, 2)\\n \"12\"\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"circular_shift"} +{"task_id":"HumanEval\\/66","prompt":"\\ndef digitSum(s):\\n \"\"\"งาน เขียนฟังก์ชันที่รับสตริงเป็นอินพุตและส่งคืนผลรวมของรหัส ASCII ของอักขระตัวบนเท่านั้น ตัวอย่าง: digitSum(\"\") => 0 digitSum(\"abAB\") => 131 digitSum(\"abcCd\") => 67 digitSum(\"helloE\") => 69 digitSum(\"woArBld\") => 131 digitSum(\"aAaaaXa\") => 153\\n \"\"\"\\n","canonical_solution":" if s == \"\": return 0\\n return sum(ord(char) if char.isupper() else 0 for char in s)\\n","test":"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","entry_point":"digitSum"} +{"task_id":"HumanEval\\/67","prompt":"\\ndef fruit_distribution(s,n):\\n \"\"\"ในงานนี้ คุณจะได้รับสตริงที่แสดงถึงจำนวนแอปเปิ้ลและส้มที่กระจายอยู่ในตะกร้าผลไม้ ตะกร้านี้ประกอบด้วยแอปเปิ้ล ส้ม และมะม่วง เมื่อกำหนดสตริงที่แสดงถึงจำนวนส้มและแอปเปิ้ลทั้งหมด และจำนวนเต็มที่แสดงถึงจำนวนผลไม้ทั้งหมดในตะกร้า ให้ส่งคืนจำนวนผลมะม่วงในตะกร้า ตัวอย่างเช่น fruit_distribution(\"5 apples and 6 oranges\", 19) ->19 - 5 - 6 = 8 fruit_distribution(\"0 apples and 1 oranges\",3) -> 3 - 0 - 1 = 2 fruit_distribution(\"2 apples and 3 oranges\", 100) -> 100 - 2 - 3 = 95 fruit_distribution(\"100 apples and 1 oranges\",120) -> 120 - 100 - 1 = 19\\n \"\"\"\\n","canonical_solution":" lis = list()\\n for i in s.split(' '):\\n if i.isdigit():\\n lis.append(int(i))\\n return n - sum(lis)\\n","test":"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","entry_point":"fruit_distribution"} +{"task_id":"HumanEval\\/68","prompt":"\\ndef pluck(arr):\\n \"\"\"\"เมื่อกำหนดอาร์เรย์ที่แสดงถึงสาขาของต้นไม้ที่มีโหนดจำนวนเต็มที่ไม่เป็นลบ งานของคุณคือเลือกโหนดหนึ่งและส่งคืน โหนดที่คัดมาควรเป็นโหนดที่มีค่าคู่ที่เล็กที่สุด หากพบโหนดหลายโหนดที่มีค่าคู่ที่เล็กที่สุดเท่ากัน ให้ส่งคืนโหนดที่มีดัชนีที่เล็กที่สุด โหนดที่คัดมาควรส่งคืนในรายการ [ smalest_value, ดัชนีของโหนดนั้น ] ถ้าไม่มีค่าคู่หรืออาร์เรย์ที่กำหนดว่างเปล่า ให้ส่งคืน [] ตัวอย่าง 1: อินพุต: [4,2,3] เอาต์พุต: [2, 1] คำอธิบาย: 2 มีค่าคู่ที่เล็กที่สุด และ 2 มีดัชนีที่เล็กที่สุด ตัวอย่าง 2: อินพุต: [1,2,3] เอาต์พุต: [2, 1] คำอธิบาย: 2 มีค่าคู่ที่เล็กที่สุด และ 2 มีดัชนีที่เล็กที่สุด ตัวอย่าง 3: อินพุต: [] เอาต์พุต: [] ตัวอย่าง 4: อินพุต: [5, 0, 3, 0, 4, 2] ผลลัพธ์: [0, 1] คำอธิบาย: 0 คือค่าที่เล็กที่สุด แต่มีศูนย์สองตัว ดังนั้นเราจะเลือกศูนย์ตัวแรกซึ่งมีดัชนีที่เล็กที่สุด ข้อจำกัด: * 1 <= nodes.length <= 10000 * 0 <= node.value\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"pluck"} +{"task_id":"HumanEval\\/69","prompt":"\\ndef search(lst):\\n '''คุณจะได้รับรายการจำนวนเต็มบวกที่ไม่ว่าง ส่งคืนจำนวนเต็มที่มากที่สุดที่มากกว่าศูนย์และมีความถี่มากกว่าหรือเท่ากับค่าของจำนวนเต็มนั้นเอง ความถี่ของจำนวนเต็มคือจำนวนครั้งที่จำนวนเต็มนั้นปรากฏในรายการ หากไม่มีค่าดังกล่าว ให้ส่งคืน -1 ตัวอย่าง: search([4, 1, 2, 2, 3, 1]) == 2 search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3 search([5, 5, 4, 4, 4]) == -1\\n '''\\n","canonical_solution":" 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","test":"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","entry_point":"search"} +{"task_id":"HumanEval\\/70","prompt":"\\ndef strange_sort_list(lst):\\n '''กำหนดให้รายการจำนวนเต็มแสดงรายการในลำดับที่แปลกประหลาด การเรียงลำดับที่แปลกประหลาดคือเมื่อคุณเริ่มต้นด้วยค่าต่ำสุด จากนั้นจึงเป็นค่าสูงสุดของจำนวนเต็มที่เหลือ จากนั้นจึงเป็นค่าต่ำสุด และเป็นเช่นนี้ไปเรื่อยๆ ตัวอย่าง: strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3] strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5] strange_sort_list([]) == []\\n '''\\n","canonical_solution":" 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\\n","test":"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","entry_point":"strange_sort_list"} +{"task_id":"HumanEval\\/71","prompt":"\\ndef triangle_area(a, b, c):\\n '''กำหนดความยาวของด้านทั้งสามของสามเหลี่ยม ส่งคืนพื้นที่ของสามเหลี่ยมที่ปัดเศษเป็นทศนิยม 2 ตำแหน่งหากด้านทั้งสามประกอบเป็นสามเหลี่ยมที่ถูกต้อง มิฉะนั้น ส่งคืน -1 ด้านทั้งสามประกอบเป็นสามเหลี่ยมที่ถูกต้องเมื่อผลรวมของด้านสองด้านใดๆ มากกว่าด้านที่สาม ตัวอย่าง: triangle_area(3, 4, 5) == 6.00 triangle_area(1, 2, 10) == -1\\n '''\\n","canonical_solution":" 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","test":"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","entry_point":"triangle_area"} +{"task_id":"HumanEval\\/72","prompt":"\\ndef will_it_fly(q,w):\\n '''เขียนฟังก์ชันที่คืนค่า True หากวัตถุ q จะบิน และคืนค่า False หากไม่เป็นเช่นนั้น วัตถุ q จะบินได้หากมีความสมดุล (เป็นรายการพาลินโดรม) และผลรวมขององค์ประกอบน้อยกว่าหรือเท่ากับน้ำหนักสูงสุดที่เป็นไปได้ w ตัวอย่าง: will_it_fly([1, 2], 5) ➞ False # 1+2 น้อยกว่าน้ำหนักสูงสุดที่เป็นไปได้ แต่ไม่สมดุล will_it_fly([3, 2, 3], 1) ➞ False # มีความสมดุล แต่ 3+2+3 มากกว่าน้ำหนักสูงสุดที่เป็นไปได้ will_it_fly([3, 2, 3], 9) ➞ True # 3+2+3 น้อยกว่าน้ำหนักสูงสุดที่เป็นไปได้ และสมดุลแล้ว will_it_fly([3], 5) ➞ True # 3 น้อยกว่าน้ำหนักสูงสุดที่เป็นไปได้ และสมดุลแล้ว\\n '''\\n","canonical_solution":" if sum(q) > w:\\n return False\\n\\n i, j = 0, len(q)-1\\n while i true is_simple_power(2, 2) => true is_simple_power(8, 2) => true is_simple_power(3, 2) => false is_simple_power(3, 1) => false is_simple_power(5, 3) => false\\n \"\"\"\\n","canonical_solution":" if (n == 1): \\n return (x == 1) \\n power = 1\\n while (power < x): \\n power = power * n \\n return (power == x) \\n","test":"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","entry_point":"is_simple_power"} +{"task_id":"HumanEval\\/77","prompt":"\\ndef iscube(a):\\n '''เขียนฟังก์ชันที่รับจำนวนเต็ม a และส่งคืนค่า True หากจำนวนเต็มนี้เป็นกำลังสามของจำนวนเต็มบางตัว หมายเหตุ: คุณอาจถือว่าอินพุตนั้นถูกต้องเสมอ ตัวอย่าง: iscube(1) ==> True iscube(2) ==> False iscube(-1) ==> True iscube(64) ==> True iscube(0) ==> True iscube(180) ==> False\\n '''\\n","canonical_solution":" a = abs(a)\\n return int(round(a ** (1. \\/ 3))) ** 3 == a\\n","test":"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","entry_point":"iscube"} +{"task_id":"HumanEval\\/78","prompt":"\\ndef hex_key(num):\\n \"\"\"คุณได้รับมอบหมายให้เขียนฟังก์ชันที่รับเลขฐานสิบหกเป็นสตริงและนับจำนวนหลักฐานสิบหกที่เป็นจำนวนเฉพาะ (จำนวนเฉพาะหรือจำนวนเฉพาะคือจำนวนธรรมชาติที่มากกว่า 1 ซึ่งไม่ใช่ผลคูณของจำนวนธรรมชาติที่เล็กกว่าสองตัว) หลักฐานสิบหกคือ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F จำนวนเฉพาะคือ 2, 3, 5, 7, 11, 13, 17,... ดังนั้นคุณต้องกำหนดจำนวนหลักต่อไปนี้: 2, 3, 5, 7, B (= ทศนิยม 11), D (= ทศนิยม 13) หมายเหตุ: คุณอาจถือว่าอินพุตถูกต้องเสมอหรือเป็นสตริงว่าง และสัญลักษณ์ A, B, C, D, E, F เป็นตัวพิมพ์ใหญ่เสมอ ตัวอย่าง: สำหรับ num = \"AB\" ผลลัพธ์ควรเป็น 1 สำหรับ num = \"1077E\" ผลลัพธ์ควรเป็น 2 สำหรับ num = \"ABED1A33\" ผลลัพธ์ควรเป็น 4 สำหรับ num = \"123456789ABCDEF0\" ผลลัพธ์ควรเป็น 6 สำหรับ num = \"2020\" ผลลัพธ์ควรเป็น 2\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"hex_key"} +{"task_id":"HumanEval\\/79","prompt":"\\ndef decimal_to_binary(decimal):\\n \"\"\"คุณจะได้รับตัวเลขในรูปแบบทศนิยม และงานของคุณคือการแปลงตัวเลขดังกล่าวเป็นรูปแบบไบนารี ฟังก์ชันควรส่งคืนสตริง โดยแต่ละอักขระจะแสดงเป็นเลขฐานสอง อักขระแต่ละตัวในสตริงจะเป็น \"0\" หรือ \"1\" โดยจะมีอักขระพิเศษอีกสองตัวคือ \"db\" ที่จุดเริ่มต้นและจุดสิ้นสุดของสตริง อักขระพิเศษเหล่านี้จะช่วยในการจัดรูปแบบ ตัวอย่าง: decimal_to_binary(15) # ส่งคืน \"db1111db\" decimal_to_binary(32) # ส่งคืน \"db100000db\"\\n \"\"\"\\n","canonical_solution":" return \"db\" + bin(decimal)[2:] + \"db\"\\n","test":"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","entry_point":"decimal_to_binary"} +{"task_id":"HumanEval\\/80","prompt":"\\ndef is_happy(s):\\n \"\"\"คุณจะได้รับสตริง s งานของคุณคือตรวจสอบว่าสตริงมีความสุขหรือไม่ สตริงจะมีความสุขหากมีความยาวอย่างน้อย 3 และตัวอักษรที่ต่อเนื่องกัน 3 ตัวนั้นแตกต่างกัน ตัวอย่างเช่น: is_happy(a) => False is_happy(aa) => False is_happy(abcd) => True is_happy(aabb) => False is_happy(adb) => True is_happy(xyy) => False\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"is_happy"} +{"task_id":"HumanEval\\/81","prompt":"\\ndef numerical_letter_grade(grades):\\n \"\"\"ตอนนี้เป็นสัปดาห์สุดท้ายของภาคการศึกษาและครูต้องให้เกรดกับนักเรียน ครูได้สร้างอัลกอริทึมสำหรับการให้เกรดของเธอเอง ปัญหาเดียวคือ ครูทำรหัสที่ใช้ในการให้เกรดหายไป ครูได้ให้รายการ GPA ของนักเรียนบางคนแก่คุณ และคุณต้องเขียนฟังก์ชันที่สามารถแสดงรายการเกรดเป็นตัวอักษรโดยใช้ตารางต่อไปนี้: GPA | เกรดเป็นตัวอักษร 4.0 A+ > 3.7 A > 3.3 A- > 3.0 B+ > 2.7 B > 2.3 B- > 2.0 C+ > 1.7 C > 1.3 C- > 1.0 D+ > 0.7 D > 0.0 D- 0.0 E ตัวอย่าง: grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> [\\'A+\\', \\'B\\', \\'C-\\', \\'C\\', \\'A-\\']\\n \"\"\"\\n","canonical_solution":"\\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","test":"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","entry_point":"numerical_letter_grade"} +{"task_id":"HumanEval\\/82","prompt":"\\ndef prime_length(string):\\n \"\"\"เขียนฟังก์ชันที่รับสตริงและส่งคืน True หากความยาวสตริงเป็นจำนวนเฉพาะหรือส่งคืน False หากไม่เช่นนั้น ตัวอย่าง prime_length(\\'Hello\\') == True prime_length(\\'abcdcba\\') == True prime_length(\\'kittens\\') == True prime_length(\\'orange\\') == False\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"prime_length"} +{"task_id":"HumanEval\\/83","prompt":"\\ndef starts_one_ends(n):\\n \"\"\"กำหนดจำนวนเต็มบวก n ให้ส่งคืนจำนวนเต็มบวก n หลักที่เริ่มต้นหรือลงท้ายด้วย 1\\n \"\"\"\\n","canonical_solution":" if n == 1: return 1\\n return 18 * (10 ** (n - 2))\\n","test":"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","entry_point":"starts_one_ends"} +{"task_id":"HumanEval\\/84","prompt":"\\ndef solve(N):\\n \"\"\"กำหนดจำนวนเต็มบวก N ให้ส่งคืนผลรวมทั้งหมดของตัวเลขในรูปแบบไบนารี ตัวอย่าง สำหรับ N = 1000 ผลรวมของตัวเลขจะเท่ากับ 1 ผลลัพธ์ควรเป็น \"1\" สำหรับ N = 150 ผลรวมของตัวเลขจะเท่ากับ 6 ผลลัพธ์ควรเป็น \"110\" สำหรับ N = 147 ผลรวมของตัวเลขจะเท่ากับ 12 ผลลัพธ์ควรเป็น \"1100\" ตัวแปร: @N จำนวนเต็ม ข้อจำกัด: 0 ≤ N ≤ 10000 ผลลัพธ์: สตริงของตัวเลขไบนารี\\n \"\"\"\\n","canonical_solution":" return bin(sum(int(i) for i in str(N)))[2:]\\n","test":"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","entry_point":"solve"} +{"task_id":"HumanEval\\/85","prompt":"\\ndef add(lst):\\n \"\"\"กำหนดรายการจำนวนเต็มที่ไม่ว่าง lst. เพิ่มองค์ประกอบคู่ที่มีดัชนีคี่ ตัวอย่าง: add([4, 2, 6, 7]) ==> 2\\n \"\"\"\\n","canonical_solution":" return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])\\n","test":"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","entry_point":"add"} +{"task_id":"HumanEval\\/86","prompt":"\\ndef anti_shuffle(s):\\n \"\"\"เขียนฟังก์ชันที่รับสตริงและส่งคืนเวอร์ชันที่เรียงลำดับของสตริงนั้น เวอร์ชันที่เรียงลำดับของสตริงคือสตริงที่คำทั้งหมด (คั่นด้วยช่องว่าง) จะถูกแทนที่ด้วยคำใหม่ โดยที่อักขระทั้งหมดจะเรียงตามลำดับจากน้อยไปมากตามค่า ASCII หมายเหตุ: คุณควรคงลำดับของคำและช่องว่างในประโยคไว้ ตัวอย่างเช่น: anti_shuffle(\\'Hi\\') ส่งคืน \\'Hi\\' anti_shuffle(\\'hello\\') ส่งคืน \\'ehllo\\' anti_shuffle(\\'Hello World!!!\\') ส่งคืน \\'Hello !!!Wdlor\\'\\n \"\"\"\\n","canonical_solution":" return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])\\n","test":"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","entry_point":"anti_shuffle"} +{"task_id":"HumanEval\\/87","prompt":"\\ndef get_row(lst, x):\\n \"\"\"คุณจะได้รับข้อมูล 2 มิติในรูปแบบรายการซ้อน ซึ่งคล้ายกับเมทริกซ์ อย่างไรก็ตาม ต่างจากเมทริกซ์ ตรงที่แต่ละแถวอาจมีจำนวนคอลัมน์ต่างกัน เมื่อกำหนด lst และจำนวนเต็ม x ให้ค้นหาจำนวนเต็ม x ในรายการ และส่งคืนรายการของทูเพิล [(x1, y1), (x2, y2) ...] โดยที่แต่ละทูเพิลเป็นพิกัด - (แถว คอลัมน์) เริ่มต้นด้วย 0 เรียงลำดับพิกัดเบื้องต้นตามแถวในลำดับจากน้อยไปมาก นอกจากนี้ ให้เรียงลำดับพิกัดของแถวตามคอลัมน์ในลำดับจากมากไปน้อย ตัวอย่าง: get_row([ [1,2,3,4,5,6], [1,2,3,4,1,6], [1,2,3,4,5,1] ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)] get_row([], 1) == [] get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"get_row"} +{"task_id":"HumanEval\\/88","prompt":"\\ndef sort_array(array):\\n \"\"\"กำหนดอาร์เรย์ของจำนวนเต็มที่ไม่เป็นลบ ให้ส่งคืนสำเนาของอาร์เรย์ที่กำหนดหลังจากการเรียงลำดับ คุณจะเรียงลำดับอาร์เรย์ที่กำหนดในลำดับจากน้อยไปมาก หากผลรวม (ค่าดัชนีแรก ค่าดัชนีสุดท้าย) เป็นเลขคี่ หรือเรียงลำดับในลำดับจากมากไปน้อย หากผลรวม (ค่าดัชนีแรก ค่าดัชนีสุดท้าย) เป็นเลขคู่ หมายเหตุ: * อย่าเปลี่ยนแปลงอาร์เรย์ที่กำหนด ตัวอย่าง: * sort_array([]) => [] * sort_array([5]) => [5] * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5] * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]\\n \"\"\"\\n","canonical_solution":" return [] if len(array) == 0 else sorted(array, reverse= (array[0]+array[-1]) % 2 == 0) \\n","test":"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","entry_point":"sort_array"} +{"task_id":"HumanEval\\/89","prompt":"\\ndef encrypt(s):\\n \"\"\"สร้างฟังก์ชัน encrypt ที่รับสตริงเป็นอาร์กิวเมนต์และส่งคืนสตริงที่เข้ารหัสด้วยตัวอักษรที่หมุน ตัวอักษรควรหมุนในลักษณะที่ตัวอักษรเลื่อนลงสองคูณสองตำแหน่ง ตัวอย่างเช่น: encrypt(\\'hi\\') ส่งคืน \\'lm\\' encrypt(\\'asdfghjkl\\') ส่งคืน \\'ewhjklnop\\' encrypt(\\'gf\\') ส่งคืน \\'kj\\' encrypt(\\'et\\') ส่งคืน \\'ix\\'\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"encrypt"} +{"task_id":"HumanEval\\/90","prompt":"\\ndef next_smallest(lst):\\n \"\"\"คุณจะได้รับรายการจำนวนเต็ม เขียนฟังก์ชัน next_smallest() ที่ส่งคืนองค์ประกอบที่เล็กเป็นอันดับ 2 ของรายการ ส่งคืน None หากไม่มีองค์ประกอบดังกล่าว next_smallest([1, 2, 3, 4, 5]) == 2 next_smallest([5, 1, 4, 3, 2]) == 2 next_smallest([]) == None next_smallest([1, 1]) == None\\n \"\"\"\\n","canonical_solution":" lst = sorted(set(lst))\\n return None if len(lst) < 2 else lst[1]\\n","test":"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","entry_point":"next_smallest"} +{"task_id":"HumanEval\\/91","prompt":"\\ndef is_bored(S):\\n \"\"\"คุณจะได้รับคำจำนวนหนึ่ง และงานของคุณคือนับจำนวนความเบื่อหน่าย ความเบื่อหน่ายคือประโยคที่เริ่มต้นด้วยคำว่า \"I\" ประโยคจะถูกคั่นด้วย \\'.\\', \\'?\\' หรือ \\'!\\' ตัวอย่างเช่น:\\n >>> is_bored(\"Hello world\")\\n 0\\n >>> is_bored(\"The sky is blue. The sun is shining. I love this weather\")\\n 1\"\"\"\\n","canonical_solution":" import re\\n sentences = re.split(r'[.?!]\\s*', S)\\n return sum(sentence[0:2] == 'I ' for sentence in sentences)\\n","test":"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","entry_point":"is_bored"} +{"task_id":"HumanEval\\/92","prompt":"\\ndef any_int(x, y, z):\\n '''สร้างฟังก์ชันที่ใช้ตัวเลข 3 ตัว คืนค่าเป็นจริงหากตัวเลขตัวหนึ่งมีค่าเท่ากับผลรวมของอีกสองตัว และตัวเลขทั้งหมดเป็นจำนวนเต็ม คืนค่าเท็จในกรณีอื่น ๆ ตัวอย่าง any_int(5, 2, 7) ➞ True any_int(3, 2, 2) ➞ False any_int(3, -2, 1) ➞ True any_int(3.6, -2.2, 2) ➞ False\\n '''\\n","canonical_solution":" \\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","test":"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","entry_point":"any_int"} +{"task_id":"HumanEval\\/93","prompt":"\\ndef encode(message):\\n \"\"\"จงเขียนฟังก์ชันที่รับข้อความและเข้ารหัสโดยเปลี่ยนตัวพิมพ์ใหญ่-เล็กของตัวอักษรทั้งหมด และแทนที่สระทั้งหมดในข้อความด้วยตัวอักษรที่ปรากฏอยู่ข้างหน้าสระนั้น 2 ตำแหน่งในตัวอักษรภาษาอังกฤษ โดยถือว่ามีเฉพาะตัวอักษรเท่านั้น ตัวอย่าง:\\n >>> encode('test')\\n 'TGST'\\n >>> encode('This is a message')\\n 'tHKS KS C MGSSCGG'\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"encode"} +{"task_id":"HumanEval\\/94","prompt":"\\n\\ndef skjkasdkd(lst):\\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 สำหรับ lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] ผลลัพธ์ควรเป็น 25 สำหรับ lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] ผลลัพธ์ควรเป็น 13 สำหรับ lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] ผลลัพธ์ควรเป็น 11 สำหรับ lst = [0,81,12,3,1,21] ผลลัพธ์ควรเป็น 3 สำหรับ lst = [0,8,1,2,1,7] ผลลัพธ์ควรเป็น 7\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"skjkasdkd"} +{"task_id":"HumanEval\\/95","prompt":"\\ndef check_dict_case(dict):\\n \"\"\"ให้พจนานุกรมส่งกลับค่า True หากคีย์ทั้งหมดเป็นสตริงตัวพิมพ์เล็กหรือคีย์ทั้งหมดเป็นสตริงตัวพิมพ์ใหญ่ มิฉะนั้นให้ส่งกลับค่า False ฟังก์ชันควรส่งกลับค่า False หากพจนานุกรมที่กำหนดว่างเปล่า ตัวอย่าง: check_dict_case({\"a\":\"apple\", \"b\":\"banana\"}) ควรส่งกลับค่า True check_dict_case({\"a\":\"apple\", \"A\":\"banana\", \"B\":\"banana\"}) ควรส่งกลับค่า False check_dict_case({\"a\":\"apple\", 8:\"banana\", \"a\":\"apple\"}) ควรส่งกลับค่า False check_dict_case({\"Name\":\"John\", \"Age\":\"36\", \"City\":\"Houston\"}) ควรส่งกลับค่า False check_dict_case({\"STATE\":\"NC\", \"ZIP\":\"12345\" }) ควรส่งกลับค่า True\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"check_dict_case"} +{"task_id":"HumanEval\\/96","prompt":"\\ndef count_up_to(n):\\n \"\"\"ใช้ฟังก์ชันที่รับจำนวนเต็มที่ไม่เป็นลบและส่งคืนอาร์เรย์ของจำนวนเต็ม n แรกที่เป็นจำนวนเฉพาะและน้อยกว่า n ตัวอย่างเช่น: count_up_to(5) => [2,3] count_up_to(11) => [2,3,5,7] count_up_to(0) => [] count_up_to(20) => [2,3,5,7,11,13,17,19] count_up_to(1) => [] count_up_to(18) => [2,3,5,7,11,13,17]\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"count_up_to"} +{"task_id":"HumanEval\\/97","prompt":"\\ndef multiply(a, b):\\n \"\"\"ดำเนินการฟังก์ชันที่รับจำนวนเต็มสองจำนวนและส่งคืนผลคูณของหลักหน่วยของจำนวนเต็มเหล่านั้นให้สมบูรณ์ สมมติว่าอินพุตนั้นถูกต้องเสมอ ตัวอย่าง: multiply(148, 412) ควรส่งคืน 16, multiply(19, 28) ควรส่งคืน 72, multiply(2020, 1851) ควรส่งคืน 0, multiply(14,-15) ควรส่งคืน 20\\n \"\"\"\\n","canonical_solution":" return abs(a % 10) * abs(b % 10)\\n","test":"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","entry_point":"multiply"} +{"task_id":"HumanEval\\/98","prompt":"\\ndef count_upper(s):\\n \"\"\"กำหนดสตริง s ให้นับจำนวนสระตัวพิมพ์ใหญ่ในดัชนีคู่ ตัวอย่างเช่น count_upper(\\'aBCdEf\\') คืนค่า 1 count_upper(\\'abcdefg\\') คืนค่า 0 count_upper(\\'dBBE\\') คืนค่า 0\\n \"\"\"\\n","canonical_solution":" count = 0\\n for i in range(0,len(s),2):\\n if s[i] in \"AEIOU\":\\n count += 1\\n return count\\n","test":"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","entry_point":"count_upper"} +{"task_id":"HumanEval\\/99","prompt":"\\ndef closest_integer(value):\\n '''สร้างฟังก์ชันที่รับค่า (สตริง) ที่แสดงถึงตัวเลขและส่งคืนจำนวนเต็มที่ใกล้เคียงที่สุดกับตัวเลขนั้น หากตัวเลขมีระยะห่างเท่ากันจากจำนวนเต็มสองจำนวน ให้ปัดเศษออกจากศูนย์ ตัวอย่าง >>> Closest_integer(\"10\") 10 >>> Closest_integer(\"15.3\") 15 หมายเหตุ: การปัดเศษออกจากศูนย์หมายความว่าหากตัวเลขที่กำหนดมีระยะห่างเท่ากันจากจำนวนเต็มสองจำนวน จำนวนที่คุณควรส่งคืนคือจำนวนที่อยู่ห่างจากศูนย์มากที่สุด ตัวอย่างเช่น Closest_integer(\"14.5\") ควรส่งคืน 15 และ Closest_integer(\"-14.5\") ควรส่งคืน -15\\n '''\\n","canonical_solution":" 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","test":"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","entry_point":"closest_integer"} +{"task_id":"HumanEval\\/100","prompt":"\\ndef make_a_pile(n):\\n \"\"\"เมื่อกำหนดจำนวนเต็มบวก n คุณต้องสร้างกองหิน n ระดับ ระดับแรกมีหิน n ก้อน จำนวนหินในระดับถัดไปคือ - จำนวนคี่ถัดไปถ้า n เป็นคี่ - จำนวนคู่ถัดไปถ้า n เป็นคู่ ส่งคืนจำนวนหินในแต่ละระดับในรายการ โดยที่องค์ประกอบที่ดัชนี i แสดงถึงจำนวนหินในระดับ (i+1) ตัวอย่าง:\\n >>> make_a_pile(3)\\n [3, 5, 7]\"\"\"\\n","canonical_solution":" return [n + 2*i for i in range(n)]\\n","test":"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","entry_point":"make_a_pile"} +{"task_id":"HumanEval\\/101","prompt":"\\ndef words_string(s):\\n \"\"\"คุณจะได้รับสตริงคำที่คั่นด้วยเครื่องหมายจุลภาคหรือช่องว่าง งานของคุณคือแยกสตริงออกเป็นคำและส่งคืนอาร์เรย์ของคำเหล่านั้น ตัวอย่างเช่น: words_string(\"Hi, my name is John\") == [\"Hi\", \"my\", \"name\", \"is\", \"John\"] words_string(\"One, two, three, four, five, six\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"words_string"} +{"task_id":"HumanEval\\/102","prompt":"\\ndef choose_num(x, y):\\n \"\"\"ฟังก์ชันนี้ใช้ค่า x และ y เป็นจำนวนบวกสองค่า และส่งคืนจำนวนเต็มคู่ที่มากที่สุดที่อยู่ในช่วง [x, y] รวม หากไม่มีค่าดังกล่าว ฟังก์ชันควรส่งคืน -1 ตัวอย่างเช่น: choose_num(12, 15) = 14 choose_num(13, 12) = -1\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"choose_num"} +{"task_id":"HumanEval\\/103","prompt":"\\ndef rounded_avg(n, m):\\n \"\"\"คุณได้รับจำนวนเต็มบวกสองจำนวนคือ n และ m และงานของคุณคือคำนวณค่าเฉลี่ยของจำนวนเต็มตั้งแต่ n ถึง m (รวมทั้ง n และ m) ปัดเศษคำตอบเป็นจำนวนเต็มที่ใกล้เคียงที่สุดและแปลงเป็นเลขฐานสอง หาก n มากกว่า m ให้ส่งคืน -1 ตัวอย่าง: rounded_avg(1, 5) => \"0b11\" rounded_avg(7, 5) => -1 rounded_avg(10, 20) => \"0b1111\" rounded_avg(20, 33) => \"0b11010\"\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"rounded_avg"} +{"task_id":"HumanEval\\/104","prompt":"\\ndef unique_digits(x):\\n \"\"\"กำหนดรายการของจำนวนเต็มบวก x ให้ส่งคืนรายการที่เรียงลำดับขององค์ประกอบทั้งหมดที่ไม่มีเลขคู่ หมายเหตุ: รายการที่ส่งคืนควรเรียงลำดับตามลำดับเพิ่มขึ้น ตัวอย่างเช่น:\\n >>> unique_digits([15, 33, 1422, 1])\\n [1, 15, 33]\\n >>> unique_digits([152, 323, 1422, 10])\\n []\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"unique_digits"} +{"task_id":"HumanEval\\/105","prompt":"\\ndef by_length(arr):\\n \"\"\"กำหนดอาร์เรย์ของจำนวนเต็ม ให้เรียงลำดับจำนวนเต็มที่อยู่ระหว่าง 1 ถึง 9 รวมทั้งหมด ย้อนกลับอาร์เรย์ผลลัพธ์ แล้วแทนที่แต่ละหลักด้วยชื่อที่สอดคล้องกันจาก \"หนึ่ง\" \"สอง\" \"สาม\" \"สี่\" \"ห้า\" \"หก\" \"เจ็ด\" \"แปด\" \"เก้า\" ตัวอย่าง: arr = [2, 1, 1, 4, 5, 8, 2, 3] -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8] -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1] return [\"Eight\", \"Five\", \"Four\", \"Three\", \"Two\", \"Two\", \"One\", \"One\"] ถ้าอาร์เรย์ว่างเปล่า ให้ส่งคืนอาร์เรย์ว่าง: arr = [] return [] ถ้าอาร์เรย์มีตัวเลขแปลกๆ ให้ละเว้น: arr = [1, -1 , 55] -> sort arr -> [-1, 1, 55] -> reverse arr -> [55, 1, -1] return = [\\'One\\']\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"by_length"} +{"task_id":"HumanEval\\/106","prompt":"\\ndef f(n):\\n \"\"\"นำฟังก์ชัน f ที่รับ n เป็นพารามิเตอร์มาใช้งาน และส่งคืนรายการขนาด n โดยที่ค่าขององค์ประกอบที่ดัชนี i จะเป็นแฟกทอเรียลของ i หาก i เป็นเลขคู่ หรือเป็นผลรวมของตัวเลขตั้งแต่ 1 ถึง i ในกรณีอื��น i เริ่มจาก 1 แฟกทอเรียลของ i คือการคูณตัวเลขตั้งแต่ 1 ถึง i (1 * 2 * ... * i) ตัวอย่าง: f(5) == [1, 2, 6, 24, 15]\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"f"} +{"task_id":"HumanEval\\/107","prompt":"\\ndef even_odd_palindrome(n):\\n \"\"\"กำหนดจำนวนเต็มบวก n ให้ส่งคืนทูเพิลที่มีจำนวนพาลินโดรมจำนวนเต็มคู่และคี่ที่อยู่ในช่วง (1, n) รวม ตัวอย่าง 1: อินพุต: 3 เอาต์พุต: (1, 2) คำอธิบาย: พาลินโดรมจำนวนเต็มคือ 1, 2, 3 โดยหนึ่งในนั้นเป็นจำนวนคู่ และอีกสองอันเป็นจำนวนคี่ ตัวอย่าง 2: อินพุต: 12 เอาต์พุต: (4, 6) คำอธิบาย: พาลินโดรมจำนวนเต็มคือ 1, 2, 3, 4, 5, 6, 7, 8, 9, 11 โดยสี่อันเป็นจำนวนคู่ และอีก 6 อันเป็นจำนวนคี่ หมายเหตุ: 1. 1 <= n <= 10^3 2. ทูเพิลที่ส่งคืนมีจำนวนพาลินโดรมจำนวนเต็มคู่และคี่ตามลำดับ\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"even_odd_palindrome"} +{"task_id":"HumanEval\\/108","prompt":"\\ndef count_nums(arr):\\n \"\"\"เขียนฟังก์ชัน count_nums ซึ่งรับอาร์เรย์ของจำนวนเต็ม และส่งคืนจำนวนองค์ประกอบที่ผลรวมของตัวเลข > 0 หากตัวเลขเป็นค่าลบ ตัวเลขที่มีเครื่องหมายตัวแรกจะเป็นค่าลบ เช่น -123 มีตัวเลขที่มีเครื่องหมายคือ -1, 2 และ 3\\n >>> count_nums([]) == 0\\n >>> count_nums([-1, 11, -11]) == 1\\n >>> count_nums([1, 1, 2]) == 3\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"count_nums"} +{"task_id":"HumanEval\\/109","prompt":"\\ndef move_one_ball(arr):\\n \"\"\"เรามีอาร์เรย์ \\'arr\\' ของจำนวนเต็ม N ตัว arr[1], arr[2], ..., arr[N] ตัวเลขในอาร์เรย์จะถูกเรียงลำดับแบบสุ่ม งานของคุณคือตรวจสอบว่าเป็นไปได้หรือไม่ที่จะเรียงลำดับอาร์เรย์ในลำดับที่ไม่ลดลงโดยดำเนินการต่อไปนี้กับอาร์เรย์ที่กำหนด: คุณสามารถเลื่อนไปทางขวาได้หลายครั้งเท่าที่ต้องการ การเลื่อนไปทางขวาหนึ่งครั้งหมายถึงการเลื่อนองค์ประกอบทั้งหมดในอาร์เรย์ไปหนึ่งตำแหน่งในทิศทางที่ถูกต้อง องค์ประกอบสุดท้ายของอาร์เรย์จะย้ายไปที่ตำแหน่งเริ่มต้นในอาร์เรย์ เช่น ดัชนีที่ 0 หากสามารถรับอาร์เรย์ที่เรียงลำดับได้โดยดำเนินการข้างต้น ให้ส่งคืนค่า True มิฉะนั้นให้ส่งคืนค่า False หากอาร์เรย์ที่กำหนดว่างเปล่า ให้ส่งคืนค่า True หมายเหตุ: รายการที่กำหนดให้มีองค์ประกอบที่ไม่ซ้ำกันอย่างแน่นอน ตัวอย่างเช่น: move_one_ball([3, 4, 5, 1, 2])==>True คำอธิบาย: โดยการเลื่อนไปทางขวา 2 ครั้ง จะทำให้ได้ลำดับที่ไม่ลดลงสำหรับอาร์เรย์ที่กำหนด move_one_ball([3, 5, 4, 1, 2])==>เท็จ คำอธิบาย: ไม่สามารถรับลำดับที่ไม่ลดลงสำหรับอาร์เรย์ที่กำหนดได้โดยดำเนินการเลื่อนไปทางขวาจำนวนใดๆ ก็ได้\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"move_one_ball"} +{"task_id":"HumanEval\\/110","prompt":"\\ndef exchange(lst1, lst2):\\n \"\"\"ในปัญหานี้ คุณจะใช้ฟังก์ชันที่รับรายการตัวเลขสองรายการ และพิจารณาว่าเป็นไปได้หรือไม่ที่จะทำการแลกเปลี่ยนองค์ประกอบระหว่างรายการเหล่านั้นเพื่อทำให้ lst1 เป็นรายการของตัวเลขคู่เท่านั้น ไม่มีข้อจำกัดเกี่ยวกับจำนวนองค์ประกอบที่แลกเปลี่ยนระหว่าง lst1 และ lst2 หากสามารถแลกเปลี่ยนองค์ประกอบระหว่าง lst1 และ lst2 เพื่อทำให้องค์ประกอบทั้งหมดของ lst1 เป็นเลขคู่ ให้ส่งคืน \"YES\" มิฉะนั้น ให้ส่งคืน \"NO\" ตัวอย่างเช่น: exchange([1, 2, 3, 4], [1, 2, 3, 4]) => \"YES\" exchange([1, 2, 3, 4], [1, 5, 3, 4]) => \"NO\" ถือว่ารายการอินพุตจะไม่ว่างเปล่า\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"exchange"} +{"task_id":"HumanEval\\/111","prompt":"\\ndef histogram(test):\\n \"\"\"กำหนดสตริงที่แสดงถึงตัวอักษรตัวเล็กที่คั่นด้วยช่องว่าง ให้ส่งคืนพจนานุกรมของตัวอักษรที่มีการทำซ้ำมากที่สุดและมีจำนวนที่สอดคล้องกัน หากมีตัวอักษรหลายตัวปรากฏเหมือนกัน ให้ส่งคืนทั้งหมด ตัวอย่าง: histogram(\\'ab c\\') == {\\'a\\': 1, \\'b\\': 1, \\'c\\': 1} histogram(\\'abb a\\') == {\\'a\\': 2, \\'b\\': 2} histogram(\\'abca b\\') == {\\'a\\': 2, \\'b\\': 2} histogram(\\'bbbb a\\') == {\\'b\\': 4} histogram(\\'\\') == {}\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"histogram"} +{"task_id":"HumanEval\\/112","prompt":"\\ndef reverse_delete(s,c):\\n \"\"\"งาน เราได้รับสตริง 2 ตัวคือ s และ c คุณต้องลบตัวอักษรทั้งหมดใน s ที่เท่ากับตัวอักษรใดๆ ใน c จากนั้นตรวจสอบว่าสตริงผลลัพธ์เป็นพาลินโดรมหรือไม่ สตริงจะถูกเรียกว่าพาลินโดรมหากอ่านแบบย้อนกลับและไปข้างหน้าเหมือนกัน คุณควรส่งคืนทูเพิลที่มีสตริงผลลัพธ์และค่า True\\/False สำหรับการตรวจสอบ ตัวอย่าง สำหรับ s = \"abcde\", c = \"ae\" ผลลัพธ์ควรเป็น (\\'bcd\\',False) สำหรับ s = \"abcdef\", c = \"b\" ผลลัพธ์ควรเป็น (\\'acdef\\',False) สำหรับ s = \"abcdedcba\", c = \"ab\" ผลลัพธ์ควรเป็น (\\'cdedc\\',True)\\n \"\"\"\\n","canonical_solution":" s = ''.join([char for char in s if char not in c])\\n return (s,s[::-1] == s)\\n","test":"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","entry_point":"reverse_delete"} +{"task_id":"HumanEval\\/113","prompt":"\\ndef odd_count(lst):\\n \"\"\"ให้รายการสตริงที่มีเฉพาะตัวเลข ให้ส่งคืนรายการ องค์ประกอบ i แต่ละตัวของเอาต์พุตควรเป็น \"จำนวนองค์ประกอบคี่ในสตริง i ของอินพุต\" โดยที่ i ทั้งหมดควรถูกแทนที่ด้วยจำนวนหลักคี่ในสตริงที่ i ของอินพุต\\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.\"]\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"odd_count"} +{"task_id":"HumanEval\\/114","prompt":"\\ndef minSubArraySum(nums):\\n \"\"\"กำหนดอาร์เรย์ของจำนวนเต็ม nums หาผลรวมขั้นต่ำของอาร์เรย์ย่อยของ nums ที่ไม่ว่าง ตัวอย่าง minSubArraySum([2, 3, 4, 1, 2, 4]) == 1 minSubArraySum([-1, -2, -3]) == -6\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"minSubArraySum"} +{"task_id":"HumanEval\\/115","prompt":"\\ndef max_fill(grid, capacity):\\n import math\\n \"\"\"คุณจะได้รับตารางบ่อน้ำรูปสี่เหลี่ยมผืนผ้า แต่ละแถวแทนบ่อน้ำ 1 บ่อ และแต่ละบ่อน้ำในแถวแทนน้ำ 1 หน่วย แต่ละบ่อน้ำจะมีถังที่สอดคล้องกันซึ่งใช้สำหรับตักน้ำออกจากบ่อ และถังทั้งหมดจะมีความจุเท่ากัน หน้าที่ของคุณคือใช้ถังเพื่อเทน้ำออกจากบ่อ กำหนดจำนวนครั้งที่คุณต้องการลดถังลง ตัวอย่างที่ 1: อินพุต: grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]] bucket_capacity : 1 เอาต์พุต: 6 ตัวอย่างที่ 2: อินพุต: grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]] bucket_capacity : 2 เอาต์พุต: 5 ตัวอย่างที่ 3: อินพุต: grid : [[0,0,0], [0,0,0]] bucket_capacity : 5 เอาต์พุต: 0 ข้อจำกัด: * บ่อน้ำทั้งหมดมีความยาวเท่ากัน * 1 <= grid.length <= 10^2 * 1 <= grid[:,1].length <= 10^2 * grid[i][j] -> 0 | 1 * 1 <= ความจุ <= 10\\n \"\"\"\\n","canonical_solution":" return sum([math.ceil(sum(arr)\\/capacity) for arr in grid])\\n","test":"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","entry_point":"max_fill"} +{"task_id":"HumanEval\\/116","prompt":"\\ndef sort_array(arr):\\n \"\"\"ใน Kata นี้ คุณต้องเรียงลำดับอาร์เรย์ของจำนวนเต็มที่ไม่เป็นลบตามจำนวนเลขฐานสองที่แสดงเป็นเลขฐานสองจากน้อยไปมาก สำหรับจำนวนเลขฐานสองที่ใกล้เคียงกัน ให้เรียงลำดับตามค่าทศนิยม ซึ่งจะต้องดำเนินการดังนี้:\\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]\"\"\"\\n","canonical_solution":" return sorted(sorted(arr), key=lambda x: bin(x)[2:].count('1'))\\n","test":"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","entry_point":"sort_array"} +{"task_id":"HumanEval\\/117","prompt":"\\ndef select_words(s, n):\\n \"\"\"เมื่อกำหนดสตริง s และจำนวนธรรมชาติ n คุณได้รับมอบหมายให้ใช้งานฟังก์ชันที่ส่งคืนรายการคำทั้งหมดจากสตริง s ที่มีพยัญชนะ n ตัวพอดี โดยคำเหล่านี้จะปรากฏตามลำดับในสตริง s หากสตริง s ว่างเปล่า ฟังก์ชันควรส่งคืนรายการว่างเปล่า หมายเหตุ: คุณอาจถือว่าสตริงอินพุตมีเฉพาะตัวอักษรและช่องว่างเท่านั้น ตัวอย่าง: select_words(\"Mary had a little lamb\", 4) ==> [\"little\"] select_words(\"Mary had a little lamb\", 3) ==> [\"Mary\", \"lamb\"] select_words(\"simple white space\", 2) ==> [] select_words(\"Hello world\", 4) ==> [\"world\"] select_words(\"Uncle sam\", 3) ==> [\"Uncle\"]\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"select_words"} +{"task_id":"HumanEval\\/118","prompt":"\\ndef get_closest_vowel(word):\\n \"\"\"คุณจะได้รับคำศัพท์หนึ่งคำ งานของคุณคือค้นหาสระที่ใกล้เคียงที่สุดที่อยู่ระหว่างพยัญชนะสองตัวจากด้านขวาของคำ (ต้องตรงตามตัวพิมพ์ใหญ่-เล็ก) สระในตอนต้นและตอนท้ายไม่นับ ส่งคืนสตริงว่างหา��คุณไม่พบสระที่ตรงตามเงื่อนไขข้างต้น คุณอาจถือว่าสตริงที่กำหนดมีเฉพาะตัวอักษรภาษาอังกฤษเท่านั้น ตัวอย่าง: get_closest_vowel(\"yogurt\") ==> \"u\" get_closest_vowel(\"FULL\") ==> \"U\" get_closest_vowel(\"quick\") ==> \"\" get_closest_vowel(\"ab\") ==> \"\"\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"get_closest_vowel"} +{"task_id":"HumanEval\\/119","prompt":"\\ndef match_parens(lst):\\n '''คุณจะได้รับรายการสตริงสองสตริง โดยสตริงทั้งสองประกอบด้วยวงเล็บเปิด \\'(\\' หรือวงเล็บปิด \\')\\' เท่านั้น งานของคุณคือตรวจสอบว่าสามารถต่อสตริงทั้งสองเข้าด้วยกันในลำดับใด ๆ ได้หรือไม่ สตริงที่ได้จะดีหรือไม่ สตริง S จะถือว่าดีก็ต่อเมื่อวงเล็บทั้งหมดใน S สมดุลกัน ตัวอย่างเช่น สตริง \\'(())()\\' ดีในขณะที่สตริง \\'())\\' ไม่ดี ให้ส่งคืน \\'ใช่\\' หากมีวิธีสร้างสตริงที่ดี และส่งคืน \\'ไม่ใช่\\' หากไม่เป็นเช่นนั้น ตัวอย่าง: match_parens([\\'()(\\', \\')\\']) == \\'ใช่\\' match_parens([\\')\\', \\')\\']) == \\'ไม่\\'\\n '''\\n","canonical_solution":" 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","test":"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","entry_point":"match_parens"} +{"task_id":"HumanEval\\/120","prompt":"\\ndef maximum(arr, k):\\n \"\"\"กำหนดอาร์เรย์ arr ของจำนวนเต็มและจำนวนเต็มบวก k ให้ส่งคืนรายการที่เรียงลำดับความยาว k พร้อมตัวเลขสูงสุด k ตัวใน arr ตัวอย่างที่ 1: อินพุต: arr = [-3, -4, 5], k = 3 เอาต์พุต: [-4, -3, 5] ตัวอย่างที่ 2: อินพุต: arr = [4, -4, 4], k = 2 เอาต์พุต: [4, 4] ตัวอย่างที่ 3: อินพุต: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1 เอาต์พุต: [2] หมายเหตุ: 1. ความยาวของอาร์เรย์จะอยู่ในช่วง [1, 1000] 2. องค์ประกอบในอาร์เรย์จะอยู่ในช่วง [-1000, 1000] 3. 0 <= k <= len(arr)\\n \"\"\"\\n","canonical_solution":" if k == 0:\\n return []\\n arr.sort()\\n ans = arr[-k:]\\n return ans\\n","test":"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","entry_point":"maximum"} +{"task_id":"HumanEval\\/121","prompt":"\\ndef solution(lst):\\n \"\"\"กำหนดรายการจำนวนเต็มที่ไม่ว่าง ให้ส่งคืนผลรวมขององค์ประกอบคี่ทั้งหมดที่อยู่ในตำแหน่งคู่ ตัวอย่าง solution([5, 8, 7, 1]) ==> 12 solution([3, 3, 3, 3, 3]) ==> 9 solution([30, 13, 24, 321]) ==>0\\n \"\"\"\\n","canonical_solution":" return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])\\n","test":"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","entry_point":"solution"} +{"task_id":"HumanEval\\/122","prompt":"\\ndef add_elements(arr, k):\\n \"\"\"กำหนดอาร์เรย์ของจำนวนเต็ม arr และจำนวนเต็ม k ที่ไม่ว่าง ให้ส่งคืนผลรวมขององค์ประกอบที่มีตัวเลขไม่เกินสองหลักจากองค์ประกอบ k แรกของ arr ตัวอย่าง: อินพุต: arr = [111,21,3,4000,5,6,7,8,9], k = 4 เอาต์พุต: 24 # ผลรวมของ 21 + 3 เงื่อนไข: 1. 1 <= len(arr) <= 100 2. 1 <= k <= len(arr)\\n \"\"\"\\n","canonical_solution":" return sum(elem for elem in arr[:k] if len(str(elem)) <= 2)\\n","test":"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","entry_point":"add_elements"} +{"task_id":"HumanEval\\/123","prompt":"\\ndef get_odd_collatz(n):\\n \"\"\"กำหนดจำนวนเต็มบวก n ให้ส่งคืนรายการที่เรียงลำดับแล้วที่มีจำนวนคี่ในลำดับคอลลาตซ์ สมมติฐานคอลลาตซ์เป็นสมมติฐานทางคณิตศาสตร์ที่เกี่ยวข้องกับลำดับที่กำหนดดังต่อไปนี้: เริ่มต้นด้วยจำนวนเต็มบวก n ใดๆ จากนั้นแต่ละเทอมจะได้มาจากเทอมก่อนหน้าดังนี้: ถ้าเทอมก่อนหน้าเป็นเลขคู่ เทอมถัดไปจะเป็นครึ่งหนึ่งของเทอมก่อนหน้า ถ้าเทอมก่อนหน้าเป็นเลขคี่ เทอมถัดไปจะเป็น 3 เท่าของเทอมก่อนหน้าบวก 1 สมมติฐานคือไม่ว่าค่า n จะเป็นเท่าใด ลำดับจะถึง 1 เสมอ หมายเหตุ: 1. Collatz(1) คือ [1] 2. ส่งคืนรายการที่เรียงลำดับจากน้อยไปมาก ตัวอย่างเช่น: get_odd_collatz(5) ส่งคืน [1, 5] # ลำดับคอลลาตซ์สำหรับ 5 คือ [5, 16, 8, 4, 2, 1] ดังนั้นเลขคี่จึงเป็น 1 และ 5 เท่านั้น\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"get_odd_collatz"} +{"task_id":"HumanEval\\/124","prompt":"\\ndef valid_date(date):\\n \"\"\"คุณต้องเขียนฟังก์ชันที่ตรวจสอบสตริงวันที่ที่กำหนดและส่งคืนค่า True หากวันที่นั้นถูกต้อง มิฉะนั้นจะส่งคืนค่า False วันที่นั้นจะถูกต้องหากเป็นไปตามกฎทั้งหมดต่อไปนี้: 1. สตริงวันที่ไม่ว่างเปล่า 2. จำนวนวันไม่น้อยกว่า 1 วันหรือสูงกว่า 31 วันสำหรับเดือน 1,3,5,7,8,10,12 และจำนวนวันไม่น้อยกว่า 1 วันหรือสูงกว่า 30 วันสำหรับเดือน 4,6,9,11 และจำนวนวันต้องไม่น้อยกว่า 1 และไม่สูงกว่า 29 สำหรับเดือนที่ 2 3. เดือนไม่ควรน้อยกว่า 1 และไม่สูงกว่า 12 4. วันที่ควรอยู่ในรูปแบบ mm-dd-yyyy เช่น valid_date(\\'03-11-2000\\') => True valid_date(\\'15-01-2012\\') => False valid_date(\\'04-0-2040\\') => False valid_date(\\'06-04-2020\\') => True valid_date(\\'06\\/04\\/2020\\') => False\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"valid_date"} +{"task_id":"HumanEval\\/125","prompt":"\\ndef split_words(txt):\\n '''กำหนดสตริงของคำ ให้ส่งคืนรายการคำที่แบ่งตามช่องว่าง ถ้าไม่มีช่องว่างในข้อความ คุณควรแบ่งด้วยเครื่องหมายจุลภาค \\' ถ้าไม่มีเครื่องหมายจุลภาค คุณควรส่งคืนจำนวนตัวอักษรพิมพ์เล็กที่มีลำดับคี่ในตัวอักษร ord(\\'a\\') = 0, ord(\\'b\\') = 1, ... ord(\\'z\\') = 25 ตัวอย่าง split_words(\"Hello world!\") ➞ [\"Hello\", \"world!\"] split_words(\"Hello,world!\") ➞ [\"Hello\", \"world!\"] split_words(\"abcdef\") == 3\\n '''\\n","canonical_solution":" 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","test":"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","entry_point":"split_words"} +{"task_id":"HumanEval\\/126","prompt":"\\ndef is_sorted(lst):\\n '''ให้แสดงรายการตัวเลข ให้ส่งคืนว่าตัวเลขเหล่านั้นเรียงลำดับจากน้อยไปมากหรือไม่ หากรายการมีตัวเลขเดียวกันซ้ำกันมากกว่า 1 ตัว ให้ส่งคืนค่า False สมมติว่าไม่มีตัวเลขติดลบและมีเพียงจำนวนเต็มเท่านั้น ตัวอย่าง is_sorted([5]) ➞ True is_sorted([1, 2, 3, 4, 5]) ➞ True is_sorted([1, 3, 2, 4, 5]) ➞ False is_sorted([1, 2, 3, 4, 5, 6]) ➞ True is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False is_sorted([1, 2, 2, 3, 3, 4]) ➞ True is_sorted([1, 2, 2, 2, 3, 4]) ➞ False\\n '''\\n","canonical_solution":" 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","test":"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","entry_point":"is_sorted"} +{"task_id":"HumanEval\\/127","prompt":"\\ndef intersection(interval1, interval2):\\n \"\"\"คุณจะได้รับช่วงสองช่วง โดยแต่ละช่วงเป็นคู่ของจำนวนเต็ม ตัวอย่างเช่น ช่วง = (start, end) = (1, 2) ช่วงที่กำหนดเป็นช่วงปิด ซึ่งหมายความว่าช่วง (start, end) ประกอบด้วยทั้ง start และ end สำหรับแต่ละช่วงที่กำหนด จะถือว่า start น้อยกว่าหรือเท่ากับ end งานของคุณคือการกำหนดว่าความยาวของจุดตัดของช่วงทั้งสองนี้เป็นจำนวนเฉพาะหรือไม่ ตัวอย่างเช่น จุดตัดของช่วง (1, 3), (2, 4) คือ (2, 3) ซึ่งมีความยาวเท่ากับ 1 ซึ่งไม่ใช่จำนวนเฉพาะ หากความยาวของจุดตัดเป็นจำนวนเฉพาะ ให้ส่งคืน \"YES\" มิฉะนั้น ให้ส่งคืน \"NO\" หากช่วงทั้งสองไม่ตัดกัน ให้ส่งคืน \"NO\" [อินพุต\\/เอาต์พุต] ตัวอย่าง: จุดตัด ((1, 2), (2, 3)) ==> \"ไม่ใช่\" จุดตัด ((-1, 1), (0, 4)) ==> \"ไม่ใช่\" จุดตัด ((-3, -1), (-5, 5)) ==> \"ใช่\"\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"intersection"} +{"task_id":"HumanEval\\/128","prompt":"\\ndef prod_signs(arr):\\n \"\"\"คุณจะได้รับอาร์เรย์ arr ของจำนวนเต็ม และคุณต้องส่งคืนผลรวมของขนาดของจำนวนเต็มคูณด้วยผลคูณของเครื่องหมายทั้งหมดของแต่ละจำนวนในอาร์เรย์ ซึ่งแสดงด้วย 1, -1 หรือ 0 หมายเหตุ: ส่งคืน None สำหรับ arr ที่ว่างเปล่า ตัวอย่าง:\\n >>> prod_signs([1, 2, 2, -4]) == -9\\n >>> prod_signs([0, 1]) == 0\\n >>> prod_signs([]) == None\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"prod_signs"} +{"task_id":"HumanEval\\/129","prompt":"\\ndef minPath(grid, k):\\n \"\"\"กำหนดตารางที่มี N แถวและ N คอลัมน์ (N >= 2) และจำนวนเต็มบวก k เซลล์แต่ละเซลล์ของตารางจะมีค่า จำนวนเต็มทุกจำนวนในช่วง [1, N * N] รวมอยู่ด้วยจะปรากฏบนเซลล์ของตารางเพียงครั้งเดียว คุณต้องค้นหาเส้นทางที่สั้นที่สุดของความยาว k ในตาราง คุณสามารถเริ่มต้นจากเซลล์ใดก็ได้ และในแต่ละขั้นตอน คุณสามารถย้ายไปยังเซลล์ข้างเคียงเซลล์ใดก็ได้ กล่าวอีกนัยหนึ่งคือ คุณสามารถไปยังเซลล์ที่แบ่งปันขอบกับเซลล์ปัจจุบันของคุณได้ โปรดทราบว่าเส้นทางที่มีความยาว k หมายถึงการเยี่ยมชมเซลล์ k พอดี (ไม่จำเป็นต้องแยกจากกัน) คุณไม่สามารถออกจากตารางได้ เส้นทาง A (ความยาว k) ถือว่าน้อยกว่าเส้นทาง B (ความยาว k) หากหลังจากสร้างรายการค่าตามลำดับในเซลล์ที่ A และ B ผ่าน (เรียกว่า lst_A และ lst_B) แล้ว lst_A จะน้อยกว่า lst_B ตามพจนานุกรม กล่าวอีกนัยหนึ่งคือ มีดัชนีจำนวนเต็ม i (1 <= i <= k) ที่ทำให้ lst_A[i] < lst_B[i] และสำหรับ j ใดๆ (1 <= j < i) เราจะได้ lst_A[j] = lst_B[j] รับประกันว่าคำตอบจะไม่ซ้ำกัน ส่งคืนรายการค่าตามลำดับในเซลล์ที่เส้นทางขั้นต่ำผ่าน ตัวอย่าง: อินพุต: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3 เอาต์พุต: [1, 2, 1] อินพุต: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1 เอาต์พุต: [1]\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"minPath"} +{"task_id":"HumanEval\\/130","prompt":"\\ndef tri(n):\\n \"\"\"ทุกคนรู้จักลำดับฟีโบนัชชี ซึ่งนักคณิตศาสตร์ได้ศึกษาอย่างลึกซึ้งในช่วงสองศตวรรษที่ผ่านมา อย่างไรก็ตาม สิ่งที่ผู้คนไม่รู้ก็คือลำดับทริโบนัชชี ลำดับทริโบนัชชีถูกกำหนดโดยการเกิดซ้ำ: tri(1) = 3 tri(n) = 1 + n \\/ 2 ถ้า n เป็นเลขคู่ tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1) ถ้า n เป็นเลขคี่ ตัวอย่างเช่น: tri(2) = 1 + (2 \\/ 2) = 2 tri(4) = 3 tri(3) = tri(2) + tri(1) + tri(4) = 2 + 3 + 3 = 8 คุณได้รับเลขจำนวนเต็มที่ไม่เป็นลบ n คุณต้องส่งคืนรายการของตัวเลข n + 1 แรกของลำดับทริโบนัชชี ตัวอย่าง: tri(3) = [1, 3, 2, 8]\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"tri"} +{"task_id":"HumanEval\\/131","prompt":"\\ndef digits(n):\\n \"\"\"กำหนดจำนวนเต็มบวก n ให้ส่งคืนผลคูณของหลักคี่ ส่งคืน 0 ถ้าหลักทั้งหมดเป็นเลขคู่ ตัวอย่างเช่น: digits(1) == 1 digits(4) == 0 digits(235) == 15\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"digits"} +{"task_id":"HumanEval\\/132","prompt":"\\ndef is_nested(string):\\n '''สร้างฟังก์ชันที่รับสตริงเป็นอินพ���ตซึ่งประกอบด้วยวงเล็บเหลี่ยมเท่านั้น ฟังก์ชันควรส่งคืนค่า True ก็ต่อเมื่อมีลำดับย่อยที่ถูกต้องของวงเล็บซึ่งวงเล็บอย่างน้อยหนึ่งอันในลำดับย่อยนั้นซ้อนกัน is_nested(\\'[[]]\\') ➞ True is_nested(\\'[[]]]]]]][[[[[]\\') ➞ False is_nested(\\'[][]\\') ➞ False is_nested(\\'[[][]\\') ➞ False is_nested(\\'[[][]]\\') ➞ True is_nested(\\'[[]][[\\') ➞ True\\n '''\\n","canonical_solution":" 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","test":"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","entry_point":"is_nested"} +{"task_id":"HumanEval\\/133","prompt":"\\n\\ndef sum_squares(lst):\\n \"\"\"คุณจะได้รับรายการตัวเลข คุณต้องส่งคืนผลรวมของตัวเลขยกกำลังสองในรายการที่กำหนด ปัดเศษแต่ละองค์ประกอบในรายการเป็น int(Ceiling) บนสุดก่อน ตัวอย่าง: สำหรับ lst = [1,2,3] ผลลัพธ์ควรเป็น 14 สำหรับ lst = [1,4,9] ผลลัพธ์ควรเป็น 98 สำหรับ lst = [1,3,5,7] ผลลัพธ์ควรเป็น 84 สำหรับ lst = [1.4,4.2,0] ผลลัพธ์ควรเป็น 29 สำหรับ lst = [-2.4,1,1] ผลลัพธ์ควรเป็น 6\\n \"\"\"\\n","canonical_solution":" import math\\n squared = 0\\n for i in lst:\\n squared += math.ceil(i)**2\\n return squared\\n","test":"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","entry_point":"sum_squares"} +{"task_id":"HumanEval\\/134","prompt":"\\ndef check_if_last_char_is_a_letter(txt):\\n '''สร้างฟังก์ชันที่ส่งคืนค่า True หากอักขระตัวสุดท้ายของสตริงที่กำหนดเป็นอักขระตัวอักษรและไม่ใช่ส่วนหนึ่งของคำ และส่งคืนค่า False หากไม่เป็นเช่นนั้น หมายเหตุ: \"word\" คือกลุ่มอักขระที่ค��่นด้วยช่องว่าง ตัวอย่าง: check_if_last_char_is_a_letter(\"apple pie\") ➞ False check_if_last_char_is_a_letter(\"apple pi e\") ➞ True check_if_last_char_is_a_letter(\"apple pi e \") ➞ False check_if_last_char_is_a_letter(\"\") ➞ False\\n '''\\n","canonical_solution":" \\n check = txt.split(' ')[-1]\\n return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False\\n","test":"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","entry_point":"check_if_last_char_is_a_letter"} +{"task_id":"HumanEval\\/135","prompt":"\\ndef can_arrange(arr):\\n \"\"\"สร้างฟังก์ชันที่ส่งคืนดัชนีที่ใหญ่ที่สุดขององค์ประกอบซึ่งไม่มากกว่าหรือเท่ากับองค์ประกอบก่อนหน้าทันที หากไม่มีองค์ประกอบดังกล่าว ให้ส่งคืน -1 อาร์เรย์ที่กำหนดจะไม่มีค่าซ้ำกัน ตัวอย่าง: can_arrange([1,2,4,3,5]) = 3 can_arrange([1,2,3]) = -1\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"largest_smallest_integers"} +{"task_id":"HumanEval\\/137","prompt":"\\ndef compare_one(a, b):\\n \"\"\"สร้างฟังก์ชันที่ใช้จำนวนเต็ม จำนวนทศนิยม หรือสตริงที่แสดงถึงจำนวนจริง และส่งคืนตัวแปรที่มีค่ามากกว่าในประเภทตัวแปรที่กำหนด ส่งคืนค่า None หากค่าเท่ากัน หมายเหตุ: หากแสดงจำนวนจริงเป็นสตริง จุดทศนิยมอาจเป็น . หรือ , compare_one(1, 2.5) ➞ 2.5 compare_one(1, \"2,3\") ➞ \"2,3\" compare_one(\"5,1\", \"6\") ➞ \"6\" compare_one(\"1\", 1) ➞ None\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"compare_one"} +{"task_id":"HumanEval\\/138","prompt":"\\ndef is_equal_to_sum_even(n):\\n \"\"\"ประเมินว่าตัวเลข n ที่กำหนดสามารถเขียนเป็นผลรวมของจำนวนคู่บวก 4 จำนวนพอดีหรือไม่ ตัวอย่าง is_equal_to_sum_even(4) == False is_equal_to_sum_even(6) == False is_equal_to_sum_even(8) == True\\n \"\"\"\\n","canonical_solution":" return n%2 == 0 and n >= 8\\n","test":"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","entry_point":"is_equal_to_sum_even"} +{"task_id":"HumanEval\\/139","prompt":"\\ndef special_factorial(n):\\n \"\"\"แฟกทอเรียลของบราซิลถูกกำหนดเป็น: brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! โดยที่ n > 0 ตัวอย่างเช่น:\\n >>> special_factorial(4)\\n 288\\n\\n The function will receive an integer as input and should return the special\\n factorial of this integer.\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"special_factorial"} +{"task_id":"HumanEval\\/140","prompt":"\\ndef fix_spaces(text):\\n \"\"\"กำหนดข้อความสตริง ให้แทนที่ช่องว่างทั้งหมดด้วยเครื่องหมายขีดล่าง และถ้าสตริงมีช่องว่างติดต่อกันมากกว่า 2 ช่องว่าง ให้แทนที่ช่องว่างติดต่อกันทั้งหมดด้วย - fix_spaces(\"Example\") == \"Example\" fix_spaces(\"Example 1\") == \"Example_1\" fix_spaces(\" Example 2\") == \"_Example_2\" fix_spaces(\" Example 3\") == \"_Example-3\"\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"fix_spaces"} +{"task_id":"HumanEval\\/141","prompt":"\\ndef file_name_check(file_name):\\n \"\"\"สร้างฟังก์ชันที่รับสตริงที่แสดงชื่อไฟล์ และส่งคืน \\'ใช่\\' หากชื่อไฟล์ถูกต้อง และส่งกลับ \\'ไม่ใช่\\' หากไม่เป็นเช่นนั้น ชื่อไฟล์จะถือว่าถูกต้องก็ต่อเมื่อตรงตามเงื่อนไขต่อไปนี้ทั้งหมดเท่านั้น: - ชื่อไฟล์ไม่ควรมีตัวเลขเกินสามหลัก (\\'0\\'-\\'9\\') - ชื่อไฟล์มีจุด \".\\' เพียงหนึ่งจุด - สตริงย่อยก่อนจุดไม่ควรว่างเปล่า และเริ่มต้นด้วยตัวอักษรจากภาษาละติน alphapet (\\'a\\'-\\'z\\' และ \\'A\\'-\\'Z\\') - สตริงย่อยหลังจุดควรเป็นอย่างใดอย่างหนึ่งจากนี้: [\\'txt\\', \\'exe\\', \\'dll\\'] ตัวอย่าง: file_name_check(\"example.txt\") # => \\'Yes\\' file_name_check(\"1example.dll\") # => \\'No\\' (ชื่อควรเริ่มต้นด้วยตัวอักษรละติน alphapet)\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"file_name_check"} +{"task_id":"HumanEval\\/142","prompt":"\\n\\n\\ndef sum_squares(lst):\\n \"\"\"\" ฟังก์ชันนี้จะใช้รายการจำนวนเต็ม สำหรับรายการทั้งหมดในรายการ ฟังก์ชันจะต้องยกกำลังรายการจำนวนเต็มหากดัชนีของฟังก์ชันเป็นผลคูณของ 3 และจะยกกำลังรายการจำนวนเต็มหากดัชนีของฟังก์ชันเป็นผลคูณของ 4 และไม่ใช่เป็นผลคูณของ 3 ฟังก์ชันจะไม่เปลี่ยนแปลงรายการในรายการที่มีดัชนีไม่ใช่ผลคูณของ 3 หรือ 4 ฟังก์ชันจะส่งคืนผลรวมของรายการทั้งหมด ตัวอย่าง: สำหรับ lst = [1,2,3] ผลลัพธ์ควรเป็น 6 สำหรับ lst = [] ผลลัพธ์ควรเป็น 0 สำหรับ lst = [-1,-5,2,-1,-5] ผลลัพธ์ควรเป็น -126\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"sum_squares"} +{"task_id":"HumanEval\\/143","prompt":"\\ndef words_in_sentence(sentence):\\n \"\"\"คุณจะได้รับสตริงที่แสดงถึงประโยค ประโยคประกอบด้วยคำบางคำที่คั่นด้วยช่องว่าง และคุณต้องส่งคืนสตริงที่มีคำจากประโยคเดิม ซึ่งความยาวเป็นจำนวนเฉพาะ ลำดับของคำในสตริงใหม่ควรเหมือนกับของเดิม ตัวอย่างที่ 1: อินพุต: ประโยค = \"This is a test\" เอาต์พุต: \"is\" ตัวอย่างที่ 2: อินพุต: ประโยค = \"lets go for swimming\" เอาต์พุต: \"go for\" ข้อจำกัด: * 1 <= len(sentence) <= 100 * ประโยคประกอบด้วยตัวอักษรเท่านั้น\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"words_in_sentence"} +{"task_id":"HumanEval\\/144","prompt":"\\ndef simplify(x, n):\\n \"\"\"งานของคุณคือการใช้ฟังก์ชันที่จะทำให้นิพจน์ x * n ง่ายขึ้น ฟังก์ชันนี้จะคืนค่า True หาก x * n ประเมินผลเป็นจำนวนเต็ม และคืนค่า False หากไม่เช่นนั้น ทั้ง x และ n ต่างก็เป็นสตริงที่แสดงเศษส่วน และมีรูปแบบดังต่อไปนี้ - โดยที่ตัวเศษและตัวส่วนเป็นจำนวนเต็มบวกทั้งคู่ คุณสามารถถือว่า x และ n เป็นเศษส่วนที่ถูกต้อง และไม่มีศูนย์เป็นตัวส่วน simplify(\"1\\/5\", \"5\\/1\") = True simplify(\"1\\/6\", \"2\\/1\") = False simplify(\"7\\/10\", \"10\\/2\") = False\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"simplify"} +{"task_id":"HumanEval\\/145","prompt":"\\ndef order_by_points(nums):\\n \"\"\"เขียนฟังก์ชันที่เรียงลำดับรายการจำนวนเต็มที่กำหนดตามลำดับจากน้อยไปมากตามผลรวมของตัวเลข หมายเหตุ: หากมีรายการหลายรายการที่ผลรวมของตัวเลขใกล้เคียงกัน ให้เรียงลำดับตามดัชนีในรายการเดิม ตัวอย่างเช่น:\\n >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]\\n >>> order_by_points([]) == []\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"order_by_points"} +{"task_id":"HumanEval\\/146","prompt":"\\ndef specialFilter(nums):\\n \"\"\"เขียนฟังก์ชันที่รับอาร์เรย์ของตัวเลขเป็นอินพุตและส่งคืนจำนวนองค์ประกอบในอาร์เรย์ที่มากกว่า 10 และหลักแรกและหลักสุดท้ายของตัวเลขเป็นเลขคี่ (1, 3, 5, 7, 9) ตัวอย่างเช่น: specialFilter([15, -73, 14, -15]) => 1 specialFilter([33, -2, -3, 45, 21, 109]) => 2\\n \"\"\"\\n","canonical_solution":" \\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","test":"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","entry_point":"specialFilter"} +{"task_id":"HumanEval\\/147","prompt":"\\ndef get_max_triples(n):\\n \"\"\"คุณได้รับจำนวนเต็มบวก n คุณต้องสร้างอาร์เรย์จำนวนเต็ม a ที่มีความยาว n สำหรับแต่ละ i (1 ≤ i ≤ n) ค่าของ a[i] = i * i - i + 1 ส่งกลับจำนวนสาม (a[i], a[j], a[k]) ของ a โดยที่ i < j < k และ a[i] + a[j] + a[k] เป็นทวีคูณของ 3 ตัวอย่าง: อินพุต: n = 5 เอาต์พุต: 1 คำอธิบาย: a = [1, 3, 7, 13, 21] สามที่ถูกต้องคือ (1, 7, 13) เท่านั้น\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"get_max_triples"} +{"task_id":"HumanEval\\/148","prompt":"\\ndef bf(planet1, planet2):\\n '''ในระบบสุริยะของเรามีดาวเคราะห์ 8 ดวง ดวงที่อยู่ใกล้ดวงอาทิตย์ที่สุดคือดาวพุธ ดวงถัดมาคือดาวศุกร์ จากนั้นคือโลก ดาวอังคาร ดาวพฤหัสบดี ดาวเสาร์ ดาวยูเรนัส ดาวเนปจูน เขียนฟังก์ชันที่รับชื่อดาวเคราะห์ 2 ดวงเป็นสตริง ได้แก่ planet1 และ planet2 ฟังก์ชันควรส่งคืนทูเพิลที่มีดาวเคราะห์ทั้งหมดที่มีวงโคจรอยู่ระหว่างวงโคจรของ planet1 และวงโคจรของ planet2 โดยเรียงลำดับตามระยะห่างจากดวงอาทิตย์ ฟังก์ชันควรส่งคืนทูเพิลว่างหาก planet1 หรือ planet2 ไม���ใช่ชื่อดาวเคราะห์ที่ถูกต้อง ตัวอย่าง bf(\"Jupiter\", \"Neptune\") ==> (\"Saturn\", \"Uranus\") bf(\"Earth\", \"Mercury\") ==> (\"Venus\") bf(\"Mercury\", \"Uranus\") ==> (\"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\")\\n '''\\n","canonical_solution":" 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","test":"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","entry_point":"bf"} +{"task_id":"HumanEval\\/149","prompt":"\\ndef sorted_list_sum(lst):\\n \"\"\"เขียนฟังก์ชันที่ยอมรับรายการสตริงเป็นพารามิเตอร์ ลบสตริงที่มีความยาวคี่ และส่งคืนรายการผลลัพธ์ที่มีลำดับการเรียงลำดับ รายการจะเป็นรายการสตริงเสมอ ไม่ใช่เป็นอาร์เรย์ของตัวเลข และอาจมีรายการที่ซ้ำกันได้ ลำดับของรายการควรเรียงจากน้อยไปมากตามความยาวของคำแต่ละคำ และคุณควรส่งคืนรายการที่เรียงลำดับตามกฎนั้น หากคำสองคำมีความยาวเท่ากัน ให้เรียงลำดับรายการตามตัวอักษร ฟังก์ชันควรส่งคืนรายการสตริงที่เรียงลำดับแล้ว คุณอาจถือว่าคำทั้งหมดจะมีความยาวเท่ากัน ตัวอย่างเช่น: assert list_sort([\"aa\", \"a\", \"aaa\"]) => [\"aa\"] assert list_sort([\"ab\", \"a\", \"aaa\", \"cd\"]) => [\"ab\", \"cd\"]\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"sorted_list_sum"} +{"task_id":"HumanEval\\/150","prompt":"\\ndef x_or_y(n, x, y):\\n \"\"\"โปรแกรมง่ายๆ ที่ควรส่งคืนค่าของ x หาก n เป็นจำนวนเฉพาะ และควรส่งคืนค่าของ y ในกรณีอื่น ตัวอย่าง: for x_or_y(7, 34, 12) == 34 for x_or_y(15, 8, 5) == 5\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"x_or_y"} +{"task_id":"HumanEval\\/151","prompt":"\\ndef double_the_difference(lst):\\n '''กำหนดรายการตัวเลข ให้ส่งคืนผลรวมของกำลังสองของตัวเลขในรายการที่เป็นเลขคี่ ไม่ต้องสนใจตัวเลขที่เป็นจำนวนเต็มลบหรือไม่ใช่จำนวนเต็ม double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10 double_the_difference([-1, -2, 0]) == 0 double_the_difference([9, -2]) == 81 double_the_difference([0]) == 0 ถ้ารายการอินพุตว่างเปล่า ให้ส่งคืน 0\\n '''\\n","canonical_solution":" return sum([i**2 for i in lst if i > 0 and i%2!=0 and \".\" not in str(i)])\\n","test":"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","entry_point":"double_the_difference"} +{"task_id":"HumanEval\\/152","prompt":"\\ndef compare(game,guess):\\n \"\"\"ฉันคิดว่าเราทุกคนคงจำความรู้สึกนั้นได้เมื่อผลลัพธ์ของเหตุการณ์ที่รอคอยมานานในที่สุดก็ถูกเปิดเผย ความรู้สึกและความคิดที่คุณมีในขณะนั้นคุ้มค่าแก่การจดบันทึกและเปรียบเทียบอย่างแน่นอน หน้าที่ของคุณคือตรวจสอบว่าบุคคลนั้นเดาผลลัพธ์ของการจับคู่จำนวนหนึ่งได้ถูกต้องหรือไม่ คุณจะได้รับอาร์เรย์คะแนนและการเดาสองชุดที่มีความยาวเท่ากัน โดยแต่ละดัชนีจะแสดงการจับคู่ที่ตรงกัน ส่งคืนอาร์เรย์ที่มีความยาวเท่ากันเพื่อระบุว่าการเดาแต่ละครั้งนั้นคลาดเคลื่อนแค่ไหน หากพวกเขาเดาถูก ค่าจะเป็น 0 และหากไม่ใช่ ค่าจะเป็นความแตกต่างสัมบูรณ์ระหว่างการเดาและคะแนน ตัวอย่าง: compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3] compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]\\n \"\"\"\\n","canonical_solution":" return [abs(x-y) for x,y in zip(game,guess)]\\n","test":"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","entry_point":"compare"} +{"task_id":"HumanEval\\/153","prompt":"\\ndef Strongest_Extension(class_name, extensions):\\n \"\"\"คุณจะได้รับชื่อของคลาส (สตริง) และรายการส่วนขยาย ส่วนขยายเหล่���นี้จะถูกใช้เพื่อโหลดคลาสเพิ่มเติมให้กับคลาส ความแข็งแกร่งของส่วนขยายมีดังนี้ ให้ CAP เป็นจำนวนตัวอักษรพิมพ์ใหญ่ในชื่อส่วนขยาย และให้ SM เป็นจำนวนตัวอักษรพิมพ์เล็กในชื่อส่วนขยาย ความแข็งแกร่งจะกำหนดโดยเศษส่วน CAP - SM คุณควรค้นหาส่วนขยายที่แข็งแกร่งที่สุดและส่งคืนสตริงในรูปแบบนี้: ClassName.StrongestExtensionName หากมีส่วนขยายสองรายการขึ้นไปที่มีความแข็งแกร่งเท่ากัน คุณควรเลือกส่วนขยายที่อยู่อันดับแรกในรายการ ตัวอย่างเช่น หากคุณได้รับ \"Slices\" เป็นคลาสและรายการส่วนขยาย: [\\'SErviNGSliCes\\', \\'Cheese\\', \\'StuFfed\\'] คุณควรส่งคืน \\'Slices.SErviNGSliCes\\' เนื่องจาก \\'SErviNGSliCes\\' เป็นส่วนขยายที่แข็งแกร่งที่สุด (ความแข็งแกร่งคือ -1) ตัวอย่าง: สำหรับ Strongest_Extension(\\'my_class\\', [\\'AA\\', \\'Be\\', \\'CC\\']) == \\'my_class.AA\\'\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"Strongest_Extension"} +{"task_id":"HumanEval\\/154","prompt":"\\ndef cycpattern_check(a , b):\\n \"\"\"คุณได้รับ 2 คำ คุณต้องคืนค่า True หากคำที่สองหรือการหมุนเวียนใดๆ ของคำนั้นเป็นสตริงย่อยในคำแรก cycpattern_check(\"abcd\",\"abd\") => False cycpattern_check(\"hello\",\"ell\") => True cycpattern_check(\"whassup\",\"psus\") => False cycpattern_check(\"abab\",\"baa\") => True cycpattern_check(\"efef\",\"eeff\") => False cycpattern_check(\"himenss\",\"simen\") => True\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"cycpattern_check"} +{"task_id":"HumanEval\\/155","prompt":"\\ndef even_odd_count(num):\\n \"\"\"เมื่อกำหนดจำนวนเต็ม ให้ส่งคืนทูเพิลที่มีจำนวนหลักคู่และหลักคี่ตามลำดับ ตัวอย่าง: even_odd_count(-12) ==> (1, 1) even_odd_count(123) ==> (1, 2)\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"even_odd_count"} +{"task_id":"HumanEval\\/156","prompt":"\\ndef int_to_mini_roman(number):\\n \"\"\"เมื่อกำหนดจำนวนเต็มบวก ให้หาค่าเทียบเท่าตัวเลขโรมันเป็นสตริง แล้วส่งคืนเป็นตัวพิมพ์เล็ก ข้อจำกัด: 1 <= num <= 1000 ตัวอย่าง:\\n >>> int_to_mini_roman(19) == 'xix'\\n >>> int_to_mini_roman(152) == 'clii'\\n >>> int_to_mini_roman(426) == 'cdxxvi'\"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"int_to_mini_roman"} +{"task_id":"HumanEval\\/157","prompt":"\\ndef right_angle_triangle(a, b, c):\\n '''กำหนดความยาวของด้านทั้งสามของรูปสามเหลี่ยม คืนค่า True หากด้านทั้งสามประกอบกันเป็นรูปสามเหลี่ยมมุมฉาก คืนค่า False หากไม่เป็นเช่นนั้น รูปสามเหลี่ยมมุมฉากคือรูปสามเหลี่ยมที่มีมุมหนึ่งเป็นมุมฉากหรือ 90 องศา ตัวอย่าง: right_angle_triangle(3, 4, 5) == True right_angle_triangle(1, 2, 3) == False\\n '''\\n","canonical_solution":" return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b\\n","test":"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","entry_point":"right_angle_triangle"} +{"task_id":"HumanEval\\/158","prompt":"\\ndef find_max(words):\\n \"\"\"เขียนฟังก์ชันที่รับรายการสตริง รายการประกอบด้วยคำต่างๆ ส่งคืนคำที่มีจำนวนอักขระที่ไม่ซ้ำกันสูงสุด หากสตริงหลายรายการมีอักขระที่ไม่ซ้ำกันสูงสุด ให้ส่งคืนสตริงที่มาก่อนตามลำดับตัวอักษร find_max([\"name\", \"of\", \"string\"]) == \"string\" find_max([\"name\", \"enam\", \"game\"]) == \"enam\" find_max([\"aaaaaaa\", \"bb\" ,\"cc\"]) == \"\"aaaaaaa\"\\n \"\"\"\\n","canonical_solution":" return sorted(words, key = lambda x: (-len(set(x)), x))[0]\\n","test":"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","entry_point":"find_max"} +{"task_id":"HumanEval\\/159","prompt":"\\ndef eat(number, need, remaining):\\n \"\"\"คุณเป็นกระต่ายที่หิวโหย และคุณได้กินแครอทไปจำนวนหนึ่งแล้ว แต่ตอนนี้คุณต้องกินแครอทเพิ่มเพื่อให้ครบมื้อของวัน คุณควรส่งคืนอาร์เรย์ของ [ จำนวนแครอทที่กินทั้งหมดหลังมื้ออาหารของคุณ จำนวนแครอทที่เหลือหลังมื้ออาหารของคุณ ] ถ้าแครอทเหลือไม่เพียงพอ คุณจะกินแครอทที่เหลือทั้งหมด แต่จะยังคงหิวอยู่ ตัวอย่าง: * eat(5, 6, 10) -> [11, 4] * eat(4, 8, 9) -> [12, 1] * eat(1, 10, 10) -> [11, 0] * eat(2, 11, 5) -> [7, 0] ตัวแปร: @number : integer จำนวนแครอทที่คุณกิน @need : integer จำนวนแครอทที่คุณต้องกิน @remaining : integer คือ จำนวนแครอทที่เหลืออยู่ในสต็อก Constrain: * 0 <= จำนวน <= 1000 * 0 <= ความต้องการ <= 1000 * 0 <= ที่เหลือ <= 1000 สนุกนะ :)\\n \"\"\"\\n","canonical_solution":" if(need <= remaining):\\n return [ number + need , remaining-need ]\\n else:\\n return [ number + remaining , 0]\\n","test":"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","entry_point":"eat"} +{"task_id":"HumanEval\\/160","prompt":"\\ndef do_algebra(operator, operand):\\n \"\"\"กำหนดตัวดำเนินการรายการสองตัวและตัวดำเนินการ รายการแรกมีการดำเนินการพีชคณิตพื้นฐาน และรายการที่สองเป็นรายการของจำนวนเต็ม ใช้รายการทั้งสองที่กำหนดเพื่อสร้างนิพจน์พีชคณิตและส่งคืนการประเมินนิพจน์นี้ การดำเนินการพีชคณิตพื้นฐาน: การบวก ( + ) การลบ ( - ) การคูณ ( * ) การหารด้วยเลขฐานสอง ( \\/\\/ ) การยกกำลัง ( ** ) ตัวอย่าง: ตัวดำเนินการ[\\'+\\', \\'*\\', \\'-\\'] อาร์เรย์ = [2, 3, 4, 5] ผลลัพธ์ = 2 + 3 * 4 - 5 => ผลลัพธ์ = 9 หมายเหตุ: ความยาวของตัวดำเนินการรายการเท่ากับความยาวของตัวดำเนินการรายการลบหนึ่ง ตัวดำเนินการคือรายการของจำนวนเต็มที่ไม่เป็นลบ ตัวดำเนินการรายการมีตัวดำเนินการอย่างน้อยหนึ่งตัว และตัวดำเนินการรายการมีตัวดำเนินการอย่างน้อยสองตัว\\n \"\"\"\\n","canonical_solution":" expression = str(operand[0])\\n for oprt, oprn in zip(operator, operand[1:]):\\n expression+= oprt + str(oprn)\\n return eval(expression)\\n","test":"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","entry_point":"do_algebra"} +{"task_id":"HumanEval\\/161","prompt":"\\ndef solve(s):\\n \"\"\"คุณจะได้รับสตริง s หาก s[i] เป็นตัวอักษร ให้กลับตัวพิมพ์จากตัวพิมพ์เล็กเป็นตัวพิมพ์ใหญ่หรือในทางกลับกัน มิฉะนั้น ให้คงไว้ตามเดิม หากสตริงไม่มีตัวอักษร ให้กลับตัวพิมพ์ ฟังก์ชันควรส่งคืนสตริงที่ได้ ตัวอย่าง solve(\"1234\") = \"4321\" solve(\"ab\") = \"AB\" solve(\"#a@C\") = \"#A@c\"\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"solve"} +{"task_id":"HumanEval\\/162","prompt":"\\ndef string_to_md5(text):\\n \"\"\"เมื่อได้รับสตริง \\'text\\' ให้ส่งคืนสตริงเทียบเท่าแฮช md5 หาก \\'text\\' เป็นสตริงว่าง ให้ส่งคืน None\\n >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'\"\"\"\\n","canonical_solution":" import hashlib\\n return hashlib.md5(text.encode('ascii')).hexdigest() if text else None\\n","test":"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","entry_point":"string_to_md5"} +{"task_id":"HumanEval\\/163","prompt":"\\ndef generate_integers(a, b):\\n \"\"\"กำหนดจำนวนเต็มบวกสองจำนวนคือ a และ b ให้ส่งคืนเลขคู่ระหว่าง a และ b ตามลำดับจากน้อยไปมาก ตัวอย่างเช่น generate_integers(2, 8) => [2, 4, 6, 8] generate_integers(8, 2) => [2, 4, 6, 8] generate_integers(10, 14) => []\\n \"\"\"\\n","canonical_solution":" 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","test":"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","entry_point":"generate_integers"}