task_id stringlengths 12 14 | prompt stringlengths 118 1.11k | canonical_solution stringlengths 17 895 | test stringlengths 125 1.84k | entry_point stringlengths 1 30 |
|---|---|---|---|---|
HumanEval\/100 | \ndef make_a_pile(n):\n """เมื่อกำหนดจำนวนเต็มบวก n คุณต้องสร้างกองหิน n ระดับ ระดับแรกมีหิน n ก้อน จำนวนหินในระดับถัดไปคือ - จำนวนคี่ถัดไปถ้า n เป็นคี่ - จำนวนคู่ถัดไปถ้า n เป็นคู่ ส่งคืนจำนวนหินในแต่ละระดับในรายการ โดยที่องค์ประกอบที่ดัชนี i แสดงถึงจำนวนหินในระดับ (i+1) ตัวอย่าง:\n >>> make_a_pile(3)\n [3, 5... | return [n + 2*i for i in range(n)]\n | 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 # Ch... | make_a_pile |
HumanEval\/101 | \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... | 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 | 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... | words_string |
HumanEval\/102 | \ndef choose_num(x, y):\n """ฟังก์ชันนี้ใช้ค่า x และ y เป็นจำนวนบวกสองค่า และส่งคืนจำนวนเต็มคู่ที่มากที่สุดที่อยู่ในช่วง [x, y] รวม หากไม่มีค่าดังกล่าว ฟังก์ชันควรส่งคืน -1 ตัวอย่างเช่น: choose_num(12, 15) = 14 choose_num(13, 12) = -1\n """\n | if x > y:\n return -1\n if y % 2 == 0:\n return y\n if x == y:\n return -1\n return y - 1\n | 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 ... | choose_num |
HumanEval\/103 | \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, 2... | 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 | 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) == "0b10... | rounded_avg |
HumanEval\/104 | \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 | 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 | 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... | unique_digits |
HumanEval\/105 | \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] -... | 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_... | 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... | by_length |
HumanEval\/106 | \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, 1... | 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 | 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 | f |
HumanEval\/107 | \ndef even_odd_palindrome(n):\n """กำหนดจำนวนเต็มบวก n ให้ส่งคืนทูเพิลที่มีจำนวนพาลินโดรมจำนวนเต็มคู่และคี่ที่อยู่ในช่วง (1, n) รวม ตัวอย่าง 1: อินพุต: 3 เอาต์พุต: (1, 2) คำอธิบาย: พาลินโดรมจำนวนเต็มคือ 1, 2, 3 โดยหนึ่งในนั้นเป็นจำนวนคู่ และอีกสองอันเป็นจำนวนคี่ ตัวอย่าง 2: อินพุต: 12 เอาต์พุต: (4, 6) คำอธิบาย: พาลิ... | 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_c... | 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... | even_odd_palindrome |
HumanEval\/108 | \ndef count_nums(arr):\n """เขียนฟังก์ชัน count_nums ซึ่งรับอาร์เรย์ของจำนวนเต็ม และส่งคืนจำนวนองค์ประกอบที่ผลรวมของตัวเลข > 0 หากตัวเลขเป็นค่าลบ ตัวเลขที่มีเครื่องหมายตัวแรกจะเป็นค่าลบ เช่น -123 มีตัวเลขที่มีเครื่องหมายคือ -1, 2 และ 3\n >>> count_nums([]) == 0\n >>> count_nums([-1, 11, -11]) == 1\n >>> cou... | 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 | 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, ... | count_nums |
HumanEval\/109 | \ndef move_one_ball(arr):\n """เรามีอาร์เรย์ \'arr\' ของจำนวนเต็ม N ตัว arr[1], arr[2], ..., arr[N] ตัวเลขในอาร์เรย์จะถูกเรียงลำดับแบบสุ่ม งานของคุณคือตรวจสอบว่าเป็นไปได้หรือไม่ที่จะเรียงลำดับอาร์เรย์ในลำดับที่ไม่ลดลงโดยดำเนินการต่อไปนี้กับอาร์เรย์ที่กำหนด: คุณสามารถเลื่อนไปทางขวาได้หลายครั้งเท่าที่ต้องการ การเลื่อน... | if len(arr)==0:\n return True\n sorted_array=sorted(arr)\n my_arr=[]\n \n min_value=min(arr)\n min_index=arr.index(min_value)\n my_arr=arr[min_index:]+arr[0:min_index]\n for i in range(len(arr)):\n if my_arr[i]!=sorted_array[i]:\n return False\n return True\n | 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 as... | move_one_ball |
HumanEval\/110 | \ndef exchange(lst1, lst2):\n """ในปัญหานี้ คุณจะใช้ฟังก์ชันที่รับรายการตัวเลขสองรายการ และพิจารณาว่าเป็นไปได้หรือไม่ที่จะทำการแลกเปลี่ยนองค์ประกอบระหว่างรายการเหล่านั้นเพื่อทำให้ lst1 เป็นรายการของตัวเลขคู่เท่านั้น ไม่มีข้อจำกัดเกี่ยวกับจำนวนองค์ประกอบที่แลกเปลี่ยนระหว่าง lst1 และ lst2 หากสามารถแลกเปลี่ยนองค์ประกอบ... | 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 | 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... | exchange |
HumanEval\/111 | \ndef histogram(test):\n """กำหนดสตริงที่แสดงถึงตัวอักษรตัวเล็กที่คั่นด้วยช่องว่าง ให้ส่งคืนพจนานุกรมของตัวอักษรที่มีการทำซ้ำมากที่สุดและมีจำนวนที่สอดคล้องกัน หากมีตัวอักษรหลายตัวปรากฏเหมือนกัน ให้ส่งคืนทั้งหมด ตัวอย่าง: histogram(\'ab c\') == {\'a\': 1, \'b\': 1, \'c\': 1} histogram(\'abb a\') == {\'a\': 2, \'b\': ... | 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 | 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') == {... | histogram |
HumanEval\/112 | \ndef reverse_delete(s,c):\n """งาน เราได้รับสตริง 2 ตัวคือ s และ c คุณต้องลบตัวอักษรทั้งหมดใน s ที่เท่ากับตัวอักษรใดๆ ใน c จากนั้นตรวจสอบว่าสตริงผลลัพธ์เป็นพาลินโดรมหรือไม่ สตริงจะถูกเรียกว่าพาลินโดรมหากอ่านแบบย้อนกลับและไปข้างหน้าเหมือนกัน คุณควรส่งคืนทูเพิลที่มีสตริงผลลัพธ์และค่า True\/False สำหรับการตรวจสอบ ตัวอ... | s = ''.join([char for char in s if char not in c])\n return (s,s[::-1] == s)\n | 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",... | reverse_delete |
HumanEval\/113 | \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."... | 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 | 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 8... | odd_count |
HumanEval\/114 | \ndef minSubArraySum(nums):\n """กำหนดอาร์เรย์ของจำนวนเต็ม nums หาผลรวมขั้นต่ำของอาร์เรย์ย่อยของ nums ที่ไม่ว่าง ตัวอย่าง minSubArraySum([2, 3, 4, 1, 2, 4]) == 1 minSubArraySum([-1, -2, -3]) == -6\n """\n | max_sum = 0\n s = 0\n for num in nums:\n s += -num\n if (s < 0):\n s = 0\n max_sum = max(s, max_sum)\n if max_sum == 0:\n max_sum = max(-i for i in nums)\n min_sum = -max_sum\n return min_sum\n | 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... | minSubArraySum |
HumanEval\/115 | \ndef max_fill(grid, capacity):\n import math\n """คุณจะได้รับตารางบ่อน้ำรูปสี่เหลี่ยมผืนผ้า แต่ละแถวแทนบ่อน้ำ 1 บ่อ และแต่ละบ่อน้ำในแถวแทนน้ำ 1 หน่วย แต่ละบ่อน้ำจะมีถังที่สอดคล้องกันซึ่งใช้สำหรับตักน้ำออกจากบ่อ และถังทั้งหมดจะมีความจุเท่ากัน หน้าที่ของคุณคือใช้ถังเพื่อเทน้ำออกจากบ่อ กำหนดจำนวนครั้งที่คุณต้องการล... | return sum([math.ceil(sum(arr)\/capacity) for arr in grid])\n | 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... | max_fill |
HumanEval\/116 | \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, ... | return sorted(sorted(arr), key=lambda x: bin(x)[2:].count('1'))\n | 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 cand... | sort_array |
HumanEval\/117 | \ndef select_words(s, n):\n """เมื่อกำหนดสตริง s และจำนวนธรรมชาติ n คุณได้รับมอบหมายให้ใช้งานฟังก์ชันที่ส่งคืนรายการคำทั้งหมดจากสตริง s ที่มีพยัญชนะ n ตัวพอดี โดยคำเหล่านี้จะปรากฏตามลำดับในสตริง s หากสตริง s ว่างเปล่า ฟังก์ชันควรส่งคืนรายการว่างเปล่า หมายเหตุ: คุณอาจถือว่าสตริงอินพุตมีเฉพาะตัวอักษรและช่องว่างเท่านั้... | 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 | 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 litt... | select_words |
HumanEval\/118 | \ndef get_closest_vowel(word):\n """คุณจะได้รับคำศัพท์หนึ่งคำ งานของคุณคือค้นหาสระที่ใกล้เคียงที่สุดที่อยู่ระหว่างพยัญชนะสองตัวจากด้านขวาของคำ (ต้องตรงตามตัวพิมพ์ใหญ่-เล็ก) สระในตอนต้นและตอนท้ายไม่นับ ส่งคืนสตริงว่างหากคุณไม่พบสระที่ตรงตามเงื่อนไขข้างต้น คุณอาจถือว่าสตริงที่กำหนดมีเฉพาะตัวอักษรภาษาอังกฤษเท่านั้น ตัว... | if len(word) < 3:\n return ""\n\n vowels = {"a", "e", "i", "o", "u", "A", "E", 'O', 'U', 'I'}\n for i in range(len(word)-2, 0, -1):\n if word[i] in vowels:\n if (word[i+1] not in vowels) and (word[i-1] not in vowels):\n return word[i]\n return ""\n | 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 asse... | get_closest_vowel |
HumanEval\/119 | \ndef match_parens(lst):\n '''คุณจะได้รับรายการสตริงสองสตริง โดยสตริงทั้งสองประกอบด้วยวงเล็บเปิด \'(\' หรือวงเล็บปิด \')\' เท่านั้น งานของคุณคือตรวจสอบว่าสามารถต่อสตริงทั้งสองเข้าด้วยกันในลำดับใด ๆ ได้หรือไม่ สตริงที่ได้จะดีหรือไม่ สตริง S จะถือว่าดีก็ต่อเมื่อวงเล็บทั้งหมดใน S สมดุลกัน ตัวอย่างเช่น สตริง \'(())()\' ... | 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 ... | 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 candida... | match_parens |
HumanEval\/120 | \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,... | if k == 0:\n return []\n arr.sort()\n ans = arr[-k:]\n return ans\n | 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 ... | maximum |
HumanEval\/121 | \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 | return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])\n | 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... | solution |
HumanEval\/122 | \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 ... | return sum(elem for elem in arr[:k] if len(str(elem)) <= 2)\n | 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 (g... | add_elements |
HumanEval\/123 | \ndef get_odd_collatz(n):\n """กำหนดจำนวนเต็มบวก n ให้ส่งคืนรายการที่เรียงลำดับแล้วที่มีจำนวนคี่ในลำดับคอลลาตซ์ สมมติฐานคอลลาตซ์เป็นสมมติฐานทางคณิตศาสตร์ที่เกี่ยวข้องกับลำดับที่กำหนดดังต่อไปนี้: เริ่มต้นด้วยจำนวนเต็มบวก n ใดๆ จากนั้นแต่ละเทอมจะได้มาจากเทอมก่อนหน้าดังนี้: ถ้าเทอมก่อนหน้าเป็นเลขคู่ เทอมถัดไปจะเป็นครึ่... | if n%2==0:\n odd_collatz = [] \n else:\n odd_collatz = [n]\n while n > 1:\n if n % 2 == 0:\n n = n\/2\n else:\n n = n*3 + 1\n \n if n%2 == 1:\n odd_collatz.append(int(n))\n\n return sorted(odd_collatz)\n | 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 ca... | get_odd_collatz |
HumanEval\/124 | \ndef valid_date(date):\n """คุณต้องเขียนฟังก์ชันที่ตรวจสอบสตริงวันที่ที่กำหนดและส่งคืนค่า True หากวันที่นั้นถูกต้อง มิฉะนั้นจะส่งคืนค่า False วันที่นั้นจะถูกต้องหากเป็นไปตามกฎทั้งหมดต่อไปนี้: 1. สตริงวันที่ไม่ว่างเปล่า 2. จำนวนวันไม่น้อยกว่า 1 วันหรือสูงกว่า 31 วันสำหรับเดือน 1,3,5,7,8,10,12 และจำนวนวันไม่น้อยกว่า ... | 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... | 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'... | valid_date |
HumanEval\/125 | \ndef split_words(txt):\n '''กำหนดสตริงของคำ ให้ส่งคืนรายการคำที่แบ่งตามช่องว่าง ถ้าไม่มีช่องว่างในข้อความ คุณควรแบ่งด้วยเครื่องหมายจุลภาค \' ถ้าไม่มีเครื่องหมายจุลภาค คุณควรส่งคืนจำนวนตัวอักษรพิมพ์เล็กที่มีลำดับคี่ในตัวอักษร ord(\'a\') = 0, ord(\'b\') = 1, ... ord(\'z\') = 25 ตัวอย่าง split_words("Hello world!") ➞ ... | 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 | 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 ... | split_words |
HumanEval\/126 | \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]) ➞ Fal... | 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 | 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, ... | is_sorted |
HumanEval\/127 | \ndef intersection(interval1, interval2):\n """คุณจะได้รับช่วงสองช่วง โดยแต่ละช่วงเป็นคู่ของจำนวนเต็ม ตัวอย่างเช่น ช่วง = (start, end) = (1, 2) ช่วงที่กำหนดเป็นช่วงปิด ซึ่งหมายความว่าช่วง (start, end) ประกอบด้วยทั้ง start และ end สำหรับแต่ละช่วงที่กำหนด จะถือว่า start น้อยกว่าหรือเท่ากับ end งานของคุณคือการกำหนดว่าค... | 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], interval... | 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 as... | intersection |
HumanEval\/128 | \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... | 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 | 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([... | prod_signs |
HumanEval\/129 | \ndef minPath(grid, k):\n """กำหนดตารางที่มี N แถวและ N คอลัมน์ (N >= 2) และจำนวนเต็มบวก k เซลล์แต่ละเซลล์ของตารางจะมีค่า จำนวนเต็มทุกจำนวนในช่วง [1, N * N] รวมอยู่ด้วยจะปรากฏบนเซลล์ของตารางเพียงครั้งเดียว คุณต้องค้นหาเส้นทางที่สั้นที่สุดของความยาว k ในตาราง คุณสามารถเริ่มต้นจากเซลล์ใดก็ได้ และในแต่ละขั้นตอน คุณสามา... | 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 ... | 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 ass... | minPath |
HumanEval\/130 | \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 เป็นเลขคี่ ตัวอย่างเ... | 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 | 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.... | tri |
HumanEval\/131 | \ndef digits(n):\n """กำหนดจำนวนเต็มบวก n ให้ส่งคืนผลคูณของหลักคี่ ส่งคืน 0 ถ้าหลักทั้งหมดเป็นเลขคู่ ตัวอย่างเช่น: digits(1) == 1 digits(4) == 0 digits(235) == 15\n """\n | product = 1\n odd_count = 0\n for digit in str(n):\n int_digit = int(digit)\n if int_digit%2 == 1:\n product= product*int_digit\n odd_count+=1\n if odd_count ==0:\n return 0\n else:\n return product\n | 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.... | digits |
HumanEval\/132 | \ndef is_nested(string):\n '''สร้างฟังก์ชันที่รับสตริงเป็นอินพุตซึ่งประกอบด้วยวงเล็บเหลี่ยมเท่านั้น ฟังก์ชันควรส่งคืนค่า True ก็ต่อเมื่อมีลำดับย่อยที่ถูกต้องของวงเล็บซึ่งวงเล็บอย่างน้อยหนึ่งอันในลำดับย่อยนั้นซ้อนกัน is_nested(\'[[]]\') ➞ True is_nested(\'[[]]]]]]][[[[[]\') ➞ False is_nested(\'[][]\') ➞ False is_nest... | 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_bracke... | 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('[[[[]]]]') == Tru... | is_nested |
HumanEval\/133 | \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,... | import math\n squared = 0\n for i in lst:\n squared += math.ceil(i)**2\n return squared\n | 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... | sum_squares |
HumanEval\/134 | \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_l... | \n check = txt.split(' ')[-1]\n return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False\n | 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... | check_if_last_char_is_a_letter |
HumanEval\/135 | \ndef can_arrange(arr):\n """สร้างฟังก์ชันที่ส่งคืนดัชนีที่ใหญ่ที่สุดขององค์ประกอบซึ่งไม่มากกว่าหรือเท่ากับองค์ประกอบก่อนหน้าทันที หากไม่มีองค์ประกอบดังกล่าว ให้ส่งคืน -1 อาร์เรย์ที่กำหนดจะไม่มีค่าซ้ำกัน ตัวอย่าง: can_arrange([1,2,4,3,5]) = 3 can_arrange([1,2,3]) = -1\n """\n | ind=-1\n i=1\n while i<len(arr):\n if arr[i]<arr[i-1]:\n ind=i\n i+=1\n return ind\n | def check(candidate):\n\n # Check some simple cases\n assert candidate([1,2,4,3,5])==3\n assert candidate([1,2,4,5])==-1\n assert candidate([1,4,2,5,6,7,8,9,10])==2\n assert candidate([4,8,5,7,3])==4\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([])==-1\n\n | can_arrange |
HumanEval\/136 | \ndef largest_smallest_integers(lst):\n '''สร้างฟังก์ชันที่ส่งคืนทูเพิล (a, b) โดยที่ \'a\' คือจำนวนเต็มลบที่ใหญ่ที่สุด และ \'b\' คือจำนวนเต็มบวกที่น้อยที่สุดในรายการ ถ้าไม่มีจำนวนเต็มลบหรือบวก ให้ส่งคืนเป็น None ตัวอย่าง: largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1) largest_smallest_integers([]) == (N... | smallest = list(filter(lambda x: x < 0, lst))\n largest = list(filter(lambda x: x > 0, lst))\n return (max(smallest) if smallest else None, min(largest) if largest else None)\n | 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, ... | largest_smallest_integers |
HumanEval\/137 | \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"... | 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 | 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 ass... | compare_one |
HumanEval\/138 | \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 | return n%2 == 0 and n >= 8\n | 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 | is_equal_to_sum_even |
HumanEval\/139 | \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 | 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 | 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 | special_factorial |
HumanEval\/140 | \ndef fix_spaces(text):\n """กำหนดข้อความสตริง ให้แทนที่ช่องว่างทั้งหมดด้วยเครื่องหมายขีดล่าง และถ้าสตริงมีช่องว่างติดต่อกันมากกว่า 2 ช่องว่าง ให้แทนที่ช่องว่างติดต่อกันทั้งหมดด้วย - fix_spaces("Example") == "Example" fix_spaces("Example 1") == "Example_1" fix_spaces(" Example 2") == "_Example_2" fix_spaces(" Exampl... | 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 ... | 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 D... | fix_spaces |
HumanEval\/141 | \ndef file_name_check(file_name):\n """สร้างฟังก์ชันที่รับสตริงที่แสดงชื่อไฟล์ และส่งคืน \'ใช่\' หากชื่อไฟล์ถูกต้อง และส่งกลับ \'ไม่ใช่\' หากไม่เป็นเช่นนั้น ชื่อไฟล์จะถือว่าถูกต้องก็ต่อเมื่อตรงตามเงื่อนไขต่อไปนี้ทั้งหมดเท่านั้น: - ชื่อไฟล์ไม่ควรมีตัวเลขเกินสามหลัก (\'0\'-\'9\') - ชื่อไฟล์มีจุด ".\' เพียงหนึ่งจุด - ส... | 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 ... | 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') ... | file_name_check |
HumanEval\/142 | \n\n\ndef sum_squares(lst):\n """" ฟังก์ชันนี้จะใช้รายการจำนวนเต็ม สำหรับรายการทั้งหมดในรายการ ฟังก์ชันจะต้องยกกำลังรายการจำนวนเต็มหากดัชนีของฟังก์ชันเป็นผลคูณของ 3 และจะยกกำลังรายการจำนวนเต็มหากดัชนีของฟังก์ชันเป็นผลคูณของ 4 และไม่ใช่เป็นผลคูณของ 3 ฟังก์ชันจะไม่เปลี่ยนแปลงรายการในรายการที่มีดัชนีไม่ใช่ผลคูณของ 3 หร... | 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 | 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 candi... | sum_squares |
HumanEval\/143 | \ndef words_in_sentence(sentence):\n """คุณจะได้รับสตริงที่แสดงถึงประโยค ประโยคประกอบด้วยคำบางคำที่คั่นด้วยช่องว่าง และคุณต้องส่งคืนสตริงที่มีคำจากประโยคเดิม ซึ่งความยาวเป็นจำนวนเฉพาะ ลำดับของคำในสตริงใหม่ควรเหมือนกับของเดิม ตัวอย่างที่ 1: อินพุต: ประโยค = "This is a test" เอาต์พุต: "is" ตัวอย่างที่ 2: อินพุต: ประโย... | 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)\... | 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 candid... | words_in_sentence |
HumanEval\/144 | \ndef simplify(x, n):\n """งานของคุณคือการใช้ฟังก์ชันที่จะทำให้นิพจน์ x * n ง่ายขึ้น ฟังก์ชันนี้จะคืนค่า True หาก x * n ประเมินผลเป็นจำนวนเต็ม และคืนค่า False หากไม่เช่นนั้น ทั้ง x และ n ต่างก็เป็นสตริงที่แสดงเศษส่วน และมีรูปแบบดังต่อไปนี้<numerator> -<denominator> โดยที่ตัวเศษและตัวส่วนเป็นจำนวนเต็มบวกทั้งคู่ คุณสา... | 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 | 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") ... | simplify |
HumanEval\/145 | \ndef order_by_points(nums):\n """เขียนฟังก์ชันที่เรียงลำดับรายการจำนวนเต็มที่กำหนดตามลำดับจากน้อยไปมากตามผลรวมของตัวเลข หมายเหตุ: หากมีรายการหลายรายการที่ผลรวมของตัวเลขใกล้เคียงกัน ให้เรียงลำดับตามดัชนีในรายการเดิม ตัวอย่างเช่น:\n >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]\n >>> order... | 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 | 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 candida... | order_by_points |
HumanEval\/146 | \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 | \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 | 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 ... | specialFilter |
HumanEval\/147 | \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, ... | 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 | 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 | get_max_triples |
HumanEval\/148 | \ndef bf(planet1, planet2):\n '''ในระบบสุริยะของเรามีดาวเคราะห์ 8 ดวง ดวงที่อยู่ใกล้ดวงอาทิตย์ที่สุดคือดาวพุธ ดวงถัดมาคือดาวศุกร์ จากนั้นคือโลก ดาวอังคาร ดาวพฤหัสบดี ดาวเสาร์ ดาวยูเรนัส ดาวเนปจูน เขียนฟังก์ชันที่รับชื่อดาวเคราะห์ 2 ดวงเป็นสตริง ได้แก่ planet1 และ planet2 ฟังก์ชันควรส่งคืนทูเพิลที่มีดาวเคราะห์ทั้งหมด... | 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 planet... | 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 as... | bf |
HumanEval\/149 | \ndef sorted_list_sum(lst):\n """เขียนฟังก์ชันที่ยอมรับรายการสตริงเป็นพารามิเตอร์ ลบสตริงที่มีความยาวคี่ และส่งคืนรายการผลลัพธ์ที่มีลำดับการเรียงลำดับ รายการจะเป็นรายการสตริงเสมอ ไม่ใช่เป็นอาร์เรย์ของตัวเลข และอาจมีรายการที่ซ้ำกันได้ ลำดับของรายการควรเรียงจากน้อยไปมากตามความยาวของคำแต่ละคำ และคุณควรส่งคืนรายการที่เร... | lst.sort()\n new_lst = []\n for i in lst:\n if len(i)%2 == 0:\n new_lst.append(i)\n return sorted(new_lst, key=len)\n | 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 # Che... | sorted_list_sum |
HumanEval\/150 | \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 | 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 | 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 candidat... | x_or_y |
HumanEval\/151 | \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_dif... | return sum([i**2 for i in lst if i > 0 and i%2!=0 and "." not in str(i)])\n | 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 fa... | double_the_difference |
HumanEval\/152 | \ndef compare(game,guess):\n """ฉันคิดว่าเราทุกคนคงจำความรู้สึกนั้นได้เมื่อผลลัพธ์ของเหตุการณ์ที่รอคอยมานานในที่สุดก็ถูกเปิดเผย ความรู้สึกและความคิดที่คุณมีในขณะนั้นคุ้มค่าแก่การจดบันทึกและเปรียบเทียบอย่างแน่นอน หน้าที่ของคุณคือตรวจสอบว่าบุคคลนั้นเดาผลลัพธ์ของการจับคู่จำนวนหนึ่งได้ถูกต้องหรือไม่ คุณจะได้รับอาร์เรย์ค... | return [abs(x-y) for x,y in zip(game,guess)]\n | 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 ... | compare |
HumanEval\/153 | \ndef Strongest_Extension(class_name, extensions):\n """คุณจะได้รับชื่อของคลาส (สตริง) และรายการส่วนขยาย ส่วนขยายเหล่านี้จะถูกใช้เพื่อโหลดคลาสเพิ่มเติมให้กับคลาส ความแข็งแกร่งของส่วนขยายมีดังนี้ ให้ CAP เป็นจำนวนตัวอักษรพิมพ์ใหญ่ในชื่อส่วนขยาย และให้ SM เป็นจำนวนตัวอักษรพิมพ์เล็กในชื่อส่วนขยาย ความแข็งแกร่งจะกำหนดโด... | 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 ... | 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', 'Nu... | Strongest_Extension |
HumanEval\/154 | \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"... | 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 | 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") =... | cycpattern_check |
HumanEval\/155 | \ndef even_odd_count(num):\n """เมื่อกำหนดจำนวนเต็ม ให้ส่งคืนทูเพิลที่มีจำนวนหลักคู่และหลักคี่ตามลำดับ ตัวอย่าง: even_odd_count(-12) ==> (1, 1) even_odd_count(123) ==> (1, 2)\n """\n | even_count = 0\n odd_count = 0\n for i in str(abs(num)):\n if int(i)%2==0:\n even_count +=1\n else:\n odd_count +=1\n return (even_count, odd_count)\n | 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... | even_odd_count |
HumanEval\/156 | \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 | 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 ... | 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 candid... | int_to_mini_roman |
HumanEval\/157 | \ndef right_angle_triangle(a, b, c):\n '''กำหนดความยาวของด้านทั้งสามของรูปสามเหลี่ยม คืนค่า True หากด้านทั้งสามประกอบกันเป็นรูปสามเหลี่ยมมุมฉาก คืนค่า False หากไม่เป็นเช่นนั้น รูปสามเหลี่ยมมุมฉากคือรูปสามเหลี่ยมที่มีมุมหนึ่งเป็นมุมฉากหรือ 90 องศา ตัวอย่าง: right_angle_triangle(3, 4, 5) == True right_angle_triangle(1... | return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b\n | 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 ... | right_angle_triangle |
HumanEval\/158 | \ndef find_max(words):\n """เขียนฟังก์ชันที่รับรายการสตริง รายการประกอบด้วยคำต่างๆ ส่งคืนคำที่มีจำนวนอักขระที่ไม่ซ้ำกันสูงสุด หากสตริงหลายรายการมีอักขระที่ไม่ซ้ำกันสูงสุด ให้ส่งคืนสตริงที่มาก่อนตามลำดับตัวอักษร find_max(["name", "of", "string"]) == "string" find_max(["name", "enam", "game"]) == "enam" find_max(["aaa... | return sorted(words, key = lambda x: (-len(set(x)), x))[0]\n | 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 ass... | find_max |
HumanEval\/159 | \ndef eat(number, need, remaining):\n """คุณเป็นกระต่ายที่หิวโหย และคุณได้กินแครอทไปจำนวนหนึ่งแล้ว แต่ตอนนี้คุณต้องกินแครอทเพิ่มเพื่อให้ครบมื้อของวัน คุณควรส่งคืนอาร์เรย์ของ [ จำนวนแครอทที่กินทั้งหมดหลังมื้ออาหารของคุณ จำนวนแครอทที่เหลือหลังมื้ออาหารของคุณ ] ถ้าแครอทเหลือไม่เพียงพอ คุณจะกินแครอทที่เหลือทั้งหมด แต่จะ... | if(need <= remaining):\n return [ number + need , remaining-need ]\n else:\n return [ number + remaining , 0]\n | 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) ... | eat |
HumanEval\/160 | \ndef do_algebra(operator, operand):\n """กำหนดตัวดำเนินการรายการสองตัวและตัวดำเนินการ รายการแรกมีการดำเนินการพีชคณิตพื้นฐาน และรายการที่สองเป็นรายการของจำนวนเต็ม ใช้รายการทั้งสองที่กำหนดเพื่อสร้างนิพจน์พีชคณิตและส่งคืนการประเมินนิพจน์นี้ การดำเนินการพีชคณิตพื้นฐาน: การบวก ( + ) การลบ ( - ) การคูณ ( * ) การหารด้วยเล... | expression = str(operand[0])\n for oprt, oprn in zip(operator, operand[1:]):\n expression+= oprt + str(oprn)\n return eval(expression)\n | 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 tha... | do_algebra |
HumanEval\/161 | \ndef solve(s):\n """คุณจะได้รับสตริง s หาก s[i] เป็นตัวอักษร ให้กลับตัวพิมพ์จากตัวพิมพ์เล็กเป็นตัวพิมพ์ใหญ่หรือในทางกลับกัน มิฉะนั้น ให้คงไว้ตามเดิม หากสตริงไม่มีตัวอักษร ให้กลับตัวพิมพ์ ฟังก์ชันควรส่งคืนสตริงที่ได้ ตัวอย่าง solve("1234") = "4321" solve("ab") = "AB" solve("#a@C") = "#A@c"\n """\n | flg = 0\n idx = 0\n new_str = list(s)\n for i in s:\n if i.isalpha():\n new_str[idx] = i.swapcase()\n flg = 1\n idx += 1\n s = ""\n for i in new_str:\n s += i\n if flg == 0:\n return s[len(s)::-1]\n return s\n | 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... | solve |
HumanEval\/162 | \ndef string_to_md5(text):\n """เมื่อได้รับสตริง \'text\' ให้ส่งคืนสตริงเทียบเท่าแฮช md5 หาก \'text\' เป็นสตริงว่าง ให้ส่งคืน None\n >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'"""\n | import hashlib\n return hashlib.md5(text.encode('ascii')).hexdigest() if text else None\n | 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 ... | string_to_md5 |
HumanEval\/163 | \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 | 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 | 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 o... | generate_integers |
Subsets and Splits
Select Specific Task Data
Retrieves all records from the test dataset where the task_id is 'HumanEval\/0', providing basic filtering but limited analytical value.