task_name
stringclasses 1
value | src_lang
stringclasses 1
value | tgt_lang
stringclasses 1
value | data_id
stringlengths 10
12
| demos
listlengths 0
0
| compare_func
listlengths 0
0
| dataset_name
stringclasses 1
value | suffix
stringlengths 0
672
| test_cases
listlengths 0
5
| entry_func
stringlengths 3
31
| import_str
listlengths 0
1
| doc_string
stringlengths 39
252
| prefix
stringlengths 80
786
| solution
stringlengths 11
142
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code_infilling
|
python
|
python
|
MBPP/69/L12
|
[] |
[] |
MBPP_Infilling
|
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
|
while n < len(s) and l[i + n] == s[n]:
|
code_infilling
|
python
|
python
|
MBPP/69/L13
|
[] |
[] |
MBPP_Infilling
|
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
while n < len(s) and l[i + n] == s[n]:
|
n += 1
|
code_infilling
|
python
|
python
|
MBPP/69/L14
|
[] |
[] |
MBPP_Infilling
|
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
while n < len(s) and l[i + n] == s[n]:
n += 1
|
if n == len(s):
|
code_infilling
|
python
|
python
|
MBPP/69/L15
|
[] |
[] |
MBPP_Infilling
|
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
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
|
sub_set = True
|
code_infilling
|
python
|
python
|
MBPP/69/L16
|
[] |
[] |
MBPP_Infilling
|
[
[
"[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
while n < len(s) and l[i + n] == s[n]:
n += 1
if n == len(s):
sub_set = True
|
return sub_set
|
|
code_infilling
|
python
|
python
|
MBPP/70/L10
|
[] |
[] |
MBPP_Infilling
|
[
[
"[(11, 22, 33), (44, 55, 66)]",
"True"
],
[
"[(1, 2, 3), (4, 5, 6, 7)]",
"False"
],
[
"[(1, 2), (3, 4)]",
"True"
]
] |
get_equal
|
[] |
Write a function to find whether all the given tuples have equal length or not.
|
def find_equal_tuple(Input):
k = 0 if not Input else len(Input[0])
flag = 1
for tuple in Input:
if len(tuple) != k:
flag = 0
break
return flag
def get_equal(Input):
"""Write a function to find whether all the given tuples have equal length or not. """
|
return find_equal_tuple(Input) == 1
|
|
code_infilling
|
python
|
python
|
MBPP/71/L1
|
[] |
[] |
MBPP_Infilling
|
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
|
shrink_fact = 1.3
|
code_infilling
|
python
|
python
|
MBPP/71/L2
|
[] |
[] |
MBPP_Infilling
|
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
|
gaps = len(nums)
|
code_infilling
|
python
|
python
|
MBPP/71/L3
|
[] |
[] |
MBPP_Infilling
|
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
|
swapped = True
|
code_infilling
|
python
|
python
|
MBPP/71/L4
|
[] |
[] |
MBPP_Infilling
|
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
|
i = 0
|
code_infilling
|
python
|
python
|
MBPP/71/L5
|
[] |
[] |
MBPP_Infilling
|
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
|
while gaps > 1 or swapped:
|
code_infilling
|
python
|
python
|
MBPP/71/L6
|
[] |
[] |
MBPP_Infilling
|
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
|
gaps = int(float(gaps) / shrink_fact)
|
code_infilling
|
python
|
python
|
MBPP/71/L7
|
[] |
[] |
MBPP_Infilling
|
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
|
swapped = False
|
code_infilling
|
python
|
python
|
MBPP/71/L8
|
[] |
[] |
MBPP_Infilling
|
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
|
i = 0
|
code_infilling
|
python
|
python
|
MBPP/71/L9
|
[] |
[] |
MBPP_Infilling
|
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
|
while gaps + i < len(nums):
|
code_infilling
|
python
|
python
|
MBPP/71/L10
|
[] |
[] |
MBPP_Infilling
|
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
|
if nums[i] > nums[i + gaps]:
|
code_infilling
|
python
|
python
|
MBPP/71/L11
|
[] |
[] |
MBPP_Infilling
|
swapped = True
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
|
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
|
code_infilling
|
python
|
python
|
MBPP/71/L12
|
[] |
[] |
MBPP_Infilling
|
i += 1
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
|
swapped = True
|
code_infilling
|
python
|
python
|
MBPP/71/L13
|
[] |
[] |
MBPP_Infilling
|
return nums
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
|
i += 1
|
code_infilling
|
python
|
python
|
MBPP/71/L14
|
[] |
[] |
MBPP_Infilling
|
[
[
"[5, 15, 37, 25, 79]",
"[5, 15, 25, 37, 79]"
],
[
"[41, 32, 15, 19, 22]",
"[15, 19, 22, 32, 41]"
],
[
"[99, 15, 13, 47]",
"[13, 15, 47, 99]"
]
] |
comb_sort
|
[] |
Write a function to sort a list of elements.
|
def comb_sort(nums):
"""Write a function to sort a list of elements. """
shrink_fact = 1.3
gaps = len(nums)
swapped = True
i = 0
while gaps > 1 or swapped:
gaps = int(float(gaps) / shrink_fact)
swapped = False
i = 0
while gaps + i < len(nums):
if nums[i] > nums[i + gaps]:
(nums[i], nums[i + gaps]) = (nums[i + gaps], nums[i])
swapped = True
i += 1
|
return nums
|
|
code_infilling
|
python
|
python
|
MBPP/72/L1
|
[] |
[] |
MBPP_Infilling
|
return True
return False
|
[
[
"5",
"True"
],
[
"10",
"False"
],
[
"15",
"True"
]
] |
dif_Square
|
[] |
Write a python function to check whether the given number can be represented as the difference of two squares or not.
|
def dif_Square(n):
"""Write a python function to check whether the given number can be represented as the difference of two squares or not. """
|
if n % 4 != 2:
|
code_infilling
|
python
|
python
|
MBPP/72/L2
|
[] |
[] |
MBPP_Infilling
|
return False
|
[
[
"5",
"True"
],
[
"10",
"False"
],
[
"15",
"True"
]
] |
dif_Square
|
[] |
Write a python function to check whether the given number can be represented as the difference of two squares or not.
|
def dif_Square(n):
"""Write a python function to check whether the given number can be represented as the difference of two squares or not. """
if n % 4 != 2:
|
return True
|
code_infilling
|
python
|
python
|
MBPP/72/L3
|
[] |
[] |
MBPP_Infilling
|
[
[
"5",
"True"
],
[
"10",
"False"
],
[
"15",
"True"
]
] |
dif_Square
|
[] |
Write a python function to check whether the given number can be represented as the difference of two squares or not.
|
def dif_Square(n):
"""Write a python function to check whether the given number can be represented as the difference of two squares or not. """
if n % 4 != 2:
return True
|
return False
|
|
code_infilling
|
python
|
python
|
MBPP/74/L1
|
[] |
[] |
MBPP_Infilling
|
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
|
if len(colors) != len(patterns):
|
code_infilling
|
python
|
python
|
MBPP/74/L2
|
[] |
[] |
MBPP_Infilling
|
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
|
return False
|
code_infilling
|
python
|
python
|
MBPP/74/L3
|
[] |
[] |
MBPP_Infilling
|
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
|
sdict = {}
|
code_infilling
|
python
|
python
|
MBPP/74/L4
|
[] |
[] |
MBPP_Infilling
|
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
|
pset = set()
|
code_infilling
|
python
|
python
|
MBPP/74/L5
|
[] |
[] |
MBPP_Infilling
|
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
|
sset = set()
|
code_infilling
|
python
|
python
|
MBPP/74/L6
|
[] |
[] |
MBPP_Infilling
|
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
|
for i in range(len(patterns)):
|
code_infilling
|
python
|
python
|
MBPP/74/L7
|
[] |
[] |
MBPP_Infilling
|
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
|
pset.add(patterns[i])
|
code_infilling
|
python
|
python
|
MBPP/74/L8
|
[] |
[] |
MBPP_Infilling
|
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
|
sset.add(colors[i])
|
code_infilling
|
python
|
python
|
MBPP/74/L9
|
[] |
[] |
MBPP_Infilling
|
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
|
if patterns[i] not in sdict.keys():
|
code_infilling
|
python
|
python
|
MBPP/74/L10
|
[] |
[] |
MBPP_Infilling
|
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
|
sdict[patterns[i]] = []
|
code_infilling
|
python
|
python
|
MBPP/74/L11
|
[] |
[] |
MBPP_Infilling
|
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
|
keys = sdict[patterns[i]]
|
code_infilling
|
python
|
python
|
MBPP/74/L12
|
[] |
[] |
MBPP_Infilling
|
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
|
keys.append(colors[i])
|
code_infilling
|
python
|
python
|
MBPP/74/L13
|
[] |
[] |
MBPP_Infilling
|
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
|
sdict[patterns[i]] = keys
|
code_infilling
|
python
|
python
|
MBPP/74/L14
|
[] |
[] |
MBPP_Infilling
|
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
|
if len(pset) != len(sset):
|
code_infilling
|
python
|
python
|
MBPP/74/L15
|
[] |
[] |
MBPP_Infilling
|
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
|
return False
|
code_infilling
|
python
|
python
|
MBPP/74/L16
|
[] |
[] |
MBPP_Infilling
|
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
|
for values in sdict.values():
|
code_infilling
|
python
|
python
|
MBPP/74/L17
|
[] |
[] |
MBPP_Infilling
|
if values[i] != values[i + 1]:
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
|
for i in range(len(values) - 1):
|
code_infilling
|
python
|
python
|
MBPP/74/L18
|
[] |
[] |
MBPP_Infilling
|
return False
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
|
if values[i] != values[i + 1]:
|
code_infilling
|
python
|
python
|
MBPP/74/L19
|
[] |
[] |
MBPP_Infilling
|
return True
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
|
return False
|
code_infilling
|
python
|
python
|
MBPP/74/L20
|
[] |
[] |
MBPP_Infilling
|
[
[
"[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]",
"True"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]",
"False"
],
[
"[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]",
"False"
]
] |
is_samepatterns
|
[] |
Write a function to check whether it follows the sequence given in the patterns array.
|
def is_samepatterns(colors, patterns):
"""Write a function to check whether it follows the sequence given in the patterns array. """
if len(colors) != len(patterns):
return False
sdict = {}
pset = set()
sset = set()
for i in range(len(patterns)):
pset.add(patterns[i])
sset.add(colors[i])
if patterns[i] not in sdict.keys():
sdict[patterns[i]] = []
keys = sdict[patterns[i]]
keys.append(colors[i])
sdict[patterns[i]] = keys
if len(pset) != len(sset):
return False
for values in sdict.values():
for i in range(len(values) - 1):
if values[i] != values[i + 1]:
return False
|
return True
|
|
code_infilling
|
python
|
python
|
MBPP/75/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"[(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6",
"[(6, 24, 12)]"
],
[
"[(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5",
"[(5, 25, 30)]"
],
[
"[(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4",
"[(8, 16, 4)]"
]
] |
find_tuples
|
[] |
Write a function to find tuples which have all elements divisible by k from the given list of tuples.
|
def find_tuples(test_list, K):
"""Write a function to find tuples which have all elements divisible by k from the given list of tuples. """
|
res = [sub for sub in test_list if all((ele % K == 0 for ele in sub))]
|
code_infilling
|
python
|
python
|
MBPP/75/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6",
"[(6, 24, 12)]"
],
[
"[(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5",
"[(5, 25, 30)]"
],
[
"[(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4",
"[(8, 16, 4)]"
]
] |
find_tuples
|
[] |
Write a function to find tuples which have all elements divisible by k from the given list of tuples.
|
def find_tuples(test_list, K):
"""Write a function to find tuples which have all elements divisible by k from the given list of tuples. """
res = [sub for sub in test_list if all((ele % K == 0 for ele in sub))]
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/77/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"1212112",
"True"
],
[
"1212",
"False"
]
] |
is_Diff
|
[] |
Write a python function to find whether a number is divisible by 11.
|
def is_Diff(n):
"""Write a python function to find whether a number is divisible by 11. """
|
return n % 11 == 0
|
|
code_infilling
|
python
|
python
|
MBPP/79/L1
|
[] |
[] |
MBPP_Infilling
|
for word in s:
if len(word) % 2 != 0:
return True
else:
return False
|
[
[
"\"Hadoop\"",
"False"
],
[
"\"great\"",
"True"
],
[
"\"structure\"",
"True"
]
] |
word_len
|
[] |
Write a python function to check whether the length of the word is odd or not.
|
def word_len(s):
"""Write a python function to check whether the length of the word is odd or not. """
|
s = s.split(' ')
|
code_infilling
|
python
|
python
|
MBPP/79/L2
|
[] |
[] |
MBPP_Infilling
|
if len(word) % 2 != 0:
return True
else:
return False
|
[
[
"\"Hadoop\"",
"False"
],
[
"\"great\"",
"True"
],
[
"\"structure\"",
"True"
]
] |
word_len
|
[] |
Write a python function to check whether the length of the word is odd or not.
|
def word_len(s):
"""Write a python function to check whether the length of the word is odd or not. """
s = s.split(' ')
|
for word in s:
|
code_infilling
|
python
|
python
|
MBPP/79/L3
|
[] |
[] |
MBPP_Infilling
|
return True
else:
return False
|
[
[
"\"Hadoop\"",
"False"
],
[
"\"great\"",
"True"
],
[
"\"structure\"",
"True"
]
] |
word_len
|
[] |
Write a python function to check whether the length of the word is odd or not.
|
def word_len(s):
"""Write a python function to check whether the length of the word is odd or not. """
s = s.split(' ')
for word in s:
|
if len(word) % 2 != 0:
|
code_infilling
|
python
|
python
|
MBPP/79/L4
|
[] |
[] |
MBPP_Infilling
|
else:
return False
|
[
[
"\"Hadoop\"",
"False"
],
[
"\"great\"",
"True"
],
[
"\"structure\"",
"True"
]
] |
word_len
|
[] |
Write a python function to check whether the length of the word is odd or not.
|
def word_len(s):
"""Write a python function to check whether the length of the word is odd or not. """
s = s.split(' ')
for word in s:
if len(word) % 2 != 0:
|
return True
|
code_infilling
|
python
|
python
|
MBPP/79/L5
|
[] |
[] |
MBPP_Infilling
|
return False
|
[
[
"\"Hadoop\"",
"False"
],
[
"\"great\"",
"True"
],
[
"\"structure\"",
"True"
]
] |
word_len
|
[] |
Write a python function to check whether the length of the word is odd or not.
|
def word_len(s):
"""Write a python function to check whether the length of the word is odd or not. """
s = s.split(' ')
for word in s:
if len(word) % 2 != 0:
return True
|
else:
|
code_infilling
|
python
|
python
|
MBPP/79/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"Hadoop\"",
"False"
],
[
"\"great\"",
"True"
],
[
"\"structure\"",
"True"
]
] |
word_len
|
[] |
Write a python function to check whether the length of the word is odd or not.
|
def word_len(s):
"""Write a python function to check whether the length of the word is odd or not. """
s = s.split(' ')
for word in s:
if len(word) % 2 != 0:
return True
else:
|
return False
|
|
code_infilling
|
python
|
python
|
MBPP/80/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"5",
"35"
],
[
"6",
"56"
],
[
"7",
"84"
]
] |
tetrahedral_number
|
[] |
Write a function to find the nth tetrahedral number.
|
def tetrahedral_number(n):
"""Write a function to find the nth tetrahedral number. """
|
return n * (n + 1) * (n + 2) / 6
|
|
code_infilling
|
python
|
python
|
MBPP/82/L3
|
[] |
[] |
MBPP_Infilling
|
return volume
|
[] |
volume_sphere
|
[
"import math"
] |
Write a function to find the volume of a sphere.
|
import math
def volume_sphere(r):
"""Write a function to find the volume of a sphere. """
|
volume = 4 / 3 * math.pi * r * r * r
|
code_infilling
|
python
|
python
|
MBPP/82/L4
|
[] |
[] |
MBPP_Infilling
|
[] |
volume_sphere
|
[
"import math"
] |
Write a function to find the volume of a sphere.
|
import math
def volume_sphere(r):
"""Write a function to find the volume of a sphere. """
volume = 4 / 3 * math.pi * r * r * r
|
return volume
|
|
code_infilling
|
python
|
python
|
MBPP/83/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(len(strr)):
summ += ord(strr[i]) - ord('a') + 1
if summ % 26 == 0:
return ord('z')
else:
summ = summ % 26
return chr(ord('a') + summ - 1)
|
[
[
"\"abc\"",
"\"f\""
],
[
"\"gfg\"",
"\"t\""
],
[
"\"ab\"",
"\"c\""
]
] |
get_Char
|
[] |
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
|
def get_Char(strr):
"""Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
|
summ = 0
|
code_infilling
|
python
|
python
|
MBPP/83/L2
|
[] |
[] |
MBPP_Infilling
|
summ += ord(strr[i]) - ord('a') + 1
if summ % 26 == 0:
return ord('z')
else:
summ = summ % 26
return chr(ord('a') + summ - 1)
|
[
[
"\"abc\"",
"\"f\""
],
[
"\"gfg\"",
"\"t\""
],
[
"\"ab\"",
"\"c\""
]
] |
get_Char
|
[] |
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
|
def get_Char(strr):
"""Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
summ = 0
|
for i in range(len(strr)):
|
code_infilling
|
python
|
python
|
MBPP/83/L3
|
[] |
[] |
MBPP_Infilling
|
if summ % 26 == 0:
return ord('z')
else:
summ = summ % 26
return chr(ord('a') + summ - 1)
|
[
[
"\"abc\"",
"\"f\""
],
[
"\"gfg\"",
"\"t\""
],
[
"\"ab\"",
"\"c\""
]
] |
get_Char
|
[] |
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
|
def get_Char(strr):
"""Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
summ = 0
for i in range(len(strr)):
|
summ += ord(strr[i]) - ord('a') + 1
|
code_infilling
|
python
|
python
|
MBPP/83/L4
|
[] |
[] |
MBPP_Infilling
|
return ord('z')
else:
summ = summ % 26
return chr(ord('a') + summ - 1)
|
[
[
"\"abc\"",
"\"f\""
],
[
"\"gfg\"",
"\"t\""
],
[
"\"ab\"",
"\"c\""
]
] |
get_Char
|
[] |
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
|
def get_Char(strr):
"""Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
summ = 0
for i in range(len(strr)):
summ += ord(strr[i]) - ord('a') + 1
|
if summ % 26 == 0:
|
code_infilling
|
python
|
python
|
MBPP/83/L5
|
[] |
[] |
MBPP_Infilling
|
else:
summ = summ % 26
return chr(ord('a') + summ - 1)
|
[
[
"\"abc\"",
"\"f\""
],
[
"\"gfg\"",
"\"t\""
],
[
"\"ab\"",
"\"c\""
]
] |
get_Char
|
[] |
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
|
def get_Char(strr):
"""Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
summ = 0
for i in range(len(strr)):
summ += ord(strr[i]) - ord('a') + 1
if summ % 26 == 0:
|
return ord('z')
|
code_infilling
|
python
|
python
|
MBPP/83/L6
|
[] |
[] |
MBPP_Infilling
|
summ = summ % 26
return chr(ord('a') + summ - 1)
|
[
[
"\"abc\"",
"\"f\""
],
[
"\"gfg\"",
"\"t\""
],
[
"\"ab\"",
"\"c\""
]
] |
get_Char
|
[] |
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
|
def get_Char(strr):
"""Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
summ = 0
for i in range(len(strr)):
summ += ord(strr[i]) - ord('a') + 1
if summ % 26 == 0:
return ord('z')
|
else:
|
code_infilling
|
python
|
python
|
MBPP/83/L7
|
[] |
[] |
MBPP_Infilling
|
return chr(ord('a') + summ - 1)
|
[
[
"\"abc\"",
"\"f\""
],
[
"\"gfg\"",
"\"t\""
],
[
"\"ab\"",
"\"c\""
]
] |
get_Char
|
[] |
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
|
def get_Char(strr):
"""Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
summ = 0
for i in range(len(strr)):
summ += ord(strr[i]) - ord('a') + 1
if summ % 26 == 0:
return ord('z')
else:
|
summ = summ % 26
|
code_infilling
|
python
|
python
|
MBPP/83/L8
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"abc\"",
"\"f\""
],
[
"\"gfg\"",
"\"t\""
],
[
"\"ab\"",
"\"c\""
]
] |
get_Char
|
[] |
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
|
def get_Char(strr):
"""Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
summ = 0
for i in range(len(strr)):
summ += ord(strr[i]) - ord('a') + 1
if summ % 26 == 0:
return ord('z')
else:
summ = summ % 26
|
return chr(ord('a') + summ - 1)
|
|
code_infilling
|
python
|
python
|
MBPP/84/L1
|
[] |
[] |
MBPP_Infilling
|
return 1
else:
return sequence(sequence(n - 1)) + sequence(n - sequence(n - 1))
|
[
[
"10",
"6"
],
[
"2",
"1"
],
[
"3",
"2"
]
] |
sequence
|
[] |
Write a function to find the nth number in the newman conway sequence.
|
def sequence(n):
"""Write a function to find the nth number in the newman conway sequence. """
|
if n == 1 or n == 2:
|
code_infilling
|
python
|
python
|
MBPP/84/L2
|
[] |
[] |
MBPP_Infilling
|
else:
return sequence(sequence(n - 1)) + sequence(n - sequence(n - 1))
|
[
[
"10",
"6"
],
[
"2",
"1"
],
[
"3",
"2"
]
] |
sequence
|
[] |
Write a function to find the nth number in the newman conway sequence.
|
def sequence(n):
"""Write a function to find the nth number in the newman conway sequence. """
if n == 1 or n == 2:
|
return 1
|
code_infilling
|
python
|
python
|
MBPP/84/L3
|
[] |
[] |
MBPP_Infilling
|
return sequence(sequence(n - 1)) + sequence(n - sequence(n - 1))
|
[
[
"10",
"6"
],
[
"2",
"1"
],
[
"3",
"2"
]
] |
sequence
|
[] |
Write a function to find the nth number in the newman conway sequence.
|
def sequence(n):
"""Write a function to find the nth number in the newman conway sequence. """
if n == 1 or n == 2:
return 1
|
else:
|
code_infilling
|
python
|
python
|
MBPP/84/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"10",
"6"
],
[
"2",
"1"
],
[
"3",
"2"
]
] |
sequence
|
[] |
Write a function to find the nth number in the newman conway sequence.
|
def sequence(n):
"""Write a function to find the nth number in the newman conway sequence. """
if n == 1 or n == 2:
return 1
else:
|
return sequence(sequence(n - 1)) + sequence(n - sequence(n - 1))
|
|
code_infilling
|
python
|
python
|
MBPP/85/L3
|
[] |
[] |
MBPP_Infilling
|
return surfacearea
|
[] |
surfacearea_sphere
|
[
"import math"
] |
Write a function to find the surface area of a sphere.
|
import math
def surfacearea_sphere(r):
"""Write a function to find the surface area of a sphere. """
|
surfacearea = 4 * math.pi * r * r
|
code_infilling
|
python
|
python
|
MBPP/85/L4
|
[] |
[] |
MBPP_Infilling
|
[] |
surfacearea_sphere
|
[
"import math"
] |
Write a function to find the surface area of a sphere.
|
import math
def surfacearea_sphere(r):
"""Write a function to find the surface area of a sphere. """
surfacearea = 4 * math.pi * r * r
|
return surfacearea
|
|
code_infilling
|
python
|
python
|
MBPP/86/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"10",
"271"
],
[
"2",
"7"
],
[
"9",
"217"
]
] |
centered_hexagonal_number
|
[] |
Write a function to find nth centered hexagonal number.
|
def centered_hexagonal_number(n):
"""Write a function to find nth centered hexagonal number. """
|
return 3 * n * (n - 1) + 1
|
|
code_infilling
|
python
|
python
|
MBPP/87/L3
|
[] |
[] |
MBPP_Infilling
|
return merged_dict
|
[
[
"{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" }",
"{'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}"
],
[
"{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"}",
"{'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}"
],
[
"{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" }",
"{'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}"
]
] |
merge_dictionaries_three
|
[
"import collections as ct"
] |
Write a function to merge three dictionaries into a single dictionary.
|
import collections as ct
def merge_dictionaries_three(dict1, dict2, dict3):
"""Write a function to merge three dictionaries into a single dictionary. """
|
merged_dict = dict(ct.ChainMap({}, dict1, dict2, dict3))
|
code_infilling
|
python
|
python
|
MBPP/87/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" }",
"{'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}"
],
[
"{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"}",
"{'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}"
],
[
"{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" }",
"{'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}"
]
] |
merge_dictionaries_three
|
[
"import collections as ct"
] |
Write a function to merge three dictionaries into a single dictionary.
|
import collections as ct
def merge_dictionaries_three(dict1, dict2, dict3):
"""Write a function to merge three dictionaries into a single dictionary. """
merged_dict = dict(ct.ChainMap({}, dict1, dict2, dict3))
|
return merged_dict
|
|
code_infilling
|
python
|
python
|
MBPP/88/L3
|
[] |
[] |
MBPP_Infilling
|
return freq_count
|
[
[
"[10,10,10,10,20,20,20,20,40,40,50,50,30]",
"({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})"
],
[
"[1,2,3,4,3,2,4,1,3,1,4]",
"({1:3, 2:2,3:3,4:3})"
],
[
"[5,6,7,4,9,10,4,5,6,7,9,5]",
"({10:1,5:3,6:2,7:2,4:2,9:2})"
]
] |
freq_count
|
[
"import collections"
] |
Write a function to get the frequency of all the elements in a list, returned as a dictionary.
|
import collections
def freq_count(list1):
"""Write a function to get the frequency of all the elements in a list, returned as a dictionary. """
|
freq_count = collections.Counter(list1)
|
code_infilling
|
python
|
python
|
MBPP/88/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"[10,10,10,10,20,20,20,20,40,40,50,50,30]",
"({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})"
],
[
"[1,2,3,4,3,2,4,1,3,1,4]",
"({1:3, 2:2,3:3,4:3})"
],
[
"[5,6,7,4,9,10,4,5,6,7,9,5]",
"({10:1,5:3,6:2,7:2,4:2,9:2})"
]
] |
freq_count
|
[
"import collections"
] |
Write a function to get the frequency of all the elements in a list, returned as a dictionary.
|
import collections
def freq_count(list1):
"""Write a function to get the frequency of all the elements in a list, returned as a dictionary. """
freq_count = collections.Counter(list1)
|
return freq_count
|
|
code_infilling
|
python
|
python
|
MBPP/89/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"11",
"10"
],
[
"7",
"6"
],
[
"12",
"11"
]
] |
closest_num
|
[] |
Write a function to find the closest smaller number than n.
|
def closest_num(N):
"""Write a function to find the closest smaller number than n. """
|
return N - 1
|
|
code_infilling
|
python
|
python
|
MBPP/90/L1
|
[] |
[] |
MBPP_Infilling
|
for i in list1:
if len(i) > max:
max = len(i)
return max
|
[
[
"[\"python\",\"PHP\",\"bigdata\"]",
"7"
],
[
"[\"a\",\"ab\",\"abc\"]",
"3"
],
[
"[\"small\",\"big\",\"tall\"]",
"5"
]
] |
len_log
|
[] |
Write a python function to find the length of the longest word.
|
def len_log(list1):
"""Write a python function to find the length of the longest word. """
|
max = len(list1[0])
|
code_infilling
|
python
|
python
|
MBPP/90/L2
|
[] |
[] |
MBPP_Infilling
|
if len(i) > max:
max = len(i)
return max
|
[
[
"[\"python\",\"PHP\",\"bigdata\"]",
"7"
],
[
"[\"a\",\"ab\",\"abc\"]",
"3"
],
[
"[\"small\",\"big\",\"tall\"]",
"5"
]
] |
len_log
|
[] |
Write a python function to find the length of the longest word.
|
def len_log(list1):
"""Write a python function to find the length of the longest word. """
max = len(list1[0])
|
for i in list1:
|
code_infilling
|
python
|
python
|
MBPP/90/L3
|
[] |
[] |
MBPP_Infilling
|
max = len(i)
return max
|
[
[
"[\"python\",\"PHP\",\"bigdata\"]",
"7"
],
[
"[\"a\",\"ab\",\"abc\"]",
"3"
],
[
"[\"small\",\"big\",\"tall\"]",
"5"
]
] |
len_log
|
[] |
Write a python function to find the length of the longest word.
|
def len_log(list1):
"""Write a python function to find the length of the longest word. """
max = len(list1[0])
for i in list1:
|
if len(i) > max:
|
code_infilling
|
python
|
python
|
MBPP/90/L4
|
[] |
[] |
MBPP_Infilling
|
return max
|
[
[
"[\"python\",\"PHP\",\"bigdata\"]",
"7"
],
[
"[\"a\",\"ab\",\"abc\"]",
"3"
],
[
"[\"small\",\"big\",\"tall\"]",
"5"
]
] |
len_log
|
[] |
Write a python function to find the length of the longest word.
|
def len_log(list1):
"""Write a python function to find the length of the longest word. """
max = len(list1[0])
for i in list1:
if len(i) > max:
|
max = len(i)
|
code_infilling
|
python
|
python
|
MBPP/90/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"[\"python\",\"PHP\",\"bigdata\"]",
"7"
],
[
"[\"a\",\"ab\",\"abc\"]",
"3"
],
[
"[\"small\",\"big\",\"tall\"]",
"5"
]
] |
len_log
|
[] |
Write a python function to find the length of the longest word.
|
def len_log(list1):
"""Write a python function to find the length of the longest word. """
max = len(list1[0])
for i in list1:
if len(i) > max:
max = len(i)
|
return max
|
|
code_infilling
|
python
|
python
|
MBPP/91/L1
|
[] |
[] |
MBPP_Infilling
|
return True
return False
|
[
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\"",
"True"
],
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\"",
"False"
],
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\"",
"True"
]
] |
find_substring
|
[] |
Write a function to check if a string is present as a substring in a given list of string values.
|
def find_substring(str1, sub_str):
"""Write a function to check if a string is present as a substring in a given list of string values. """
|
if any((sub_str in s for s in str1)):
|
code_infilling
|
python
|
python
|
MBPP/91/L2
|
[] |
[] |
MBPP_Infilling
|
return False
|
[
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\"",
"True"
],
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\"",
"False"
],
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\"",
"True"
]
] |
find_substring
|
[] |
Write a function to check if a string is present as a substring in a given list of string values.
|
def find_substring(str1, sub_str):
"""Write a function to check if a string is present as a substring in a given list of string values. """
if any((sub_str in s for s in str1)):
|
return True
|
code_infilling
|
python
|
python
|
MBPP/91/L3
|
[] |
[] |
MBPP_Infilling
|
[
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\"",
"True"
],
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\"",
"False"
],
[
"[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\"",
"True"
]
] |
find_substring
|
[] |
Write a function to check if a string is present as a substring in a given list of string values.
|
def find_substring(str1, sub_str):
"""Write a function to check if a string is present as a substring in a given list of string values. """
if any((sub_str in s for s in str1)):
return True
|
return False
|
|
code_infilling
|
python
|
python
|
MBPP/92/L1
|
[] |
[] |
MBPP_Infilling
|
if len(n) <= 2:
return False
for i in range(2, len(n)):
if n[i - 2] != n[i]:
return False
return True
|
[
[
"1212121",
"True"
],
[
"1991",
"False"
],
[
"121",
"True"
]
] |
is_undulating
|
[] |
Write a function to check whether the given number is undulating or not.
|
def is_undulating(n):
"""Write a function to check whether the given number is undulating or not. """
|
n = str(n)
|
code_infilling
|
python
|
python
|
MBPP/92/L2
|
[] |
[] |
MBPP_Infilling
|
return False
for i in range(2, len(n)):
if n[i - 2] != n[i]:
return False
return True
|
[
[
"1212121",
"True"
],
[
"1991",
"False"
],
[
"121",
"True"
]
] |
is_undulating
|
[] |
Write a function to check whether the given number is undulating or not.
|
def is_undulating(n):
"""Write a function to check whether the given number is undulating or not. """
n = str(n)
|
if len(n) <= 2:
|
code_infilling
|
python
|
python
|
MBPP/92/L3
|
[] |
[] |
MBPP_Infilling
|
for i in range(2, len(n)):
if n[i - 2] != n[i]:
return False
return True
|
[
[
"1212121",
"True"
],
[
"1991",
"False"
],
[
"121",
"True"
]
] |
is_undulating
|
[] |
Write a function to check whether the given number is undulating or not.
|
def is_undulating(n):
"""Write a function to check whether the given number is undulating or not. """
n = str(n)
if len(n) <= 2:
|
return False
|
code_infilling
|
python
|
python
|
MBPP/92/L4
|
[] |
[] |
MBPP_Infilling
|
if n[i - 2] != n[i]:
return False
return True
|
[
[
"1212121",
"True"
],
[
"1991",
"False"
],
[
"121",
"True"
]
] |
is_undulating
|
[] |
Write a function to check whether the given number is undulating or not.
|
def is_undulating(n):
"""Write a function to check whether the given number is undulating or not. """
n = str(n)
if len(n) <= 2:
return False
|
for i in range(2, len(n)):
|
code_infilling
|
python
|
python
|
MBPP/92/L5
|
[] |
[] |
MBPP_Infilling
|
return False
return True
|
[
[
"1212121",
"True"
],
[
"1991",
"False"
],
[
"121",
"True"
]
] |
is_undulating
|
[] |
Write a function to check whether the given number is undulating or not.
|
def is_undulating(n):
"""Write a function to check whether the given number is undulating or not. """
n = str(n)
if len(n) <= 2:
return False
for i in range(2, len(n)):
|
if n[i - 2] != n[i]:
|
code_infilling
|
python
|
python
|
MBPP/92/L6
|
[] |
[] |
MBPP_Infilling
|
return True
|
[
[
"1212121",
"True"
],
[
"1991",
"False"
],
[
"121",
"True"
]
] |
is_undulating
|
[] |
Write a function to check whether the given number is undulating or not.
|
def is_undulating(n):
"""Write a function to check whether the given number is undulating or not. """
n = str(n)
if len(n) <= 2:
return False
for i in range(2, len(n)):
if n[i - 2] != n[i]:
|
return False
|
code_infilling
|
python
|
python
|
MBPP/92/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"1212121",
"True"
],
[
"1991",
"False"
],
[
"121",
"True"
]
] |
is_undulating
|
[] |
Write a function to check whether the given number is undulating or not.
|
def is_undulating(n):
"""Write a function to check whether the given number is undulating or not. """
n = str(n)
if len(n) <= 2:
return False
for i in range(2, len(n)):
if n[i - 2] != n[i]:
return False
|
return True
|
|
code_infilling
|
python
|
python
|
MBPP/93/L1
|
[] |
[] |
MBPP_Infilling
|
return 1
elif a == 0:
return 0
elif b == 1:
return a
else:
return a * power(a, b - 1)
|
[
[
"3,4",
"81"
],
[
"2,3",
"8"
],
[
"5,5",
"3125"
]
] |
power
|
[] |
Write a function to calculate the value of 'a' to the power 'b'.
|
def power(a, b):
"""Write a function to calculate the value of 'a' to the power 'b'. """
|
if b == 0:
|
code_infilling
|
python
|
python
|
MBPP/93/L2
|
[] |
[] |
MBPP_Infilling
|
elif a == 0:
return 0
elif b == 1:
return a
else:
return a * power(a, b - 1)
|
[
[
"3,4",
"81"
],
[
"2,3",
"8"
],
[
"5,5",
"3125"
]
] |
power
|
[] |
Write a function to calculate the value of 'a' to the power 'b'.
|
def power(a, b):
"""Write a function to calculate the value of 'a' to the power 'b'. """
if b == 0:
|
return 1
|
code_infilling
|
python
|
python
|
MBPP/93/L3
|
[] |
[] |
MBPP_Infilling
|
return 0
elif b == 1:
return a
else:
return a * power(a, b - 1)
|
[
[
"3,4",
"81"
],
[
"2,3",
"8"
],
[
"5,5",
"3125"
]
] |
power
|
[] |
Write a function to calculate the value of 'a' to the power 'b'.
|
def power(a, b):
"""Write a function to calculate the value of 'a' to the power 'b'. """
if b == 0:
return 1
|
elif a == 0:
|
code_infilling
|
python
|
python
|
MBPP/93/L4
|
[] |
[] |
MBPP_Infilling
|
elif b == 1:
return a
else:
return a * power(a, b - 1)
|
[
[
"3,4",
"81"
],
[
"2,3",
"8"
],
[
"5,5",
"3125"
]
] |
power
|
[] |
Write a function to calculate the value of 'a' to the power 'b'.
|
def power(a, b):
"""Write a function to calculate the value of 'a' to the power 'b'. """
if b == 0:
return 1
elif a == 0:
|
return 0
|
code_infilling
|
python
|
python
|
MBPP/93/L5
|
[] |
[] |
MBPP_Infilling
|
return a
else:
return a * power(a, b - 1)
|
[
[
"3,4",
"81"
],
[
"2,3",
"8"
],
[
"5,5",
"3125"
]
] |
power
|
[] |
Write a function to calculate the value of 'a' to the power 'b'.
|
def power(a, b):
"""Write a function to calculate the value of 'a' to the power 'b'. """
if b == 0:
return 1
elif a == 0:
return 0
|
elif b == 1:
|
code_infilling
|
python
|
python
|
MBPP/93/L6
|
[] |
[] |
MBPP_Infilling
|
else:
return a * power(a, b - 1)
|
[
[
"3,4",
"81"
],
[
"2,3",
"8"
],
[
"5,5",
"3125"
]
] |
power
|
[] |
Write a function to calculate the value of 'a' to the power 'b'.
|
def power(a, b):
"""Write a function to calculate the value of 'a' to the power 'b'. """
if b == 0:
return 1
elif a == 0:
return 0
elif b == 1:
|
return a
|
code_infilling
|
python
|
python
|
MBPP/93/L7
|
[] |
[] |
MBPP_Infilling
|
return a * power(a, b - 1)
|
[
[
"3,4",
"81"
],
[
"2,3",
"8"
],
[
"5,5",
"3125"
]
] |
power
|
[] |
Write a function to calculate the value of 'a' to the power 'b'.
|
def power(a, b):
"""Write a function to calculate the value of 'a' to the power 'b'. """
if b == 0:
return 1
elif a == 0:
return 0
elif b == 1:
return a
|
else:
|
code_infilling
|
python
|
python
|
MBPP/93/L8
|
[] |
[] |
MBPP_Infilling
|
[
[
"3,4",
"81"
],
[
"2,3",
"8"
],
[
"5,5",
"3125"
]
] |
power
|
[] |
Write a function to calculate the value of 'a' to the power 'b'.
|
def power(a, b):
"""Write a function to calculate the value of 'a' to the power 'b'. """
if b == 0:
return 1
elif a == 0:
return 0
elif b == 1:
return a
else:
|
return a * power(a, b - 1)
|
|
code_infilling
|
python
|
python
|
MBPP/94/L3
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"[('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]",
"'Varsha'"
],
[
"[('Yash', 185), ('Dawood', 125), ('Sanya', 175)]",
"'Dawood'"
],
[
"[('Sai', 345), ('Salman', 145), ('Ayesha', 96)]",
"'Ayesha'"
]
] |
index_minimum
|
[
"from operator import itemgetter "
] |
Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value.
|
from operator import itemgetter
def index_minimum(test_list):
"""Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value. """
|
res = min(test_list, key=itemgetter(1))[0]
|
code_infilling
|
python
|
python
|
MBPP/94/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"[('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]",
"'Varsha'"
],
[
"[('Yash', 185), ('Dawood', 125), ('Sanya', 175)]",
"'Dawood'"
],
[
"[('Sai', 345), ('Salman', 145), ('Ayesha', 96)]",
"'Ayesha'"
]
] |
index_minimum
|
[
"from operator import itemgetter "
] |
Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value.
|
from operator import itemgetter
def index_minimum(test_list):
"""Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value. """
res = min(test_list, key=itemgetter(1))[0]
|
return res
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.