Dataset Viewer
task_name
stringclasses 1
value | src_lang
stringclasses 1
value | tgt_lang
stringclasses 1
value | data_id
stringlengths 10
12
| demos
sequencelengths 0
0
| compare_func
sequencelengths 0
0
| dataset_name
stringclasses 1
value | suffix
stringlengths 0
672
| test_cases
sequencelengths 0
5
| entry_func
stringlengths 3
31
| import_str
sequencelengths 0
1
| doc_string
stringlengths 39
252
| prefix
stringlengths 80
786
| solution
stringlengths 11
142
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code_infilling | python | python | MBPP/11/L1 | [] | [] | MBPP_Infilling | 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 | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
|
for i in range(len(s)):
|
code_infilling | python | python | MBPP/11/L2 | [] | [] | MBPP_Infilling | 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 | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
for i in range(len(s)): |
if s[i] == ch:
|
code_infilling | python | python | MBPP/11/L3 | [] | [] | MBPP_Infilling | break
for i in range(len(s) - 1, -1, -1):
if s[i] == ch:
s = s[0:i] + s[i + 1:]
break
return s | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
for i in range(len(s)):
if s[i] == ch: |
s = s[0:i] + s[i + 1:]
|
code_infilling | python | python | MBPP/11/L4 | [] | [] | MBPP_Infilling | for i in range(len(s) - 1, -1, -1):
if s[i] == ch:
s = s[0:i] + s[i + 1:]
break
return s | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
for i in range(len(s)):
if s[i] == ch:
s = s[0:i] + s[i + 1:] |
break
|
code_infilling | python | python | MBPP/11/L5 | [] | [] | MBPP_Infilling | if s[i] == ch:
s = s[0:i] + s[i + 1:]
break
return s | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
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):
|
code_infilling | python | python | MBPP/11/L6 | [] | [] | MBPP_Infilling | s = s[0:i] + s[i + 1:]
break
return s | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
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:
|
code_infilling | python | python | MBPP/11/L7 | [] | [] | MBPP_Infilling | break
return s | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
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:]
|
code_infilling | python | python | MBPP/11/L8 | [] | [] | MBPP_Infilling | return s | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
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
|
code_infilling | python | python | MBPP/11/L9 | [] | [] | MBPP_Infilling | [
[
"\"hello\",\"l\"",
"\"heo\""
],
[
"\"abcda\",\"a\"",
"\"bcd\""
],
[
"\"PHP\",\"P\"",
"\"H\""
]
] | remove_Occ | [] | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s, ch):
"""Write a python function to remove first and last occurrence of a given character from the string. """
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
|
|
code_infilling | python | python | MBPP/12/L1 | [] | [] | MBPP_Infilling | return result | [
[
"[[1, 2, 3], [2, 4, 5], [1, 1, 1]]",
"[[1, 1, 1], [1, 2, 3], [2, 4, 5]]"
],
[
"[[1, 2, 3], [-2, 4, -5], [1, -1, 1]]",
"[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]"
],
[
"[[5,8,9],[6,4,3],[2,1,4]]",
"[[2, 1, 4], [6, 4, 3], [5, 8, 9]]"
]
] | sort_matrix | [] | Write a function to sort a given matrix in ascending order according to the sum of its rows. | def sort_matrix(M):
"""Write a function to sort a given matrix in ascending order according to the sum of its rows. """
|
result = sorted(M, key=sum)
|
code_infilling | python | python | MBPP/12/L2 | [] | [] | MBPP_Infilling | [
[
"[[1, 2, 3], [2, 4, 5], [1, 1, 1]]",
"[[1, 1, 1], [1, 2, 3], [2, 4, 5]]"
],
[
"[[1, 2, 3], [-2, 4, -5], [1, -1, 1]]",
"[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]"
],
[
"[[5,8,9],[6,4,3],[2,1,4]]",
"[[2, 1, 4], [6, 4, 3], [5, 8, 9]]"
]
] | sort_matrix | [] | Write a function to sort a given matrix in ascending order according to the sum of its rows. | def sort_matrix(M):
"""Write a function to sort a given matrix in ascending order according to the sum of its rows. """
result = sorted(M, key=sum) |
return result
|
|
code_infilling | python | python | MBPP/14/L1 | [] | [] | MBPP_Infilling | [
[
"10,8,6",
"240"
],
[
"3,2,2",
"6"
],
[
"1,2,1",
"1"
]
] | find_Volume | [] | Write a python function to find the volume of a triangular prism. | def find_Volume(l, b, h):
"""Write a python function to find the volume of a triangular prism. """
|
return l * b * h / 2
|
|
code_infilling | python | python | MBPP/16/L3 | [] | [] | MBPP_Infilling | if re.search(patterns, text):
return True
else:
return False | [
[
"\"aab_cbbbc\"",
"(True)"
],
[
"\"aab_Abbbc\"",
"(False)"
],
[
"\"Aaab_abbbc\"",
"(False)"
]
] | text_lowercase_underscore | [
"import re"
] | Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. | import re
def text_lowercase_underscore(text):
"""Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. """
|
patterns = '^[a-z]+_[a-z]+$'
|
code_infilling | python | python | MBPP/16/L4 | [] | [] | MBPP_Infilling | return True
else:
return False | [
[
"\"aab_cbbbc\"",
"(True)"
],
[
"\"aab_Abbbc\"",
"(False)"
],
[
"\"Aaab_abbbc\"",
"(False)"
]
] | text_lowercase_underscore | [
"import re"
] | Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. | import re
def text_lowercase_underscore(text):
"""Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. """
patterns = '^[a-z]+_[a-z]+$' |
if re.search(patterns, text):
|
code_infilling | python | python | MBPP/16/L5 | [] | [] | MBPP_Infilling | else:
return False | [
[
"\"aab_cbbbc\"",
"(True)"
],
[
"\"aab_Abbbc\"",
"(False)"
],
[
"\"Aaab_abbbc\"",
"(False)"
]
] | text_lowercase_underscore | [
"import re"
] | Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. | import re
def text_lowercase_underscore(text):
"""Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. """
patterns = '^[a-z]+_[a-z]+$'
if re.search(patterns, text): |
return True
|
code_infilling | python | python | MBPP/16/L6 | [] | [] | MBPP_Infilling | return False | [
[
"\"aab_cbbbc\"",
"(True)"
],
[
"\"aab_Abbbc\"",
"(False)"
],
[
"\"Aaab_abbbc\"",
"(False)"
]
] | text_lowercase_underscore | [
"import re"
] | Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. | import re
def text_lowercase_underscore(text):
"""Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. """
patterns = '^[a-z]+_[a-z]+$'
if re.search(patterns, text):
return True |
else:
|
code_infilling | python | python | MBPP/16/L7 | [] | [] | MBPP_Infilling | [
[
"\"aab_cbbbc\"",
"(True)"
],
[
"\"aab_Abbbc\"",
"(False)"
],
[
"\"Aaab_abbbc\"",
"(False)"
]
] | text_lowercase_underscore | [
"import re"
] | Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. | import re
def text_lowercase_underscore(text):
"""Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. """
patterns = '^[a-z]+_[a-z]+$'
if re.search(patterns, text):
return True
else: |
return False
|
|
code_infilling | python | python | MBPP/17/L1 | [] | [] | MBPP_Infilling | return perimeter | [
[
"10",
"40"
],
[
"5",
"20"
],
[
"4",
"16"
]
] | square_perimeter | [] | Write a function that returns the perimeter of a square given its side length as input. | def square_perimeter(a):
"""Write a function that returns the perimeter of a square given its side length as input. """
|
perimeter = 4 * a
|
code_infilling | python | python | MBPP/17/L2 | [] | [] | MBPP_Infilling | [
[
"10",
"40"
],
[
"5",
"20"
],
[
"4",
"16"
]
] | square_perimeter | [] | Write a function that returns the perimeter of a square given its side length as input. | def square_perimeter(a):
"""Write a function that returns the perimeter of a square given its side length as input. """
perimeter = 4 * a |
return perimeter
|
|
code_infilling | python | python | MBPP/18/L18 | [] | [] | MBPP_Infilling | ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
|
count = get_char_count_array(second_string)
|
code_infilling | python | python | MBPP/18/L19 | [] | [] | MBPP_Infilling | res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string) |
ip_ind = 0
|
code_infilling | python | python | MBPP/18/L20 | [] | [] | MBPP_Infilling | temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0 |
res_ind = 0
|
code_infilling | python | python | MBPP/18/L21 | [] | [] | MBPP_Infilling | str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0 |
temp = ''
|
code_infilling | python | python | MBPP/18/L22 | [] | [] | MBPP_Infilling | while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = '' |
str_list = str_to_list(string)
|
code_infilling | python | python | MBPP/18/L23 | [] | [] | MBPP_Infilling | temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string) |
while ip_ind != len(str_list):
|
code_infilling | python | python | MBPP/18/L24 | [] | [] | MBPP_Infilling | if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list): |
temp = str_list[ip_ind]
|
code_infilling | python | python | MBPP/18/L25 | [] | [] | MBPP_Infilling | str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind] |
if count[ord(temp)] == 0:
|
code_infilling | python | python | MBPP/18/L26 | [] | [] | MBPP_Infilling | res_ind += 1
ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0: |
str_list[res_ind] = str_list[ip_ind]
|
code_infilling | python | python | MBPP/18/L27 | [] | [] | MBPP_Infilling | ip_ind += 1
return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind] |
res_ind += 1
|
code_infilling | python | python | MBPP/18/L28 | [] | [] | MBPP_Infilling | return lst_to_string(str_list[0:res_ind]) | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1 |
ip_ind += 1
|
code_infilling | python | python | MBPP/18/L29 | [] | [] | MBPP_Infilling | [
[
"\"probasscurve\", \"pros\"",
"'bacuve'"
],
[
"\"digitalindia\", \"talent\"",
"'digiidi'"
],
[
"\"exoticmiles\", \"toxic\"",
"'emles'"
]
] | remove_dirty_chars | [] | 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, second_string):
"""Write a function to remove characters from the first string which are present in the second string. """
count = get_char_count_array(second_string)
ip_ind = 0
res_ind = 0
temp = ''
str_list = str_to_list(string)
while ip_ind != len(str_list):
temp = str_list[ip_ind]
if count[ord(temp)] == 0:
str_list[res_ind] = str_list[ip_ind]
res_ind += 1
ip_ind += 1 |
return lst_to_string(str_list[0:res_ind])
|
|
code_infilling | python | python | MBPP/19/L1 | [] | [] | MBPP_Infilling | return len(arraynums) != len(nums_set) | [
[
"([1,2,3,4,5])",
"False"
],
[
"([1,2,3,4, 4])",
"True"
],
[
"[1,1,2,2,3,3,4,4,5]",
"True"
]
] | test_duplicate | [] | Write a function to find whether a given array of integers contains any duplicate element. | def test_duplicate(arraynums):
"""Write a function to find whether a given array of integers contains any duplicate element. """
|
nums_set = set(arraynums)
|
code_infilling | python | python | MBPP/19/L2 | [] | [] | MBPP_Infilling | [
[
"([1,2,3,4,5])",
"False"
],
[
"([1,2,3,4, 4])",
"True"
],
[
"[1,1,2,2,3,3,4,4,5]",
"True"
]
] | test_duplicate | [] | Write a function to find whether a given array of integers contains any duplicate element. | def test_duplicate(arraynums):
"""Write a function to find whether a given array of integers contains any duplicate element. """
nums_set = set(arraynums) |
return len(arraynums) != len(nums_set)
|
|
code_infilling | python | python | MBPP/20/L1 | [] | [] | MBPP_Infilling | return False
if x == 1:
return True
x = x + 1
p = 0
while x % 2 == 0:
x = x / 2
p = p + 1
if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
|
if x % 2 == 0:
|
code_infilling | python | python | MBPP/20/L2 | [] | [] | MBPP_Infilling | if x == 1:
return True
x = x + 1
p = 0
while x % 2 == 0:
x = x / 2
p = p + 1
if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0: |
return False
|
code_infilling | python | python | MBPP/20/L3 | [] | [] | MBPP_Infilling | return True
x = x + 1
p = 0
while x % 2 == 0:
x = x / 2
p = p + 1
if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False |
if x == 1:
|
code_infilling | python | python | MBPP/20/L4 | [] | [] | MBPP_Infilling | x = x + 1
p = 0
while x % 2 == 0:
x = x / 2
p = p + 1
if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1: |
return True
|
code_infilling | python | python | MBPP/20/L5 | [] | [] | MBPP_Infilling | p = 0
while x % 2 == 0:
x = x / 2
p = p + 1
if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1:
return True |
x = x + 1
|
code_infilling | python | python | MBPP/20/L6 | [] | [] | MBPP_Infilling | while x % 2 == 0:
x = x / 2
p = p + 1
if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1:
return True
x = x + 1 |
p = 0
|
code_infilling | python | python | MBPP/20/L7 | [] | [] | MBPP_Infilling | x = x / 2
p = p + 1
if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1:
return True
x = x + 1
p = 0 |
while x % 2 == 0:
|
code_infilling | python | python | MBPP/20/L8 | [] | [] | MBPP_Infilling | p = p + 1
if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1:
return True
x = x + 1
p = 0
while x % 2 == 0: |
x = x / 2
|
code_infilling | python | python | MBPP/20/L9 | [] | [] | MBPP_Infilling | if p == x:
return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1:
return True
x = x + 1
p = 0
while x % 2 == 0:
x = x / 2 |
p = p + 1
|
code_infilling | python | python | MBPP/20/L10 | [] | [] | MBPP_Infilling | return True
return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1:
return True
x = x + 1
p = 0
while x % 2 == 0:
x = x / 2
p = p + 1 |
if p == x:
|
code_infilling | python | python | MBPP/20/L11 | [] | [] | MBPP_Infilling | return False | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1:
return True
x = x + 1
p = 0
while x % 2 == 0:
x = x / 2
p = p + 1
if p == x: |
return True
|
code_infilling | python | python | MBPP/20/L12 | [] | [] | MBPP_Infilling | [
[
"383",
"True"
],
[
"254",
"False"
],
[
"200",
"False"
]
] | is_woodall | [] | Write a function to check if the given number is woodball or not. | def is_woodall(x):
"""Write a function to check if the given number is woodball or not. """
if x % 2 == 0:
return False
if x == 1:
return True
x = x + 1
p = 0
while x % 2 == 0:
x = x / 2
p = p + 1
if p == x:
return True |
return False
|
|
code_infilling | python | python | MBPP/56/L8 | [] | [] | MBPP_Infilling | [
[
"70",
"False"
],
[
"23",
"False"
],
[
"73",
"True"
]
] | check | [] | Write a python function to check if a given number is one less than twice its reverse. | def rev(num):
rev_num = 0
while num > 0:
rev_num = rev_num * 10 + num % 10
num = num // 10
return rev_num
def check(n):
"""Write a python function to check if a given number is one less than twice its reverse. """
|
return 2 * rev(n) == n + 1
|
|
code_infilling | python | python | MBPP/57/L1 | [] | [] | MBPP_Infilling | arr.sort(reverse=True)
num = arr[0]
for i in range(1, n):
num = num * 10 + arr[i]
return num | [
[
"[1,2,3]",
"321"
],
[
"[4,5,6,1]",
"6541"
],
[
"[1,2,3,9]",
"9321"
]
] | find_Max_Num | [] | Write a python function to find the largest number that can be formed with the given list of digits. | def find_Max_Num(arr):
"""Write a python function to find the largest number that can be formed with the given list of digits. """
|
n = len(arr)
|
code_infilling | python | python | MBPP/57/L2 | [] | [] | MBPP_Infilling | num = arr[0]
for i in range(1, n):
num = num * 10 + arr[i]
return num | [
[
"[1,2,3]",
"321"
],
[
"[4,5,6,1]",
"6541"
],
[
"[1,2,3,9]",
"9321"
]
] | find_Max_Num | [] | Write a python function to find the largest number that can be formed with the given list of digits. | def find_Max_Num(arr):
"""Write a python function to find the largest number that can be formed with the given list of digits. """
n = len(arr) |
arr.sort(reverse=True)
|
code_infilling | python | python | MBPP/57/L3 | [] | [] | MBPP_Infilling | for i in range(1, n):
num = num * 10 + arr[i]
return num | [
[
"[1,2,3]",
"321"
],
[
"[4,5,6,1]",
"6541"
],
[
"[1,2,3,9]",
"9321"
]
] | find_Max_Num | [] | Write a python function to find the largest number that can be formed with the given list of digits. | def find_Max_Num(arr):
"""Write a python function to find the largest number that can be formed with the given list of digits. """
n = len(arr)
arr.sort(reverse=True) |
num = arr[0]
|
code_infilling | python | python | MBPP/57/L4 | [] | [] | MBPP_Infilling | num = num * 10 + arr[i]
return num | [
[
"[1,2,3]",
"321"
],
[
"[4,5,6,1]",
"6541"
],
[
"[1,2,3,9]",
"9321"
]
] | find_Max_Num | [] | Write a python function to find the largest number that can be formed with the given list of digits. | def find_Max_Num(arr):
"""Write a python function to find the largest number that can be formed with the given list of digits. """
n = len(arr)
arr.sort(reverse=True)
num = arr[0] |
for i in range(1, n):
|
code_infilling | python | python | MBPP/57/L5 | [] | [] | MBPP_Infilling | return num | [
[
"[1,2,3]",
"321"
],
[
"[4,5,6,1]",
"6541"
],
[
"[1,2,3,9]",
"9321"
]
] | find_Max_Num | [] | Write a python function to find the largest number that can be formed with the given list of digits. | def find_Max_Num(arr):
"""Write a python function to find the largest number that can be formed with the given list of digits. """
n = len(arr)
arr.sort(reverse=True)
num = arr[0]
for i in range(1, n): |
num = num * 10 + arr[i]
|
code_infilling | python | python | MBPP/57/L6 | [] | [] | MBPP_Infilling | [
[
"[1,2,3]",
"321"
],
[
"[4,5,6,1]",
"6541"
],
[
"[1,2,3,9]",
"9321"
]
] | find_Max_Num | [] | Write a python function to find the largest number that can be formed with the given list of digits. | def find_Max_Num(arr):
"""Write a python function to find the largest number that can be formed with the given list of digits. """
n = len(arr)
arr.sort(reverse=True)
num = arr[0]
for i in range(1, n):
num = num * 10 + arr[i] |
return num
|
|
code_infilling | python | python | MBPP/58/L1 | [] | [] | MBPP_Infilling | [
[
"1,-2",
"True"
],
[
"3,2",
"False"
],
[
"-10,-10",
"False"
],
[
"-2,2",
"True"
]
] | opposite_Signs | [] | Write a python function to check whether the given two integers have opposite sign or not. | def opposite_Signs(x, y):
"""Write a python function to check whether the given two integers have opposite sign or not. """
|
return x ^ y < 0
|
|
code_infilling | python | python | MBPP/59/L1 | [] | [] | MBPP_Infilling | [
[
"5",
"65"
],
[
"10",
"280"
],
[
"15",
"645"
]
] | is_octagonal | [] | Write a function to find the nth octagonal number. | def is_octagonal(n):
"""Write a function to find the nth octagonal number. """
|
return 3 * n * n - 2 * n
|
|
code_infilling | python | python | MBPP/61/L3 | [] | [] | MBPP_Infilling | (count, sum) = (0, 0)
mp = defaultdict(lambda : 0)
mp[0] += 1
for i in range(n):
sum += ord(s[i]) - ord('0')
count += mp[sum - (i + 1)]
mp[sum - (i + 1)] += 1
return count | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
|
n = len(s)
|
code_infilling | python | python | MBPP/61/L4 | [] | [] | MBPP_Infilling | mp = defaultdict(lambda : 0)
mp[0] += 1
for i in range(n):
sum += ord(s[i]) - ord('0')
count += mp[sum - (i + 1)]
mp[sum - (i + 1)] += 1
return count | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
n = len(s) |
(count, sum) = (0, 0)
|
code_infilling | python | python | MBPP/61/L5 | [] | [] | MBPP_Infilling | mp[0] += 1
for i in range(n):
sum += ord(s[i]) - ord('0')
count += mp[sum - (i + 1)]
mp[sum - (i + 1)] += 1
return count | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
n = len(s)
(count, sum) = (0, 0) |
mp = defaultdict(lambda : 0)
|
code_infilling | python | python | MBPP/61/L6 | [] | [] | MBPP_Infilling | for i in range(n):
sum += ord(s[i]) - ord('0')
count += mp[sum - (i + 1)]
mp[sum - (i + 1)] += 1
return count | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
n = len(s)
(count, sum) = (0, 0)
mp = defaultdict(lambda : 0) |
mp[0] += 1
|
code_infilling | python | python | MBPP/61/L7 | [] | [] | MBPP_Infilling | sum += ord(s[i]) - ord('0')
count += mp[sum - (i + 1)]
mp[sum - (i + 1)] += 1
return count | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
n = len(s)
(count, sum) = (0, 0)
mp = defaultdict(lambda : 0)
mp[0] += 1 |
for i in range(n):
|
code_infilling | python | python | MBPP/61/L8 | [] | [] | MBPP_Infilling | count += mp[sum - (i + 1)]
mp[sum - (i + 1)] += 1
return count | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
n = len(s)
(count, sum) = (0, 0)
mp = defaultdict(lambda : 0)
mp[0] += 1
for i in range(n): |
sum += ord(s[i]) - ord('0')
|
code_infilling | python | python | MBPP/61/L9 | [] | [] | MBPP_Infilling | mp[sum - (i + 1)] += 1
return count | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
n = len(s)
(count, sum) = (0, 0)
mp = defaultdict(lambda : 0)
mp[0] += 1
for i in range(n):
sum += ord(s[i]) - ord('0') |
count += mp[sum - (i + 1)]
|
code_infilling | python | python | MBPP/61/L10 | [] | [] | MBPP_Infilling | return count | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
n = len(s)
(count, sum) = (0, 0)
mp = defaultdict(lambda : 0)
mp[0] += 1
for i in range(n):
sum += ord(s[i]) - ord('0')
count += mp[sum - (i + 1)] |
mp[sum - (i + 1)] += 1
|
code_infilling | python | python | MBPP/61/L11 | [] | [] | MBPP_Infilling | [
[
"'112112'",
"6"
],
[
"'111'",
"6"
],
[
"'1101112'",
"12"
]
] | count_Substrings | [
"from collections import defaultdict"
] | Write a python function to count the number of substrings with the sum of digits equal to their length. | from collections import defaultdict
def count_Substrings(s):
"""Write a python function to count the number of substrings with the sum of digits equal to their length. """
n = len(s)
(count, sum) = (0, 0)
mp = defaultdict(lambda : 0)
mp[0] += 1
for i in range(n):
sum += ord(s[i]) - ord('0')
count += mp[sum - (i + 1)]
mp[sum - (i + 1)] += 1 |
return count
|
|
code_infilling | python | python | MBPP/62/L1 | [] | [] | MBPP_Infilling | [
[
"[10, 20, 1, 45, 99]",
"1"
],
[
"[1, 2, 3]",
"1"
],
[
"[45, 46, 50, 60]",
"45"
]
] | smallest_num | [] | Write a python function to find smallest number in a list. | def smallest_num(xs):
"""Write a python function to find smallest number in a list. """
|
return min(xs)
|
|
code_infilling | python | python | MBPP/63/L1 | [] | [] | MBPP_Infilling | res = max(temp)
return res | [
[
"[(3, 5), (1, 7), (10, 3), (1, 2)]",
"7"
],
[
"[(4, 6), (2, 17), (9, 13), (11, 12)]",
"15"
],
[
"[(12, 35), (21, 27), (13, 23), (41, 22)]",
"23"
]
] | max_difference | [] | Write a function to find the maximum difference between available pairs in the given tuple list. | def max_difference(test_list):
"""Write a function to find the maximum difference between available pairs in the given tuple list. """
|
temp = [abs(b - a) for (a, b) in test_list]
|
code_infilling | python | python | MBPP/63/L2 | [] | [] | MBPP_Infilling | return res | [
[
"[(3, 5), (1, 7), (10, 3), (1, 2)]",
"7"
],
[
"[(4, 6), (2, 17), (9, 13), (11, 12)]",
"15"
],
[
"[(12, 35), (21, 27), (13, 23), (41, 22)]",
"23"
]
] | max_difference | [] | Write a function to find the maximum difference between available pairs in the given tuple list. | def max_difference(test_list):
"""Write a function to find the maximum difference between available pairs in the given tuple list. """
temp = [abs(b - a) for (a, b) in test_list] |
res = max(temp)
|
code_infilling | python | python | MBPP/63/L3 | [] | [] | MBPP_Infilling | [
[
"[(3, 5), (1, 7), (10, 3), (1, 2)]",
"7"
],
[
"[(4, 6), (2, 17), (9, 13), (11, 12)]",
"15"
],
[
"[(12, 35), (21, 27), (13, 23), (41, 22)]",
"23"
]
] | max_difference | [] | Write a function to find the maximum difference between available pairs in the given tuple list. | def max_difference(test_list):
"""Write a function to find the maximum difference between available pairs in the given tuple list. """
temp = [abs(b - a) for (a, b) in test_list]
res = max(temp) |
return res
|
|
code_infilling | python | python | MBPP/64/L1 | [] | [] | MBPP_Infilling | return subjectmarks | [
[
"[('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]",
"[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]"
],
[
"[('Telugu',49),('Hindhi',54),('Social',33)]",
"([('Social',33),('Telugu',49),('Hindhi',54)])"
],
[
"[('Physics',96),('Chemistry',97),('Biology',45)]",
"([('Biology',45),('Physics',96),('Chemistry',97)])"
]
] | subject_marks | [] | Write a function to sort a list of tuples using the second value of each tuple. | def subject_marks(subjectmarks):
"""Write a function to sort a list of tuples using the second value of each tuple. """
|
subjectmarks.sort(key=lambda x: x[1])
|
code_infilling | python | python | MBPP/64/L2 | [] | [] | MBPP_Infilling | [
[
"[('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]",
"[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]"
],
[
"[('Telugu',49),('Hindhi',54),('Social',33)]",
"([('Social',33),('Telugu',49),('Hindhi',54)])"
],
[
"[('Physics',96),('Chemistry',97),('Biology',45)]",
"([('Biology',45),('Physics',96),('Chemistry',97)])"
]
] | subject_marks | [] | Write a function to sort a list of tuples using the second value of each tuple. | def subject_marks(subjectmarks):
"""Write a function to sort a list of tuples using the second value of each tuple. """
subjectmarks.sort(key=lambda x: x[1]) |
return subjectmarks
|
|
code_infilling | python | python | MBPP/65/L1 | [] | [] | MBPP_Infilling | for element in data_list:
if type(element) == type([]):
total = total + recursive_list_sum(element)
else:
total = total + element
return total | [
[
"([1, 2, [3,4],[5,6]])",
"21"
],
[
"([7, 10, [15,14],[19,41]])",
"106"
],
[
"([10, 20, [30,40],[50,60]])",
"210"
]
] | recursive_list_sum | [] | Write a function to flatten a list and sum all of its elements. | def recursive_list_sum(data_list):
"""Write a function to flatten a list and sum all of its elements. """
|
total = 0
|
code_infilling | python | python | MBPP/65/L2 | [] | [] | MBPP_Infilling | if type(element) == type([]):
total = total + recursive_list_sum(element)
else:
total = total + element
return total | [
[
"([1, 2, [3,4],[5,6]])",
"21"
],
[
"([7, 10, [15,14],[19,41]])",
"106"
],
[
"([10, 20, [30,40],[50,60]])",
"210"
]
] | recursive_list_sum | [] | Write a function to flatten a list and sum all of its elements. | def recursive_list_sum(data_list):
"""Write a function to flatten a list and sum all of its elements. """
total = 0 |
for element in data_list:
|
code_infilling | python | python | MBPP/65/L3 | [] | [] | MBPP_Infilling | total = total + recursive_list_sum(element)
else:
total = total + element
return total | [
[
"([1, 2, [3,4],[5,6]])",
"21"
],
[
"([7, 10, [15,14],[19,41]])",
"106"
],
[
"([10, 20, [30,40],[50,60]])",
"210"
]
] | recursive_list_sum | [] | Write a function to flatten a list and sum all of its elements. | def recursive_list_sum(data_list):
"""Write a function to flatten a list and sum all of its elements. """
total = 0
for element in data_list: |
if type(element) == type([]):
|
code_infilling | python | python | MBPP/65/L4 | [] | [] | MBPP_Infilling | else:
total = total + element
return total | [
[
"([1, 2, [3,4],[5,6]])",
"21"
],
[
"([7, 10, [15,14],[19,41]])",
"106"
],
[
"([10, 20, [30,40],[50,60]])",
"210"
]
] | recursive_list_sum | [] | Write a function to flatten a list and sum all of its elements. | def recursive_list_sum(data_list):
"""Write a function to flatten a list and sum all of its elements. """
total = 0
for element in data_list:
if type(element) == type([]): |
total = total + recursive_list_sum(element)
|
code_infilling | python | python | MBPP/65/L5 | [] | [] | MBPP_Infilling | total = total + element
return total | [
[
"([1, 2, [3,4],[5,6]])",
"21"
],
[
"([7, 10, [15,14],[19,41]])",
"106"
],
[
"([10, 20, [30,40],[50,60]])",
"210"
]
] | recursive_list_sum | [] | Write a function to flatten a list and sum all of its elements. | def recursive_list_sum(data_list):
"""Write a function to flatten a list and sum all of its elements. """
total = 0
for element in data_list:
if type(element) == type([]):
total = total + recursive_list_sum(element) |
else:
|
code_infilling | python | python | MBPP/65/L6 | [] | [] | MBPP_Infilling | return total | [
[
"([1, 2, [3,4],[5,6]])",
"21"
],
[
"([7, 10, [15,14],[19,41]])",
"106"
],
[
"([10, 20, [30,40],[50,60]])",
"210"
]
] | recursive_list_sum | [] | Write a function to flatten a list and sum all of its elements. | def recursive_list_sum(data_list):
"""Write a function to flatten a list and sum all of its elements. """
total = 0
for element in data_list:
if type(element) == type([]):
total = total + recursive_list_sum(element)
else: |
total = total + element
|
code_infilling | python | python | MBPP/65/L7 | [] | [] | MBPP_Infilling | [
[
"([1, 2, [3,4],[5,6]])",
"21"
],
[
"([7, 10, [15,14],[19,41]])",
"106"
],
[
"([10, 20, [30,40],[50,60]])",
"210"
]
] | recursive_list_sum | [] | Write a function to flatten a list and sum all of its elements. | def recursive_list_sum(data_list):
"""Write a function to flatten a list and sum all of its elements. """
total = 0
for element in data_list:
if type(element) == type([]):
total = total + recursive_list_sum(element)
else:
total = total + element |
return total
|
|
code_infilling | python | python | MBPP/66/L1 | [] | [] | MBPP_Infilling | for num in list:
if num >= 0:
pos_count += 1
return pos_count | [
[
"[1,-2,3,-4]",
"2"
],
[
"[3,4,5,-1]",
"3"
],
[
"[1,2,3,4]",
"4"
]
] | pos_count | [] | Write a python function to count the number of positive numbers in a list. | def pos_count(list):
"""Write a python function to count the number of positive numbers in a list. """
|
pos_count = 0
|
code_infilling | python | python | MBPP/66/L2 | [] | [] | MBPP_Infilling | if num >= 0:
pos_count += 1
return pos_count | [
[
"[1,-2,3,-4]",
"2"
],
[
"[3,4,5,-1]",
"3"
],
[
"[1,2,3,4]",
"4"
]
] | pos_count | [] | Write a python function to count the number of positive numbers in a list. | def pos_count(list):
"""Write a python function to count the number of positive numbers in a list. """
pos_count = 0 |
for num in list:
|
code_infilling | python | python | MBPP/66/L3 | [] | [] | MBPP_Infilling | pos_count += 1
return pos_count | [
[
"[1,-2,3,-4]",
"2"
],
[
"[3,4,5,-1]",
"3"
],
[
"[1,2,3,4]",
"4"
]
] | pos_count | [] | Write a python function to count the number of positive numbers in a list. | def pos_count(list):
"""Write a python function to count the number of positive numbers in a list. """
pos_count = 0
for num in list: |
if num >= 0:
|
code_infilling | python | python | MBPP/66/L4 | [] | [] | MBPP_Infilling | return pos_count | [
[
"[1,-2,3,-4]",
"2"
],
[
"[3,4,5,-1]",
"3"
],
[
"[1,2,3,4]",
"4"
]
] | pos_count | [] | Write a python function to count the number of positive numbers in a list. | def pos_count(list):
"""Write a python function to count the number of positive numbers in a list. """
pos_count = 0
for num in list:
if num >= 0: |
pos_count += 1
|
code_infilling | python | python | MBPP/66/L5 | [] | [] | MBPP_Infilling | [
[
"[1,-2,3,-4]",
"2"
],
[
"[3,4,5,-1]",
"3"
],
[
"[1,2,3,4]",
"4"
]
] | pos_count | [] | Write a python function to count the number of positive numbers in a list. | def pos_count(list):
"""Write a python function to count the number of positive numbers in a list. """
pos_count = 0
for num in list:
if num >= 0:
pos_count += 1 |
return pos_count
|
|
code_infilling | python | python | MBPP/67/L1 | [] | [] | MBPP_Infilling | bell[0][0] = 1
for i in range(1, n + 1):
bell[i][0] = bell[i - 1][i - 1]
for j in range(1, i + 1):
bell[i][j] = bell[i - 1][j - 1] + bell[i][j - 1]
return bell[n][0] | [
[
"2",
"2"
],
[
"10",
"115975"
],
[
"56",
"6775685320645824322581483068371419745979053216268760300"
]
] | bell_number | [] | Write a function to find the number of ways to partition a set of Bell numbers. | def bell_number(n):
"""Write a function to find the number of ways to partition a set of Bell numbers. """
|
bell = [[0 for i in range(n + 1)] for j in range(n + 1)]
|
code_infilling | python | python | MBPP/67/L2 | [] | [] | MBPP_Infilling | for i in range(1, n + 1):
bell[i][0] = bell[i - 1][i - 1]
for j in range(1, i + 1):
bell[i][j] = bell[i - 1][j - 1] + bell[i][j - 1]
return bell[n][0] | [
[
"2",
"2"
],
[
"10",
"115975"
],
[
"56",
"6775685320645824322581483068371419745979053216268760300"
]
] | bell_number | [] | Write a function to find the number of ways to partition a set of Bell numbers. | def bell_number(n):
"""Write a function to find the number of ways to partition a set of Bell numbers. """
bell = [[0 for i in range(n + 1)] for j in range(n + 1)] |
bell[0][0] = 1
|
code_infilling | python | python | MBPP/67/L3 | [] | [] | MBPP_Infilling | bell[i][0] = bell[i - 1][i - 1]
for j in range(1, i + 1):
bell[i][j] = bell[i - 1][j - 1] + bell[i][j - 1]
return bell[n][0] | [
[
"2",
"2"
],
[
"10",
"115975"
],
[
"56",
"6775685320645824322581483068371419745979053216268760300"
]
] | bell_number | [] | Write a function to find the number of ways to partition a set of Bell numbers. | def bell_number(n):
"""Write a function to find the number of ways to partition a set of Bell numbers. """
bell = [[0 for i in range(n + 1)] for j in range(n + 1)]
bell[0][0] = 1 |
for i in range(1, n + 1):
|
code_infilling | python | python | MBPP/67/L4 | [] | [] | MBPP_Infilling | for j in range(1, i + 1):
bell[i][j] = bell[i - 1][j - 1] + bell[i][j - 1]
return bell[n][0] | [
[
"2",
"2"
],
[
"10",
"115975"
],
[
"56",
"6775685320645824322581483068371419745979053216268760300"
]
] | bell_number | [] | Write a function to find the number of ways to partition a set of Bell numbers. | def bell_number(n):
"""Write a function to find the number of ways to partition a set of Bell numbers. """
bell = [[0 for i in range(n + 1)] for j in range(n + 1)]
bell[0][0] = 1
for i in range(1, n + 1): |
bell[i][0] = bell[i - 1][i - 1]
|
code_infilling | python | python | MBPP/67/L5 | [] | [] | MBPP_Infilling | bell[i][j] = bell[i - 1][j - 1] + bell[i][j - 1]
return bell[n][0] | [
[
"2",
"2"
],
[
"10",
"115975"
],
[
"56",
"6775685320645824322581483068371419745979053216268760300"
]
] | bell_number | [] | Write a function to find the number of ways to partition a set of Bell numbers. | def bell_number(n):
"""Write a function to find the number of ways to partition a set of Bell numbers. """
bell = [[0 for i in range(n + 1)] for j in range(n + 1)]
bell[0][0] = 1
for i in range(1, n + 1):
bell[i][0] = bell[i - 1][i - 1] |
for j in range(1, i + 1):
|
code_infilling | python | python | MBPP/67/L6 | [] | [] | MBPP_Infilling | return bell[n][0] | [
[
"2",
"2"
],
[
"10",
"115975"
],
[
"56",
"6775685320645824322581483068371419745979053216268760300"
]
] | bell_number | [] | Write a function to find the number of ways to partition a set of Bell numbers. | def bell_number(n):
"""Write a function to find the number of ways to partition a set of Bell numbers. """
bell = [[0 for i in range(n + 1)] for j in range(n + 1)]
bell[0][0] = 1
for i in range(1, n + 1):
bell[i][0] = bell[i - 1][i - 1]
for j in range(1, i + 1): |
bell[i][j] = bell[i - 1][j - 1] + bell[i][j - 1]
|
code_infilling | python | python | MBPP/67/L7 | [] | [] | MBPP_Infilling | [
[
"2",
"2"
],
[
"10",
"115975"
],
[
"56",
"6775685320645824322581483068371419745979053216268760300"
]
] | bell_number | [] | Write a function to find the number of ways to partition a set of Bell numbers. | def bell_number(n):
"""Write a function to find the number of ways to partition a set of Bell numbers. """
bell = [[0 for i in range(n + 1)] for j in range(n + 1)]
bell[0][0] = 1
for i in range(1, n + 1):
bell[i][0] = bell[i - 1][i - 1]
for j in range(1, i + 1):
bell[i][j] = bell[i - 1][j - 1] + bell[i][j - 1] |
return bell[n][0]
|
|
code_infilling | python | python | MBPP/68/L1 | [] | [] | MBPP_Infilling | [
[
"[6, 5, 4, 4]",
"True"
],
[
"[1, 2, 2, 3]",
"True"
],
[
"[1, 3, 2]",
"False"
]
] | is_Monotonic | [] | Write a python function to check whether the given array is monotonic or not. | def is_Monotonic(A):
"""Write a python function to check whether the given array is monotonic or not. """
|
return all((A[i] <= A[i + 1] for i in range(len(A) - 1))) or all((A[i] >= A[i + 1] for i in range(len(A) - 1)))
|
|
code_infilling | python | python | MBPP/69/L1 | [] | [] | MBPP_Infilling | if s == []:
sub_set = True
elif s == l:
sub_set = True
elif len(s) > len(l):
sub_set = False
else:
for i in range(len(l)):
if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
|
sub_set = False
|
code_infilling | python | python | MBPP/69/L2 | [] | [] | MBPP_Infilling | sub_set = True
elif s == l:
sub_set = True
elif len(s) > len(l):
sub_set = False
else:
for i in range(len(l)):
if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False |
if s == []:
|
code_infilling | python | python | MBPP/69/L3 | [] | [] | MBPP_Infilling | elif s == l:
sub_set = True
elif len(s) > len(l):
sub_set = False
else:
for i in range(len(l)):
if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []: |
sub_set = True
|
code_infilling | python | python | MBPP/69/L4 | [] | [] | MBPP_Infilling | sub_set = True
elif len(s) > len(l):
sub_set = False
else:
for i in range(len(l)):
if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []:
sub_set = True |
elif s == l:
|
code_infilling | python | python | MBPP/69/L5 | [] | [] | MBPP_Infilling | elif len(s) > len(l):
sub_set = False
else:
for i in range(len(l)):
if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []:
sub_set = True
elif s == l: |
sub_set = True
|
code_infilling | python | python | MBPP/69/L6 | [] | [] | MBPP_Infilling | sub_set = False
else:
for i in range(len(l)):
if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []:
sub_set = True
elif s == l:
sub_set = True |
elif len(s) > len(l):
|
code_infilling | python | python | MBPP/69/L7 | [] | [] | MBPP_Infilling | else:
for i in range(len(l)):
if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []:
sub_set = True
elif s == l:
sub_set = True
elif len(s) > len(l): |
sub_set = False
|
code_infilling | python | python | MBPP/69/L8 | [] | [] | MBPP_Infilling | for i in range(len(l)):
if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []:
sub_set = True
elif s == l:
sub_set = True
elif len(s) > len(l):
sub_set = False |
else:
|
code_infilling | python | python | MBPP/69/L9 | [] | [] | MBPP_Infilling | if l[i] == s[0]:
n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []:
sub_set = True
elif s == l:
sub_set = True
elif len(s) > len(l):
sub_set = False
else: |
for i in range(len(l)):
|
code_infilling | python | python | MBPP/69/L10 | [] | [] | MBPP_Infilling | n = 1
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []:
sub_set = True
elif s == l:
sub_set = True
elif len(s) > len(l):
sub_set = False
else:
for i in range(len(l)): |
if l[i] == s[0]:
|
code_infilling | python | python | MBPP/69/L11 | [] | [] | MBPP_Infilling | while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
return sub_set | [
[
"[2,4,3,5,7],[3,7]",
"False"
],
[
"[2,4,3,5,7],[4,3]",
"True"
],
[
"[2,4,3,5,7],[1,6]",
"False"
]
] | is_sublist | [] | Write a function to check whether a list contains the given sublist or not. | def is_sublist(l, s):
"""Write a function to check whether a list contains the given sublist or not. """
sub_set = False
if s == []:
sub_set = True
elif s == l:
sub_set = True
elif len(s) > len(l):
sub_set = False
else:
for i in range(len(l)):
if l[i] == s[0]: |
n = 1
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 160