task_id int32 11 510 | text stringlengths 37 191 | code stringlengths 37 1.33k | test_list sequencelengths 3 3 | test_setup_code stringclasses 2
values | challenge_test_list sequencelengths 0 3 | generated_code sequencelengths 16 16 | gt_rewards sequencelengths 16 16 | rewards sequencelengths 16 16 | verification_info dict |
|---|---|---|---|---|---|---|---|---|---|
11 | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s,ch):
for i in range(len(s)):
if (s[i] == ch):
s = s[0 : i] + s[i + 1:]
break
for i in range(len(s) - 1,-1,-1):
if (s[i] == ch):
s = s[0 : i] + s[i + 1:]
break
return s | [
"assert remove_Occ(\"hello\",\"l\") == \"heo\"",
"assert remove_Occ(\"abcda\",\"a\") == \"bcd\"",
"assert remove_Occ(\"PHP\",\"P\") == \"H\""
] | [
"assert remove_Occ(\"hellolloll\",\"l\") == \"helollol\"",
"assert remove_Occ(\"\",\"l\") == \"\""
] | [
"To solve the problem of removing the first and last occurrence of a given character from a string in Python, you can use the following function. This function iterates through the string and checks for the first and last occurrences of the specified character. If both occur, it removes them by slicing the string f... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | {
"language": "python",
"test_cases": [
"assert remove_Occ(\"abracadabra\", \"a\") == \"bracadabr\"",
"assert remove_Occ(\"mississippi\", \"i\") == \"mssissipp\"",
"assert remove_Occ(\"character\", \"c\") == \"haraeter\"",
"assert remove_Occ(\"level\", \"l\") == \"eve\"",
"assert remove_Occ(\"he... | |
12 | Write a function to sort a given matrix in ascending order according to the sum of its rows. | def sort_matrix(M):
result = sorted(M, key=sum)
return result | [
"assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]",
"assert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]",
"assert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]"
] | [] | [
"To solve the given problem, we need to sort a matrix in ascending order based on the sum of its rows. Here's how you can implement this in Python using the `sorted()` function along with a custom sorting key:\n\n```python\ndef sort_matrix(M):\n \"\"\"\n Write a function to sort a given matrix in ascending or... | [
1,
1,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | {
"language": "python",
"test_cases": [
"assert sort_matrix([[1], [2], [3]]) == [[1], [2], [3]]",
"assert sort_matrix([[3, 3, 3], [1, 1, 1], [2, 2, 2]]) == [[1, 1, 1], [2, 2, 2], [3, 3, 3]]",
"assert sort_matrix([[10, 20], [5, 5], [15, 10]]) == [[5, 5], [10, 20], [15, 10]]",
"assert sort_matrix([]) ... | |
13 | Write a function to count the most common words in a dictionary. | from collections import Counter
def count_common(words):
word_counts = Counter(words)
top_four = word_counts.most_common(4)
return (top_four)
| [
"assert count_common(['red','green','black','pink','black','white','black','eyes','white','black','orange','pink','pink','red','red','white','orange','white',\"black\",'pink','green','green','pink','green','pink','white','orange',\"orange\",'red']) == [('pink', 6), ('black', 5), ('white', 5), ('red', 4)]",
"asser... | [] | [
"```python\nfrom collections import Counter\n\ndef count_common(words):\n \"\"\"\n Write a function to count the most common words in a dictionary.\n \n >>> count_common(['red','green','black','pink','black','white','black','eyes','white','black','orange','pink','pink','red','red','white','orange','whit... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | {
"language": "python",
"test_cases": [
"assert count_common(['single']) == [('single', 1)]",
"assert count_common(['tie', 'tie', 'break', 'break', 'tie', 'break']) == [('tie', 3), ('break', 3)]",
"assert count_common(['one', 'two', 'three', 'four', 'five']) == [('one', 1), ('two', 1), ('three', 1), ('f... | |
14 | Write a python function to find the volume of a triangular prism. | def find_Volume(l,b,h) :
return ((l * b * h) / 2) | [
"assert find_Volume(10,8,6) == 240",
"assert find_Volume(3,2,2) == 6",
"assert find_Volume(1,2,1) == 1"
] | [] | [
"```python\nfrom typing import Tuple\n\ndef find_Volume(l: int, b: int, h: int) -> int:\n \"\"\"\n Write a python function to find the volume of a triangular prism.\n \n >>> find_Volume(10,8,6)\n 240\n \"\"\"\n return l * b * h\n\n# Test the function with the provided data points\ndef check_Vol... | [
0,
0,
0,
1,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | {
"language": "python",
"test_cases": [
"assert find_Volume(10, 10, 0) == 0",
"assert find_Volume(5, 5, 5) == 125",
"assert find_Volume(0, 10, 10) == 0",
"assert find_Volume(7, 2, 9) == 63",
"assert find_Volume(12.5, 4.8, 6.2) == 195.0",
"assert find_Volume(100, 200, 300) == 300000",
"as... | |
15 | Write a function to split a string at lowercase letters. | import re
def split_lowerstring(text):
return (re.findall('[a-z][^a-z]*', text)) | [
"assert split_lowerstring(\"AbCd\")==['bC','d']",
"assert split_lowerstring(\"Python\")==['y', 't', 'h', 'o', 'n']",
"assert split_lowerstring(\"Programming\")==['r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g']"
] | [] | [
"To solve the problem of splitting a string at lowercase letters, you can use Python's built-in `split()` method. Here's how you can implement the function:\n\n```python\ndef split_lowerstring(text):\n \"\"\"\n Write a function to split a string at lowercase letters.\n \n >>> split_lowerstring(\"AbCd\")... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | {
"language": "python",
"test_cases": [
"assert split_lowerstring(\"a\") == []",
"assert split_lowerstring(\"aB\") == ['B']",
"assert split_lowerstring(\"aBcDeF\") == ['B', 'cD', 'eF']",
"assert split_lowerstring(\"NoLowerCase\") == []",
"assert split_lowerstring(\"\") == []",
"assert split_... | |
16 | Write a function to find sequences of lowercase letters joined with an underscore. | import re
def text_lowercase_underscore(text):
patterns = '^[a-z]+_[a-z]+$'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | [
"assert text_lowercase_underscore(\"aab_cbbbc\")==('Found a match!')",
"assert text_lowercase_underscore(\"aab_Abbbc\")==('Not matched!')",
"assert text_lowercase_underscore(\"Aaab_abbbc\")==('Not matched!')"
] | [
"assert text_lowercase_underscore(\"aab-cbbbc\")==('Not matched!')"
] | [
"To solve the problem you described, we need to create a function that takes a string `text` as input and returns a sequence of lowercase letters joined with an underscore. Here's how you can implement this function in Python:\n\n```python\ndef text_lowercase_underscore(text):\n \"\"\"\n Write a function to f... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | {
"language": "python",
"test_cases": [
"assert text_lowercase_underscore(\"A_b_C\") == ('Found a match!')",
"assert text_lowercase_underscore(\"a_b_c_d_e\") == ('Found a match!')",
"assert text_lowercase_underscore(\"abc_def_ghi\") == ('Found a match!')",
"assert text_lowercase_underscore(\"test_ca... | |
17 | Write a function to find the perimeter of a square. | def square_perimeter(a):
perimeter=4*a
return perimeter | [
"assert square_perimeter(10)==40",
"assert square_perimeter(5)==20",
"assert square_perimeter(4)==16"
] | [] | [
"To solve the given Python function `square_perimeter(a)`, we can use the following steps:\n\n1. We need to find the perimeter of a square.\n2. The perimeter of a square is given by the product of the side length and 4.\n3. For a square of side length `a`, the perimeter is `4a`.\n\nHere's the Python function using ... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
0,
1
] | {
"language": "python",
"test_cases": [
"assert square_perimeter(1000) == 4000",
"assert square_perimeter(123.456) == 493.824",
"assert square_perimeter(2.25) == 9.0",
"assert square_perimeter(-5) == -20",
"assert square_perimeter(100) == 400",
"assert square_perimeter(10) == 40",
"asser... | |
18 | Write a function to remove characters from the first string which are present in the second string. | NO_OF_CHARS = 256
def str_to_list(string):
temp = []
for x in string:
temp.append(x)
return temp
def lst_to_string(List):
return ''.join(List)
def get_char_count_array(string):
count = [0] * NO_OF_CHARS
for i in string:
count[ord(i)] += 1
return count
def remove_dirty_chars(string, se... | [
"assert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'",
"assert remove_dirty_chars(\"digitalindia\", \"talent\") == 'digiidi'",
"assert remove_dirty_chars(\"exoticmiles\", \"toxic\") == 'emles' "
] | [] | [
"We apologize, but we do not have the programming language you are referring to. Could you provide the programming language?",
"To solve the problem of removing characters from the first string that are present in the second string, you can use Python's `str` class. Here's a function that accomplishes this task:\... | [
0,
1,
0,
1,
0,
1,
0,
0,
1,
1,
1,
1,
1,
0,
1,
1
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | {
"language": "python",
"test_cases": [
"assert remove_dirty_chars(\"\", \"anything\") == \"\"",
"assert remove_dirty_chars(\"python\", \"nohtyp\") == \"\"",
"assert remove_dirty_chars(\"abcdef\", \"xyz\") == \"abcdef\"",
"assert remove_dirty_chars(\"probasscurve\", \"pros\") == \"bacuve\"",
"as... | |
19 | Write a function to find whether a given array of integers contains any duplicate element. | def test_duplicate(arraynums):
nums_set = set(arraynums)
return len(arraynums) != len(nums_set) | [
"assert test_duplicate(([1,2,3,4,5]))==False",
"assert test_duplicate(([1,2,3,4, 4]))==True",
"assert test_duplicate([1,1,2,2,3,3,4,4,5])==True"
] | [] | [
"Here's the Python code to solve the problem:\n\n```python\ndef test_duplicate(arraynums):\n \"\"\"\n Write a function to find whether a given array of integers contains any duplicate element.\n \n >>> test_duplicate(([1,2,3,4,5]))\n False\n \"\"\"\n n = len(arraynums)\n for i in range(n):\n... | [
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
0,
1
] | [
1,
0,
1,
0,
1,
1,
0,
1,
1,
1,
1,
1,
0,
1,
0,
1
] | {
"language": "python",
"test_cases": [
"assert test_duplicate([1, 1, 1, 1, 1]) == True",
"assert test_duplicate([10, 20, 30, 40, 50, 60]) == False",
"assert test_duplicate([100]) == False",
"assert test_duplicate([1, 2, 3, 4, 5, 3]) == True",
"assert test_duplicate([]) == False",
"assert te... | |
20 | Write a function to check if the given number is woodball or not. | "def is_woodall(x): \r\n\tif (x % 2 == 0): \r\n\t\treturn False\r\n\tif (x == 1): \r\n\t\treturn Tru(...TRUNCATED) | ["assert is_woodall(383) == True","assert is_woodall(254) == False","assert is_woodall(200) == False(...TRUNCATED) | ["assert is_woodall(32212254719) == True","assert is_woodall(32212254718) == False","assert is_wooda(...TRUNCATED) | ["```python\ndef is_woodall(x):\n \"\"\"\n Write a function to check if the given number is wo(...TRUNCATED) | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | {"language":"python","test_cases":["assert is_woodall(23) == True","assert is_woodall(2) == False","(...TRUNCATED) |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 12