task
stringlengths 120
1.39k
| edge_weight
listlengths 5
5
| mask
listlengths 5
5
|
---|---|---|
from typing import List
def minSubArraySum(nums: List[int]) -> int:
"""
Given an array of integers nums, find the minimum sum of any non-empty sub-array
of nums.
Example
>>> minSubArraySum([2, 3, 4, 1, 2, 4])
1
>>> minSubArraySum([-1, -2, -3])
-6
"""
|
[
[
0,
0.7310585975646973,
0.5875941514968872,
0.6013243794441223,
0.40593743324279785
],
[
0,
0,
0.5875941514968872,
0.6013243794441223,
0.40593743324279785
],
[
0,
0,
0,
0.4799574613571167,
0.3391767144203186
],
[
0,
0,
0.4799574613571167,
0,
0.34446826577186584
],
[
0,
0,
0,
0.34446826577186584,
0
]
] |
[
0,
0,
0,
0,
1
] |
def string_sequence(n: int) -> str:
""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> string_sequence(0)
'0'
>>> string_sequence(5)
'0 1 2 3 4 5'
"""
|
[
[
0,
0.7310585975646973,
0.5544677376747131,
0.5784009695053101,
0.38129737973213196
],
[
0,
0,
0.5544677376747131,
0.5784009695053101,
0.38129737973213196
],
[
0,
0,
0,
0.44356128573417664,
0.3204496204853058
],
[
0,
0,
0,
0,
0.32736876606941223
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
def cycpattern_check(a: str, b: str) -> bool:
"""You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word
>>> cycpattern_check('abcd', 'abd')
False
>>> cycpattern_check('hello', 'ell')
True
>>> cycpattern_check('whassup', 'psus')
False
>>> cycpattern_check('abab', 'baa')
True
>>> cycpattern_check('efef', 'eeff')
False
>>> cycpattern_check('himenss', 'simen')
True
"""
|
[
[
0,
0.7310585975646973,
0.524544358253479,
0.5439658164978027,
0.3554048538208008
],
[
0,
0,
0.524544358253479,
0.5439658164978027,
0.3554048538208008
],
[
0,
0,
0,
0.40800559520721436,
0.30587515234947205
],
[
0,
0,
0,
0,
0.30955970287323
],
[
0,
0,
0,
0.30955970287323,
0
]
] |
[
0,
0,
0,
1,
1
] |
from typing import List
def monotonic(l: List[int]) -> bool:
"""Return True is list elements are monotonically increasing or decreasing.
>>> monotonic([1, 2, 4, 20])
True
>>> monotonic([1, 20, 4, 10])
False
>>> monotonic([4, 1, 0, -10])
True
"""
|
[
[
0,
0.7310585975646973,
0.5941867828369141,
0.6049485802650452,
0.4101172983646393
],
[
0,
0,
0.5941867828369141,
0.6049485802650452,
0.4101172983646393
],
[
0,
0,
0,
0.48733100295066833,
0.34333890676498413
],
[
0,
0,
0,
0,
0.3475668728351593
],
[
0,
0.4101172983646393,
0.34333890676498413,
0.3475668728351593,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List, Optional
def longest(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return the longest one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> longest([])
None
>>> longest(['a', 'b', 'c'])
'a'
>>> longest(['a', 'bb', 'ccc'])
'ccc'
"""
|
[
[
0,
0.7310585975646973,
0.5702484846115112,
0.589824914932251,
0.39353758096694946
],
[
0,
0,
0.5702484846115112,
0.589824914932251,
0.39353758096694946
],
[
0,
0.5702484846115112,
0,
0.46065405011177063,
0.32912176847457886
],
[
0,
0.589824914932251,
0,
0,
0.3356281816959381
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def below_threshold(l: List[int], t: int) -> bool:
"""Return True if all numbers in the list l are below threshold t.
>>> below_threshold([1, 2, 4, 10], 100)
True
>>> below_threshold([1, 20, 4, 10], 5)
False
"""
|
[
[
0,
0.7310585975646973,
0.6029645204544067,
0.6098162531852722,
0.4154316186904907
],
[
0.7310585975646973,
0,
0.6029645204544067,
0.6098162531852722,
0.4154316186904907
],
[
0.6029645204544067,
0.6029645204544067,
0,
0.4973791539669037,
0.34895601868629456
],
[
0.6098162531852722,
0,
0,
0,
0.35168156027793884
],
[
0.4154316186904907,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
def is_multiply_prime(a: int) -> bool:
"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
>>> is_multiply_prime(30)
True
30 = 2 * 3 * 5
"""
|
[
[
0,
0.7310585975646973,
0.5792518258094788,
0.5966177582740784,
0.40071916580200195
],
[
0,
0,
0.5792518258094788,
0.5966177582740784,
0.40071916580200195
],
[
0,
0,
0,
0.47075730562210083,
0.33417052030563354
],
[
0,
0,
0.47075730562210083,
0,
0.3406223654747009
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def get_positive(l: List[int]) -> List[int]:
"""Return only positive numbers in the list.
>>> get_positive([-1, 2, -4, 5, 6])
[2, 5, 6]
>>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[5, 3, 2, 3, 9, 123, 1]
"""
|
[
[
0,
0.7310585975646973,
0.5916268229484558,
0.603606641292572,
0.4079589247703552
],
[
0,
0,
0.5916268229484558,
0.603606641292572,
0.4079589247703552
],
[
0,
0,
0,
0.4846826493740082,
0.3416286110877991
],
[
0,
0,
0.4846826493740082,
0,
0.3462298512458801
],
[
0,
0,
0.3416286110877991,
0,
0
]
] |
[
0,
0,
1,
0,
0
] |
from typing import List
def sort_third(l: List[int]) -> List[int]:
"""This function takes a list l and returns a list l' such that
l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
to the values of the corresponding indicies of l, but sorted.
>>> sort_third([1, 2, 3])
[1, 2, 3]
>>> sort_third([5, 6, 3, 4, 8, 9, 2])
[2, 6, 3, 4, 8, 9, 5]
"""
|
[
[
0,
0.7310585975646973,
0.5970510840415955,
0.6065890789031982,
0.41184714436531067
],
[
0.7310585975646973,
0,
0.5970510840415955,
0.6065890789031982,
0.41184714436531067
],
[
0,
0,
0,
0.49057528376579285,
0.34508630633354187
],
[
0.6065890789031982,
0.6065890789031982,
0.49057528376579285,
0,
0.34889546036720276
],
[
0.41184714436531067,
0.41184714436531067,
0.34508630633354187,
0.34889546036720276,
0
]
] |
[
0,
0,
1,
0,
1
] |
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
|
[
[
0,
0.7310585975646973,
0.5608347058296204,
0.5826389193534851,
0.3864946663379669
],
[
0,
0,
0.5608347058296204,
0.5826389193534851,
0.3864946663379669
],
[
0,
0.5608347058296204,
0,
0.4500073194503784,
0.32390597462654114
],
[
0,
0,
0,
0,
0.3305991590023041
],
[
0,
0.3864946663379669,
0.32390597462654114,
0.3305991590023041,
0
]
] |
[
0,
0,
0,
0,
0
] |
def triangle_area(a: int, h: int) -> float:
"""Given length of a side and high return area for a triangle.
>>> triangle_area(5, 3)
7.5
"""
|
[
[
0,
0.7310585975646973,
0.5731227397918701,
0.5931751132011414,
0.3960677981376648
],
[
0,
0,
0.5731227397918701,
0.5931751132011414,
0.3960677981376648
],
[
0,
0.5731227397918701,
0,
0.46445339918136597,
0.33056533336639404
],
[
0,
0.5931751132011414,
0.46445339918136597,
0,
0.33763837814331055
],
[
0.3960677981376648,
0.3960677981376648,
0.33056533336639404,
0.33763837814331055,
0
]
] |
[
0,
0,
0,
0,
0
] |
def multiply(a: int, b: int) -> int:
"""Complete the function that takes two integers and returns
the product of their unit digits.
Assume the input is always valid.
Examples:
>>> multiply(148, 412)
16
>>> multiply(19, 28)
72
>>> multiply(2020, 1851)
0
>>> multiply(14, -15)
20
"""
|
[
[
0,
0.7310585975646973,
0.5662944316864014,
0.5890575051307678,
0.3909284770488739
],
[
0,
0,
0.5662944316864014,
0.5890575051307678,
0.3909284770488739
],
[
0,
0.5662944316864014,
0,
0.4574238955974579,
0.3267609477043152
],
[
0,
0.5890575051307678,
0.4574238955974579,
0,
0.33430764079093933
],
[
0,
0,
0.3267609477043152,
0,
0
]
] |
[
0,
0,
1,
0,
1
] |
from typing import List
def mean_absolute_deviation(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation
around the mean of this dataset.
Mean Absolute Deviation is the average absolute difference between each
element and a centerpoint (mean in this case):
MAD = average | x - x_mean |
>>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
1.0
"""
|
[
[
0,
0.7310585975646973,
0.5682945847511292,
0.5903767347335815,
0.39117932319641113
],
[
0,
0,
0.5682945847511292,
0.5903767347335815,
0.39117932319641113
],
[
0,
0,
0,
0.45997437834739685,
0.3276989459991455
],
[
0,
0,
0.45997437834739685,
0,
0.3349228501319885
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def common(l1: List[int], l2: List[int]) -> List[int]:
"""Return sorted unique common elements for two lists.
>>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[1, 5, 653]
>>> common([5, 3, 2, 8], [3, 2])
[2, 3]
"""
|
[
[
0,
0.7310585975646973,
0.5865746736526489,
0.6006739139556885,
0.4050981402397156
],
[
0,
0,
0.5865746736526489,
0.6006739139556885,
0.4050981402397156
],
[
0,
0.5865746736526489,
0,
0.4789412319660187,
0.33864626288414
],
[
0,
0,
0,
0,
0.34395691752433777
],
[
0,
0.4050981402397156,
0,
0.34395691752433777,
0
]
] |
[
0,
0,
0,
0,
0
] |
def int_to_mini_roman(number: int) -> str:
"""
Given a positive integer, obtain its roman numeral equivalent as a string,
and return it in lowercase.
Restrictions: 1 <= num <= 1000
Examples:
>>> int_to_mini_roman(19)
'xix'
>>> int_to_mini_roman(152)
'clii'
>>> int_to_mini_roman(426)
'cdxxvi'
"""
|
[
[
0,
0.7310585975646973,
0.5569887161254883,
0.5806887745857239,
0.383448988199234
],
[
0,
0,
0.5569887161254883,
0.5806887745857239,
0.383448988199234
],
[
0,
0,
0,
0.4464638829231262,
0.3218057155609131
],
[
0,
0,
0,
0,
0.3288609981536865
],
[
0,
0.383448988199234,
0.3218057155609131,
0.3288609981536865,
0
]
] |
[
0,
0,
0,
0,
0
] |
def fruit_distribution(s: str, n: int) -> int:
"""
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples and an integer that represent the total number of the fruits
in the basket return the number of the mango fruits in the basket.
for examble:
>>> fruit_distribution('5 apples and 6 oranges', 19)
8
>>> fruit_distribution('0 apples and 1 oranges', 3)
2
>>> fruit_distribution('2 apples and 3 oranges', 100)
95
>>> fruit_distribution('100 apples and 1 oranges', 120)
19
"""
|
[
[
0,
0.7310585975646973,
0.5697717666625977,
0.5912087559700012,
0.39390209317207336
],
[
0,
0,
0.5697717666625977,
0.5912087559700012,
0.39390209317207336
],
[
0,
0.5697717666625977,
0,
0.4609171748161316,
0.32873934507369995
],
[
0,
0.5912087559700012,
0,
0,
0.3361271917819977
],
[
0,
0.39390209317207336,
0,
0.3361271917819977,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import Tuple
def reverse_delete(s: str, c: str) -> Tuple[str, bool]:
"""Task
We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
then check if the result string is palindrome.
A string is called palindrome if it reads the same backward as forward.
You should return a tuple containing the result string and True/False for the check.
Example
>>> reverse_delete('abcde', 'ae')
('bcd', False)
>>> reverse_delete('abcdef', 'b')
('acdef', False)
>>> reverse_delete('abcdedcba', 'ab')
('cdedc', True)
"""
|
[
[
0,
0.7310585975646973,
0.5349796414375305,
0.5570492744445801,
0.3643527030944824
],
[
0.7310585975646973,
0,
0.5349796414375305,
0.5570492744445801,
0.3643527030944824
],
[
0,
0,
0,
0.42042675614356995,
0.3106847405433655
],
[
0,
0,
0,
0,
0.3156000077724457
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
def greatest_common_divisor(a: int, b: int) -> int:
""" Return a greatest common divisor of two integers a and b
>>> greatest_common_divisor(3, 5)
1
>>> greatest_common_divisor(25, 15)
5
"""
|
[
[
0,
0.7310585975646973,
0.5667778253555298,
0.5892614126205444,
0.391705185174942
],
[
0,
0,
0.5667778253555298,
0.5892614126205444,
0.391705185174942
],
[
0,
0.5667778253555298,
0,
0.45778200030326843,
0.3271450400352478
],
[
0,
0,
0,
0,
0.3346642851829529
],
[
0,
0.391705185174942,
0,
0.3346642851829529,
0
]
] |
[
0,
0,
0,
0,
1
] |
from typing import Union, List
def split_words(txt: str) -> Union[List[str], int]:
"""
Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
Examples
>>> split_words('Hello world!')
['Hello', 'world!']
>>> split_words('Hello,world!')
['Hello', 'world!']
>>> split_words('abcdef')
3
"""
|
[
[
0,
0.7310585975646973,
0.543624222278595,
0.5645914077758789,
0.3716192841529846
],
[
0,
0,
0.543624222278595,
0.5645914077758789,
0.3716192841529846
],
[
0.543624222278595,
0.543624222278595,
0,
0.4293690621852875,
0.31491875648498535
],
[
0,
0,
0,
0,
0.32006481289863586
],
[
0.3716192841529846,
0.3716192841529846,
0.31491875648498535,
0.32006481289863586,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def concatenate(strings: List[str]) -> str:
""" Concatenate list of strings into a single string
>>> concatenate([])
''
>>> concatenate(['a', 'b', 'c'])
'abc'
"""
|
[
[
0,
0.7310585975646973,
0.5726167559623718,
0.59074866771698,
0.3953326642513275
],
[
0,
0,
0.5726167559623718,
0.59074866771698,
0.3953326642513275
],
[
0,
0,
0,
0.46275195479393005,
0.33048075437545776
],
[
0.59074866771698,
0.59074866771698,
0.46275195479393005,
0,
0.3366077244281769
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
1
] |
from typing import List
def sorted_list_sum(lst: List[str]) -> List[str]:
"""Write a function that accepts a list of strings as a parameter,
deletes the strings that have odd lengths from it,
and returns the resulted list with a sorted order,
The list is always a list of strings and never an array of numbers,
and it may contain duplicates.
The order of the list should be ascending by length of each word, and you
should return the list sorted by that rule.
If two words have the same length, sort the list alphabetically.
The function should return a list of strings in sorted order.
You may assume that all words will have the same length.
For example:
>>> list_sort(['aa', 'a', 'aaa'])
['aa']
>>> list_sort(['ab', 'a', 'aaa', 'cd'])
['ab', 'cd']
"""
|
[
[
0,
0.7310585975646973,
0.5687716007232666,
0.5905916690826416,
0.39146921038627625
],
[
0.7310585975646973,
0,
0.5687716007232666,
0.5905916690826416,
0.39146921038627625
],
[
0,
0,
0,
0.4605376720428467,
0.32806146144866943
],
[
0,
0,
0.4605376720428467,
0,
0.3351554870605469
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def filter_by_substring(strings: List[str], substring: str) -> List[str]:
""" Filter an input list of strings only for ones that contain given substring
>>> filter_by_substring([], 'a')
[]
>>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
['abc', 'bacd', 'array']
"""
|
[
[
0,
0.7310585975646973,
0.5931605100631714,
0.6041834950447083,
0.4095112085342407
],
[
0,
0,
0.5931605100631714,
0.6041834950447083,
0.4095112085342407
],
[
0,
0.5931605100631714,
0,
0.48614612221717834,
0.3428475856781006
],
[
0.6041834950447083,
0.6041834950447083,
0.48614612221717834,
0,
0.3470761179924011
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
1,
0
] |
def closest_integer(value: str) -> int:
"""
Create a function that takes a value (string) representing a number
and returns the closest integer to it. If the number is equidistant
from two integers, round it away from zero.
Examples
>>> closest_integer('10')
10
>>> closest_integer('15.3')
15
Note:
Rounding away from zero means that if the given number is equidistant
from two integers, the one you should return is the one that is the
farthest from zero. For example closest_integer("14.5") should
return 15 and closest_integer("-14.5") should return -15.
"""
|
[
[
0,
0.7310585975646973,
0.5862987041473389,
0.6006050705909729,
0.40517234802246094
],
[
0,
0,
0.5862987041473389,
0.6006050705909729,
0.40517234802246094
],
[
0,
0,
0,
0.478493332862854,
0.3383750915527344
],
[
0,
0,
0,
0,
0.34387561678886414
],
[
0,
0,
0,
0.34387561678886414,
0
]
] |
[
0,
0,
0,
1,
0
] |
def vowels_count(s: str) -> int:
"""Write a function vowels_count which takes a string representing
a word as input and returns the number of vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the given word.
Example:
>>> vowels_count('abcde')
2
>>> vowels_count('ACEDY')
3
"""
|
[
[
0,
0.7310585975646973,
0.5308277606964111,
0.5543600916862488,
0.3610185980796814
],
[
0.7310585975646973,
0,
0.5308277606964111,
0.5543600916862488,
0.3610185980796814
],
[
0,
0.5308277606964111,
0,
0.4166736900806427,
0.30870604515075684
],
[
0,
0,
0,
0,
0.3137601613998413
],
[
0.3610185980796814,
0.3610185980796814,
0.30870604515075684,
0.3137601613998413,
0
]
] |
[
0,
1,
0,
0,
1
] |
from typing import List
def find_max(words: List[str]) -> str:
"""Write a function that accepts a list of strings.
The list contains different words. Return the word with maximum number
of unique characters. If multiple strings have maximum number of unique
characters, return the one which comes first in lexicographical order.
>>> find_max(['name', 'of', 'string'])
'string'
>>> find_max(['name', 'enam', 'game'])
'enam'
>>> find_max(['aaaaaaa', 'bb', 'cc'])
'aaaaaaa'
"""
|
[
[
0,
0.7310585975646973,
0.5448366403579712,
0.5655277967453003,
0.3733059763908386
],
[
0.7310585975646973,
0,
0.5448366403579712,
0.5655277967453003,
0.3733059763908386
],
[
0,
0,
0,
0.43025875091552734,
0.31559064984321594
],
[
0,
0,
0,
0,
0.3208366334438324
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import Optional
def string_to_md5(text: str) -> Optional[str]:
"""
Given a string 'text', return its md5 hash equivalent string.
If 'text' is an empty string, return None.
>>> string_to_md5('Hello world')
'3e25960a79dbc69b674cd4ec67a72c62'
"""
|
[
[
0,
0.7310585975646973,
0.5512144565582275,
0.5718113780021667,
0.3785777688026428
],
[
0,
0,
0.5512144565582275,
0.5718113780021667,
0.3785777688026428
],
[
0.5512144565582275,
0.5512144565582275,
0,
0.43757757544517517,
0.3188186287879944
],
[
0,
0.5718113780021667,
0.43757757544517517,
0,
0.32444310188293457
],
[
0.3785777688026428,
0.3785777688026428,
0.3188186287879944,
0.32444310188293457,
0
]
] |
[
0,
0,
0,
0,
0
] |
def change_base(x: int, base: int) -> str:
"""Change numerical base of input number x to base.
return string representation after the conversion.
base numbers are less than 10.
>>> change_base(8, 3)
'22'
>>> change_base(8, 2)
'1000'
>>> change_base(7, 2)
'111'
"""
|
[
[
0,
0.7310585975646973,
0.5414096117019653,
0.5675823092460632,
0.37010884284973145
],
[
0,
0,
0.5414096117019653,
0.5675823092460632,
0.37010884284973145
],
[
0.5414096117019653,
0.5414096117019653,
0,
0.42978864908218384,
0.3137463331222534
],
[
0,
0,
0,
0,
0.3202584981918335
],
[
0,
0.37010884284973145,
0.3137463331222534,
0.3202584981918335,
0
]
] |
[
0,
0,
1,
0,
0
] |
def right_angle_triangle(a: int, b: int, c: int) -> bool:
"""
Given the lengths of the three sides of a triangle. Return True if the three
sides form a right-angled triangle, False otherwise.
A right-angled triangle is a triangle in which one angle is right angle or
90 degree.
Example:
>>> right_angle_triangle(3, 4, 5)
True
>>> right_angle_triangle(1, 2, 3)
False
"""
|
[
[
0,
0.7310585975646973,
0.5697720646858215,
0.5912072658538818,
0.39410507678985596
],
[
0,
0,
0.5697720646858215,
0.5912072658538818,
0.39410507678985596
],
[
0,
0,
0,
0.46083712577819824,
0.32875168323516846
],
[
0.5912072658538818,
0.5912072658538818,
0.46083712577819824,
0,
0.3361801505088806
],
[
0,
0.39410507678985596,
0.32875168323516846,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def numerical_letter_grade(grades: List[float]) -> List[str]:
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students and you have to write
a function that can output a list of letter grades using the following table:
GPA | Letter grade
4.0 A+
> 3.7 A
> 3.3 A-
> 3.0 B+
> 2.7 B
> 2.3 B-
> 2.0 C+
> 1.7 C
> 1.3 C-
> 1.0 D+
> 0.7 D
> 0.0 D-
0.0 E
Example:
>>> grade_equation([4.0, 3, 1.7, 2, 3.5])
['A+', 'B', 'C-', 'C', 'A-']
"""
|
[
[
0,
0.7310585975646973,
0.5682018995285034,
0.5902709364891052,
0.39154964685440063
],
[
0,
0,
0.5682018995285034,
0.5902709364891052,
0.39154964685440063
],
[
0.5682018995285034,
0.5682018995285034,
0,
0.4597740173339844,
0.3277917206287384
],
[
0,
0.5902709364891052,
0,
0,
0.3350392282009125
],
[
0,
0.39154964685440063,
0,
0.3350392282009125,
0
]
] |
[
0,
0,
1,
0,
0
] |
from typing import List
def intersperse(numbers: List[int], delimeter: int) -> List[int]:
""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
>>> intersperse([], 4)
[]
>>> intersperse([1, 2, 3], 4)
[1, 4, 2, 4, 3]
"""
|
[
[
0,
0.7310585975646973,
0.5990519523620605,
0.6076723337173462,
0.4130365252494812
],
[
0.7310585975646973,
0,
0.5990519523620605,
0.6076723337173462,
0.4130365252494812
],
[
0.5990519523620605,
0,
0,
0.4928894639015198,
0.3464061915874481
],
[
0.6076723337173462,
0,
0.4928894639015198,
0,
0.3498336970806122
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def specialFilter(nums: List[int]) -> int:
"""Write a function that takes an array of numbers as input and returns
the number of elements in the array that are greater than 10 and both
first and last digits of a number are odd (1, 3, 5, 7, 9).
For example:
>>> specialFilter([15, -73, 14, -15])
1
>>> specialFilter([33, -2, -3, 45, 21, 109])
2
"""
|
[
[
0,
0.7310585975646973,
0.6093167066574097,
0.6133093237876892,
0.41894593834877014
],
[
0,
0,
0.6093167066574097,
0.6133093237876892,
0.41894593834877014
],
[
0.6093167066574097,
0.6093167066574097,
0,
0.5049365758895874,
0.35318875312805176
],
[
0,
0,
0,
0,
0.35464048385620117
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
def sum_to_n(n: int) -> int:
"""sum_to_n is a function that sums numbers from 1 to n.
>>> sum_to_n(30)
465
>>> sum_to_n(100)
5050
>>> sum_to_n(5)
15
>>> sum_to_n(10)
55
>>> sum_to_n(1)
1
"""
|
[
[
0,
0.7310585975646973,
0.5846235752105713,
0.5997328758239746,
0.4038989543914795
],
[
0,
0,
0.5846235752105713,
0.5997328758239746,
0.4038989543914795
],
[
0,
0,
0,
0.47670236229896545,
0.337260365486145
],
[
0,
0,
0,
0,
0.3430339992046356
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def remove_duplicates(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
>>> remove_duplicates([1, 2, 3, 2, 4])
[1, 3, 4]
"""
|
[
[
0,
0.7310585975646973,
0.5953240394592285,
0.6055214405059814,
0.41082823276519775
],
[
0.7310585975646973,
0,
0.5953240394592285,
0.6055214405059814,
0.41082823276519775
],
[
0,
0,
0,
0.4886275827884674,
0.34412452578544617
],
[
0,
0,
0.4886275827884674,
0,
0.3481048345565796
],
[
0.41082823276519775,
0.41082823276519775,
0.34412452578544617,
0.3481048345565796,
0
]
] |
[
0,
0,
1,
0,
1
] |
from typing import List
def generate_integers(a: int, b: int) -> List[int]:
"""
Given two positive integers a and b, return the even digits between a
and b, in ascending order.
For example:
>>> generate_integers(2, 8)
[2, 4, 6, 8]
>>> generate_integers(8, 2)
[2, 4, 6, 8]
>>> generate_integers(10, 14)
[]
"""
|
[
[
0,
0.7310585975646973,
0.5914026498794556,
0.6034888029098511,
0.4080697298049927
],
[
0,
0,
0.5914026498794556,
0.6034888029098511,
0.4080697298049927
],
[
0,
0,
0,
0.48431238532066345,
0.3414820730686188
],
[
0,
0,
0,
0,
0.3461826741695404
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def rolling_max(numbers: List[int]) -> List[int]:
""" From a given list of integers, generate a list of rolling maximum element found until given moment
in the sequence.
>>> rolling_max([1, 2, 3, 2, 3, 4, 2])
[1, 2, 3, 3, 3, 4, 4]
"""
|
[
[
0,
0.7310585975646973,
0.5806098580360413,
0.597344160079956,
0.4015217423439026
],
[
0.7310585975646973,
0,
0.5806098580360413,
0.597344160079956,
0.4015217423439026
],
[
0.5806098580360413,
0,
0,
0.472290575504303,
0.33503711223602295
],
[
0,
0,
0,
0,
0.3412436842918396
],
[
0,
0,
0,
0.3412436842918396,
0
]
] |
[
0,
1,
0,
0,
1
] |
from typing import List
def below_zero(operations: List[int]) -> bool:
""" You're given a list of deposit and withdrawal operations on a bank account that starts with
zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
at that point function should return True. Otherwise it should return False.
>>> below_zero([1, 2, 3])
False
>>> below_zero([1, 2, -4, 5])
True
"""
|
[
[
0,
0.7310585975646973,
0.5877293944358826,
0.6013924479484558,
0.4061007797718048
],
[
0,
0,
0.5877293944358826,
0.6013924479484558,
0.4061007797718048
],
[
0,
0.5877293944358826,
0,
0.480071485042572,
0.33926495909690857
],
[
0,
0,
0,
0,
0.3445482850074768
],
[
0,
0,
0,
0.3445482850074768,
0
]
] |
[
0,
0,
0,
0,
1
] |
from typing import List
def search(lst: List[int]) -> int:
"""
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency greater than or equal to the value of the integer itself.
The frequency of an integer is the number of times it appears in the list.
If no such a value exist, return -1.
Examples:
>>> search([4, 1, 2, 2, 3, 1])
2
>>> search([1, 2, 2, 3, 3, 3, 4, 4, 4])
3
>>> search([5, 5, 4, 4, 4])
-1
"""
|
[
[
0,
0.7310585975646973,
0.5990225076675415,
0.607654333114624,
0.4130949378013611
],
[
0,
0,
0.5990225076675415,
0.607654333114624,
0.4130949378013611
],
[
0,
0,
0,
0.49281150102615356,
0.34637749195098877
],
[
0,
0,
0,
0,
0.3498324453830719
],
[
0,
0,
0,
0.3498324453830719,
0
]
] |
[
0,
0,
0,
0,
0
] |
def correct_bracketing(brackets: str) -> bool:
""" brackets is a string of "(" and ")".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing('(')
False
>>> correct_bracketing('()')
True
>>> correct_bracketing('(()())')
True
>>> correct_bracketing(')(()')
False
"""
|
[
[
0,
0.7310585975646973,
0.5501663684844971,
0.5736290812492371,
0.3785216510295868
],
[
0,
0,
0.5501663684844971,
0.5736290812492371,
0.3785216510295868
],
[
0,
0,
0,
0.43786340951919556,
0.3183392882347107
],
[
0,
0.5736290812492371,
0.43786340951919556,
0,
0.32490503787994385
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
0
] |
from typing import List
def sort_even(l: List[int]) -> List[int]:
"""This function takes a list l and returns a list l' such that
l' is identical to l in the odd indicies, while its values at the even indicies are equal
to the values of the even indicies of l, but sorted.
>>> sort_even([1, 2, 3])
[1, 2, 3]
>>> sort_even([5, 6, 3, 4])
[3, 6, 5, 4]
"""
|
[
[
0,
0.7310585975646973,
0.5864490866661072,
0.6006996631622314,
0.4046531915664673
],
[
0,
0,
0.5864490866661072,
0.6006996631622314,
0.4046531915664673
],
[
0,
0.5864490866661072,
0,
0.47893330454826355,
0.33844688534736633
],
[
0,
0,
0.47893330454826355,
0,
0.3437995910644531
],
[
0,
0.4046531915664673,
0.33844688534736633,
0.3437995910644531,
0
]
] |
[
0,
0,
1,
0,
1
] |
def same_chars(s0: str, s1: str) -> bool:
"""
Check if two words have the same characters.
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
True
>>> same_chars('abcd', 'dddddddabc')
True
>>> same_chars('dddddddabc', 'abcd')
True
>>> same_chars('eabcd', 'dddddddabc')
False
>>> same_chars('abcd', 'dddddddabce')
False
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
False
"""
|
[
[
0,
0.7310585975646973,
0.5194209218025208,
0.5399839282035828,
0.35112354159355164
],
[
0,
0,
0.5194209218025208,
0.5399839282035828,
0.35112354159355164
],
[
0,
0,
0,
0.4034135937690735,
0.30360567569732666
],
[
0,
0,
0,
0,
0.3072689473628998
],
[
0,
0,
0,
0,
0
]
] |
[
0,
0,
0,
0,
1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.