Resurgammm/AGP-Weights
Graph Machine Learning • Updated • 1
task stringlengths 120 1.39k | edge_weight listlengths 5 5 | mask listlengths 5 5 |
|---|---|---|
def strlen(string: str) -> int:
""" Return length of given string
>>> strlen('')
0
>>> strlen('abc')
3
"""
| [
[
0,
0.7310585975646973,
0.5459527969360352,
0.5714032053947449,
0.3744261860847473
],
[
0,
0,
0.5459527969360352,
0.5714032053947449,
0.3744261860847473
],
[
0,
0,
0,
0.43433743715286255,
0.3160649240016937
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
def encrypt(s: str) -> str:
"""Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the letters
shift down by two multiplied to two places.
For example:
>>> encrypt('hi'... | [
[
0,
0.7310585975646973,
0.5361953973770142,
0.5466917753219604,
0.3652215301990509
],
[
0,
0,
0.5361953973770142,
0.5466917753219604,
0.3652215301990509
],
[
0.5361953973770142,
0.5361953973770142,
0,
0.4151560068130493,
0.3113667070865631
],
... | [
0,
0,
0,
0,
0
] |
from typing import Dict
def check_dict_case(dict: Dict[str, str]) -> bool:
"""
Given a dictionary, return True if all keys are strings in lower
case or all keys are strings in upper case, else return False.
The function should return False is the given dictionary is empty.
Examples:
>>> check_... | [
[
0,
0.7310585975646973,
0.5638694763183594,
0.5860448479652405,
0.3892608880996704
],
[
0,
0,
0.5638694763183594,
0.5860448479652405,
0.3892608880996704
],
[
0.5638694763183594,
0.5638694763183594,
0,
0.45396485924720764,
0.3255983889102936
],
... | [
0,
0,
0,
0,
0
] |
from typing import List
def add(lst: List[int]) -> int:
"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
>>> add([4, 2, 6, 7])
2
"""
| [
[
0,
0.7310585975646973,
0.5917603969573975,
0.6037102341651917,
0.4078986942768097
],
[
0,
0,
0.5917603969573975,
0.6037102341651917,
0.4078986942768097
],
[
0,
0,
0,
0.48488569259643555,
0.3416709303855896
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
1
] |
def fibfib(n: int) -> int:
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute the n-th element ... | [
[
0,
0.7310585975646973,
0.5725210905075073,
0.5909836888313293,
0.3961414694786072
],
[
0,
0,
0.5725210905075073,
0.5909836888313293,
0.3961414694786072
],
[
0,
0,
0,
0.462358683347702,
0.33030572533607483
],
[
0.5909836888313293,
0.59... | [
0,
0,
0,
1,
1
] |
from typing import List, Any
def filter_integers(values: List[Any]) -> List[int]:
""" Filter given list of any python values only for integers
>>> filter_integers(['a', 3.14, 5])
[5]
>>> filter_integers([1, 2, 3, 'abc', { }, []])
[1, 2, 3]
"""
| [
[
0,
0.7310585975646973,
0.6458622813224792,
0.6326209902763367,
0.43708816170692444
],
[
0,
0,
0.6458622813224792,
0.6326209902763367,
0.43708816170692444
],
[
0,
0,
0,
0.5512309074401855,
0.380502849817276
],
[
0.6326209902763367,
0.6... | [
0,
0,
0,
0,
0
] |
def car_race_collision(n: int) -> int:
"""
Imagine a road that's a perfectly straight infinitely long line.
n cars are driving left to right; simultaneously, a different set of n cars
are driving right to left. The two sets of cars start out being very far from
each other. All cars move in the s... | [
[
0,
0.7310585975646973,
0.5742687582969666,
0.5938686728477478,
0.3972034752368927
],
[
0,
0,
0.5742687582969666,
0.5938686728477478,
0.3972034752368927
],
[
0,
0,
0,
0.465483158826828,
0.33116966485977173
],
[
0,
0,
0.465483158826... | [
0,
0,
0,
0,
0
] |
from typing import List
def parse_music(music_string: str) -> List[int]:
""" Input to this function is a string representing musical notes in a special ASCII format.
Your task is to parse this string and return list of integers corresponding to how many beats does each
not last.
Here is a legend:
... | [
[
0,
0.7310585975646973,
0.5831202864646912,
0.5988083481788635,
0.40273162722587585
],
[
0,
0,
0.5831202864646912,
0.5988083481788635,
0.40273162722587585
],
[
0,
0,
0,
0.4751892387866974,
0.33646705746650696
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
def decimal_to_binary(decimal: int) -> str:
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1'.
There will be an extra coupl... | [
[
0,
0.7310585975646973,
0.5360420346260071,
0.5598841905593872,
0.3656363785266876
],
[
0,
0,
0.5360420346260071,
0.5598841905593872,
0.3656363785266876
],
[
0,
0.5360420346260071,
0,
0.4224376380443573,
0.3112088441848755
],
[
0,
0,
... | [
0,
0,
1,
0,
0
] |
from typing import List
def all_prefixes(string: str) -> List[str]:
""" Return list of all prefixes from shortest to longest of the input string
>>> all_prefixes('abc')
['a', 'ab', 'abc']
"""
| [
[
0,
0.7310585975646973,
0.5559654235839844,
0.5758942365646362,
0.3821430206298828
],
[
0,
0,
0.5559654235839844,
0.5758942365646362,
0.3821430206298828
],
[
0,
0.5559654235839844,
0,
0.44295763969421387,
0.32128581404685974
],
[
0,
0,... | [
0,
0,
0,
0,
1
] |
def add(x: int, y: int) -> int:
"""Add two numbers x and y
>>> add(2, 3)
5
>>> add(5, 7)
12
"""
| [
[
0,
0.7310585975646973,
0.5831549167633057,
0.5988715291023254,
0.40312984585762024
],
[
0,
0,
0.5831549167633057,
0.5988715291023254,
0.40312984585762024
],
[
0,
0,
0,
0.4750344157218933,
0.3364291489124298
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
def flip_case(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flip_case('Hello')
'hELLO'
"""
| [
[
0,
0.7310585975646973,
0.5291882157325745,
0.5488349795341492,
0.3592526614665985
],
[
0,
0,
0.5291882157325745,
0.5488349795341492,
0.3592526614665985
],
[
0.5291882157325745,
0.5291882157325745,
0,
0.4130275547504425,
0.3080199062824249
],
... | [
0,
0,
0,
1,
1
] |
from typing import List
def by_length(arr: List[int]) -> List[str]:
"""
Given an array of integers, sort the integers that are between 1 and 9 inclusive,
reverse the resulting array, and then replace each digit by its corresponding name from
"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight... | [
[
0,
0.7310585975646973,
0.5944650173187256,
0.6051067113876343,
0.410251259803772
],
[
0,
0,
0.5944650173187256,
0.6051067113876343,
0.410251259803772
],
[
0,
0.5944650173187256,
0,
0.48766735196113586,
0.3435167372226715
],
[
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def factorize(n: int) -> List[int]:
""" Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product... | [
[
0,
0.7310585975646973,
0.5900800228118896,
0.6027089357376099,
0.40773141384124756
],
[
0,
0,
0.5900800228118896,
0.6027089357376099,
0.40773141384124756
],
[
0,
0.5900800228118896,
0,
0.48259904980659485,
0.3406849801540375
],
[
0,
0... | [
0,
0,
0,
0,
0
] |
from typing import List
def count_up_to(n: int) -> List[int]:
"""Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and less than n.
for example:
>>> count_up_to(5)
[2, 3]
>>> count_up_to(11)
[2, 3, 5, 7]
>>> count... | [
[
0,
0.7310585975646973,
0.6102949380874634,
0.6138947010040283,
0.41964709758758545
],
[
0.7310585975646973,
0,
0.6102949380874634,
0.6138947010040283,
0.41964709758758545
],
[
0,
0,
0,
0.5059905052185059,
0.35375046730041504
],
[
0,
0... | [
0,
0,
0,
0,
1
] |
from typing import List
def unique(l: List[int]) -> List[int]:
"""Return sorted unique elements in a list
>>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
[0, 2, 3, 5, 9, 123]
"""
| [
[
0,
0.7310585975646973,
0.5864791870117188,
0.6006300449371338,
0.40503692626953125
],
[
0,
0,
0.5864791870117188,
0.6006300449371338,
0.40503692626953125
],
[
0,
0,
0,
0.4788343012332916,
0.33857831358909607
],
[
0.6006300449371338,
0... | [
0,
0,
0,
0,
0
] |
from typing import List
def max_element(l: List[int]) -> int:
"""Return maximum element in the list.
>>> max_element([1, 2, 3])
3
>>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
123
"""
| [
[
0,
0.7310585975646973,
0.5832149386405945,
0.5988035202026367,
0.40277957916259766
],
[
0,
0,
0.5832149386405945,
0.5988035202026367,
0.40277957916259766
],
[
0,
0,
0,
0.47531503438949585,
0.3365890085697174
],
[
0,
0,
0.475315034... | [
0,
0,
0,
0,
1
] |
from typing import Union
def rounded_avg(n: int, m: int) -> Union[str, int]:
"""You are given two positive integers n and m, and your task is to compute the
average of the integers from n through m (including n and m).
Round the answer to the nearest integer and convert that to binary.
If n is greater... | [
[
0,
0.7310585975646973,
0.5847081542015076,
0.599746584892273,
0.40404918789863586
],
[
0,
0,
0.5847081542015076,
0.599746584892273,
0.40404918789863586
],
[
0,
0,
0,
0.4767725467681885,
0.337362676858902
],
[
0,
0,
0.4767725467681... | [
0,
0,
0,
0,
0
] |
from typing import List
def odd_count(lst: List[str]) -> List[str]:
"""Given a list of strings, where each string consists of only digits, return a list.
Each element i of the output should be "the number of odd elements in the
string i of the input." where all the i's should be replaced by the number
... | [
[
0,
0.7310585975646973,
0.5618352890014648,
0.5864667296409607,
0.3857838809490204
],
[
0,
0,
0.5618352890014648,
0.5864667296409607,
0.3857838809490204
],
[
0,
0,
0,
0.45361289381980896,
0.3241393268108368
],
[
0.5864667296409607,
0.5... | [
0,
0,
0,
0,
0
] |
from typing import List
def move_one_ball(arr: List[int]) -> bool:
"""We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
numbers in the array will be randomly ordered. Your task is to determine if
it is possible to get an array sorted in non-decreasing order by performing
the followi... | [
[
0,
0.7310585975646973,
0.5880574584007263,
0.6016290783882141,
0.40647369623184204
],
[
0.7310585975646973,
0,
0.5880574584007263,
0.6016290783882141,
0.40647369623184204
],
[
0,
0,
0,
0.4803132712841034,
0.33936551213264465
],
[
0.601629... | [
0,
0,
0,
0,
0
] |
from typing import Tuple
def even_odd_palindrome(n: int) -> Tuple[int, int]:
"""
Given a positive integer n, return a tuple that has the number of even and odd
integer palindromes that fall within the range(1, n), inclusive.
Example 1:
>>> even_odd_palindrome(3)
(1, 2)
Explanation:
... | [
[
0,
0.7310585975646973,
0.5764344334602356,
0.5950533151626587,
0.39804208278656006
],
[
0,
0,
0.5764344334602356,
0.5950533151626587,
0.39804208278656006
],
[
0,
0.5764344334602356,
0,
0.4680807590484619,
0.33247560262680054
],
[
0,
0... | [
0,
0,
0,
0,
0
] |
def is_equal_to_sum_even(n: int) -> bool:
"""Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
Example
>>> is_equal_to_sum_even(4)
False
>>> is_equal_to_sum_even(6)
False
>>> is_equal_to_sum_even(8)
True
"""
| [
[
0,
0.7310585975646973,
0.577495813369751,
0.5957269072532654,
0.39879825711250305
],
[
0,
0,
0.577495813369751,
0.5957269072532654,
0.39879825711250305
],
[
0,
0,
0,
0.4691532850265503,
0.3329944908618927
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def derivative(xs: List[int]) -> List[int]:
""" xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return derivative of this polynomial in the same form.
>>> derivative([3, 1, 2, 4, 5])
[1, 4, 12, 20]
>>> derivative([1, 2, 3])
[2, 6]
... | [
[
0,
0.7310585975646973,
0.5846138596534729,
0.5996387600898743,
0.4038187563419342
],
[
0,
0,
0.5846138596534729,
0.5996387600898743,
0.4038187563419342
],
[
0,
0.5846138596534729,
0,
0.47677120566368103,
0.33737748861312866
],
[
0,
0,... | [
0,
0,
0,
0,
0
] |
def solve(s: str) -> str:
"""You are given a string s.
if s[i] is a letter, reverse its case from lower to upper or vise versa,
otherwise keep it as it is.
If the string contains no letters, reverse the string.
The function should return the resulted string.
Examples
>>> solve('1234')
'... | [
[
0,
0.7310585975646973,
0.5270752906799316,
0.5494014620780945,
0.3576663136482239
],
[
0,
0,
0.5270752906799316,
0.5494014620780945,
0.3576663136482239
],
[
0,
0,
0,
0.41221871972084045,
0.3070538640022278
],
[
0,
0,
0.41221871972... | [
0,
0,
1,
1,
1
] |
def fizz_buzz(n: int) -> int:
"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizz_buzz(50)
0
>>> fizz_buzz(78)
2
>>> fizz_buzz(79)
3
"""
| [
[
0,
0.7310585975646973,
0.5811337828636169,
0.597224235534668,
0.40191125869750977
],
[
0.7310585975646973,
0,
0.5811337828636169,
0.597224235534668,
0.40191125869750977
],
[
0,
0,
0,
0.47240468859672546,
0.3352111876010895
],
[
0,
0,
... | [
0,
0,
0,
0,
1
] |
from typing import List
def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
""" Filter an input list of strings only for ones that start with a given prefix.
>>> filter_by_prefix([], 'a')
[]
>>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
['abc', 'array']
"""
| [
[
0,
0.7310585975646973,
0.5842877626419067,
0.5980392694473267,
0.40381038188934326
],
[
0,
0,
0.5842877626419067,
0.5980392694473267,
0.40381038188934326
],
[
0,
0,
0,
0.47546568512916565,
0.33741775155067444
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def minPath(grid: List[List[int]], k: int) -> List[int]:
"""
Given a grid with N rows and N columns (N >= 2) and a positive integer k,
each cell of the grid contains a value. Every integer in the range [1, N * N]
inclusive appears exactly once on the cells of the grid.
You... | [
[
0,
0.7310585975646973,
0.561525821685791,
0.5859988331794739,
0.38759687542915344
],
[
0,
0,
0.561525821685791,
0.5859988331794739,
0.38759687542915344
],
[
0,
0.561525821685791,
0,
0.45243874192237854,
0.3242640793323517
],
[
0,
0,
... | [
0,
0,
0,
1,
1
] |
def count_upper(s: str) -> int:
"""
Given a string s, count the number of uppercase vowels in even indices.
For example:
>>> count_upper('aBCdEf')
1
>>> count_upper('abcdefg')
0
>>> count_upper('dBBE')
0
"""
| [
[
0,
0.7310585975646973,
0.5335609316825867,
0.556732714176178,
0.363095223903656
],
[
0.7310585975646973,
0,
0.5335609316825867,
0.556732714176178,
0.363095223903656
],
[
0,
0,
0,
0.41963258385658264,
0.3100614845752716
],
[
0.556732714176... | [
0,
0,
0,
0,
0
] |
from typing import List
def maximum(arr: List[int], k: int) -> List[int]:
"""
Given an array arr of integers and a positive integer k, return a sorted list
of length k with the maximum k numbers in arr.
Example 1:
>>> maximum([-3, -4, 5], 3)
[-4, -3, 5]
Example 2:
>>> maximum([4, -... | [
[
0,
0.7310585975646973,
0.5892570614814758,
0.6021843552589417,
0.4070928692817688
],
[
0,
0,
0.5892570614814758,
0.6021843552589417,
0.4070928692817688
],
[
0,
0.5892570614814758,
0,
0.4817778468132019,
0.3402806222438812
],
[
0,
0,
... | [
0,
0,
0,
0,
1
] |
def largest_divisor(n: int) -> int:
""" For a given number n, find the largest number that divides n evenly, smaller than n
>>> largest_divisor(15)
5
"""
| [
[
0,
0.7310585975646973,
0.5651302337646484,
0.5879199504852295,
0.3908939063549042
],
[
0,
0,
0.5651302337646484,
0.5879199504852295,
0.3908939063549042
],
[
0,
0,
0,
0.4557155668735504,
0.32628777623176575
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def sort_array(array: List[int]) -> List[int]:
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
or sort it in descending order if... | [
[
0,
0.7310585975646973,
0.5914967656135559,
0.6035051941871643,
0.40835583209991455
],
[
0,
0,
0.5914967656135559,
0.6035051941871643,
0.40835583209991455
],
[
0,
0.5914967656135559,
0,
0.4843255579471588,
0.3415861427783966
],
[
0,
0.... | [
0,
0,
0,
0,
0
] |
from typing import List
def f(n: int) -> List[int]:
""" Implement the function f that takes n as a parameter,
and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
or the sum of numbers from 1 to i otherwise.
i starts from 1.
the factorial of... | [
[
0,
0.7310585975646973,
0.6031373739242554,
0.61001056432724,
0.4155429005622864
],
[
0,
0,
0.6031373739242554,
0.61001056432724,
0.4155429005622864
],
[
0,
0,
0,
0.49752524495124817,
0.34891822934150696
],
[
0,
0,
0,
0,
0.... | [
0,
0,
0,
0,
1
] |
def iscube(a: int) -> bool:
"""
Write a function that takes an integer a and returns True
if this ingeger is a cube of some integer number.
Note: you may assume the input is always valid.
Examples:
>>> iscube(1)
True
>>> iscube(2)
False
>>> iscube(-1)
True
>>> iscube(64)... | [
[
0,
0.7310585975646973,
0.5957325100898743,
0.6059268116950989,
0.4113304913043976
],
[
0.7310585975646973,
0,
0.5957325100898743,
0.6059268116950989,
0.4113304913043976
],
[
0,
0,
0,
0.4888753294944763,
0.34410718083381653
],
[
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def pairs_sum_to_zero(l: List[int]) -> bool:
"""
pairs_sum_to_zero takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
sum to zero, and False otherwise.
>>> pairs_sum_to_zero([1, 3, 5, 0])
False
>>> pairs_sum_to_z... | [
[
0,
0.7310585975646973,
0.5902866721153259,
0.6029381155967712,
0.4070470631122589
],
[
0,
0,
0.5902866721153259,
0.6029381155967712,
0.4070470631122589
],
[
0,
0.5902866721153259,
0,
0.48316827416419983,
0.34067603945732117
],
[
0,
0.... | [
0,
0,
0,
0,
0
] |
def triangle_area(a: int, b: int, c: int) -> float:
"""
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid triangle when the sum of any two sides is gr... | [
[
0,
0.7310585975646973,
0.5786261558532715,
0.5963612198829651,
0.3999643623828888
],
[
0,
0,
0.5786261558532715,
0.5963612198829651,
0.3999643623828888
],
[
0,
0,
0,
0.4701862633228302,
0.33367031812667847
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
1
] |
from typing import Tuple
def bf(planet1: str, planet2: str) -> Tuple[str, ...]:
"""
There are eight planets in our solar system: the closerst to the Sun
is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
Uranus, Neptune.
Write a function that takes two planet names as strings p... | [
[
0,
0.7310585975646973,
0.5407697558403015,
0.5638874173164368,
0.36994311213493347
],
[
0.7310585975646973,
0,
0.5407697558403015,
0.5638874173164368,
0.36994311213493347
],
[
0.5407697558403015,
0,
0,
0.42708975076675415,
0.31352806091308594
]... | [
0,
0,
0,
0,
1
] |
def digits(n: int) -> int:
"""Given a positive integer n, return the product of the odd digits.
Return 0 if all digits are even.
For example:
>>> digits(1)
1
>>> digits(4)
0
>>> digits(235)
15
"""
| [
[
0,
0.7310585975646973,
0.5786634683609009,
0.595920741558075,
0.3995455801486969
],
[
0,
0,
0.5786634683609009,
0.595920741558075,
0.3995455801486969
],
[
0,
0.5786634683609009,
0,
0.47009897232055664,
0.3337024748325348
],
[
0,
0.595... | [
0,
0,
0,
0,
1
] |
from typing import List
def words_string(s: str) -> List[str]:
"""
You will be given a string of words separated by commas or spaces. Your task is
to split the string into words and return an array of the words.
For example:
>>> words_string('Hi, my name is John')
['Hi', 'my', 'name', 'is'... | [
[
0,
0.7310585975646973,
0.5454996228218079,
0.5630558133125305,
0.37295737862586975
],
[
0,
0,
0.5454996228218079,
0.5630558133125305,
0.37295737862586975
],
[
0,
0,
0,
0.42955106496810913,
0.3158920109272003
],
[
0,
0,
0.429551064... | [
0,
0,
0,
0,
1
] |
def how_many_times(string: str, substring: str) -> int:
""" Find how many times a given substring can be found in the original string. Count overlaping cases.
>>> how_many_times('', 'a')
0
>>> how_many_times('aaa', 'a')
3
>>> how_many_times('aaaa', 'aa')
3
"""
| [
[
0,
0.7310585975646973,
0.5490551590919495,
0.5735914707183838,
0.3768863081932068
],
[
0,
0,
0.5490551590919495,
0.5735914707183838,
0.3768863081932068
],
[
0.5490551590919495,
0.5490551590919495,
0,
0.437447726726532,
0.31764376163482666
],
... | [
0,
0,
1,
0,
1
] |
from typing import Union
def compare_one(a: Union[int, float, str], b: Union[int, float, str]) -> Union[int, float, str, None]:
"""
Create a function that takes integers, floats, or strings representing
real numbers, and returns the larger variable in its given variable type.
Return None if the values ... | [
[
0,
0.7310585975646973,
0.5941138863563538,
0.6050254702568054,
0.41008105874061584
],
[
0,
0,
0.5941138863563538,
0.6050254702568054,
0.41008105874061584
],
[
0,
0,
0,
0.4871819019317627,
0.3431181311607361
],
[
0,
0.6050254702568054,... | [
0,
0,
0,
0,
0
] |
def remove_vowels(text: str) -> str:
"""
remove_vowels is a function that takes string and returns string without vowels.
>>> remove_vowels('')
''
>>> remove_vowels('abcdef')
'bcdf'
>>> remove_vowels('aaaaa')
''
>>> remove_vowels('aaBAA')
'B'
>>> remove_vowels('zbcd')
'zb... | [
[
0,
0.7310585975646973,
0.52146315574646,
0.5416050553321838,
0.3529658317565918
],
[
0.7310585975646973,
0,
0.52146315574646,
0.5416050553321838,
0.3529658317565918
],
[
0.52146315574646,
0.52146315574646,
0,
0.40551844239234924,
0.30477800965309... | [
0,
1,
0,
0,
1
] |
from typing import List
def strange_sort_list(lst: List[int]) -> List[int]:
"""
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
>>> strange_sort_list([1, 2... | [
[
0,
0.7310585975646973,
0.5906568169593811,
0.6030043363571167,
0.40796172618865967
],
[
0,
0,
0.5906568169593811,
0.6030043363571167,
0.40796172618865967
],
[
0,
0,
0,
0.48333123326301575,
0.34109848737716675
],
[
0,
0,
0.48333123... | [
0,
0,
0,
0,
0
] |
from typing import List, Tuple
def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
""" From a supplied list of numbers (of length at least two) select and return two that are the closest to each
other and return them in order (smaller number, larger number).
>>> find_closest_elements([1... | [
[
0,
0.7310585975646973,
0.5854631662368774,
0.6001133918762207,
0.4044189453125
],
[
0,
0,
0.5854631662368774,
0.6001133918762207,
0.4044189453125
],
[
0,
0.5854631662368774,
0,
0.4776844382286072,
0.33789941668510437
],
[
0.60011339187622... | [
0,
0,
1,
0,
1
] |
def is_simple_power(x: int, n: int) -> bool:
"""Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if n**int=x
For example:
>>> is_simple_power(1, 4)
True
>>> is_simple_power(2, 2)
True
>>> is_sim... | [
[
0,
0.7310585975646973,
0.5812557935714722,
0.5976129174232483,
0.402077317237854
],
[
0,
0,
0.5812557935714722,
0.5976129174232483,
0.402077317237854
],
[
0,
0,
0,
0.4727616012096405,
0.3353106677532196
],
[
0,
0,
0.47276160120964... | [
0,
0,
0,
1,
1
] |
def prime_fib(n: int) -> int:
"""
prime_fib returns n-th number that is a Fibonacci number and it's also prime.
>>> prime_fib(1)
2
>>> prime_fib(2)
3
>>> prime_fib(3)
5
>>> prime_fib(4)
13
>>> prime_fib(5)
89
"""
| [
[
0,
0.7310585975646973,
0.5775979161262512,
0.5944811701774597,
0.3996463418006897
],
[
0,
0,
0.5775979161262512,
0.5944811701774597,
0.3996463418006897
],
[
0,
0,
0,
0.46803906559944153,
0.3331422805786133
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers closer to each other than
given threshold.
>>> has_close_elements([1.0, 2.0, 3.0], 0.5)
False
>>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2... | [
[
0,
0.7310585975646973,
0.6043148636817932,
0.6106183528900146,
0.41614073514938354
],
[
0,
0,
0.6043148636817932,
0.6106183528900146,
0.41614073514938354
],
[
0,
0,
0,
0.49897339940071106,
0.3497667610645294
],
[
0,
0,
0.498973399... | [
0,
0,
0,
0,
1
] |
def make_palindrome(string: str) -> str:
""" Find the shortest palindrome that begins with a supplied string.
Algorithm idea is simple:
- Find the longest postfix of supplied string that is a palindrome.
- Append to the end of the string reverse of a string prefix that comes before the palindromic suffi... | [
[
0,
0.7310585975646973,
0.5098133683204651,
0.5308934450149536,
0.34300026297569275
],
[
0,
0,
0.5098133683204651,
0.5308934450149536,
0.34300026297569275
],
[
0.5098133683204651,
0.5098133683204651,
0,
0.3942408859729767,
0.29948410391807556
],... | [
0,
0,
0,
0,
0
] |
def string_xor(a: str, b: str) -> str:
""" Input are two strings a and b consisting only of 1s and 0s.
Perform binary XOR on these inputs and return result also as a string.
>>> string_xor('010', '110')
'100'
"""
| [
[
0,
0.7310585975646973,
0.5345494151115417,
0.5563687682151794,
0.3645571172237396
],
[
0,
0,
0.5345494151115417,
0.5563687682151794,
0.3645571172237396
],
[
0,
0.5345494151115417,
0,
0.41955840587615967,
0.31054413318634033
],
[
0,
0.... | [
0,
0,
0,
0,
1
] |
def special_factorial(n: int) -> int:
"""The Brazilian factorial is defined as:
brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
where n > 0
For example:
>>> special_factorial(4)
288
The function will receive an integer as input and should return the special
factorial of this i... | [
[
0,
0.7310585975646973,
0.5698283910751343,
0.5897971987724304,
0.39426517486572266
],
[
0,
0,
0.5698283910751343,
0.5897971987724304,
0.39426517486572266
],
[
0,
0,
0,
0.45983418822288513,
0.32879671454429626
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def add_elements(arr: List[int], k: int) -> int:
"""
Given a non-empty array of integers arr and an integer k, return
the sum of the elements with at most two digits from the first k elements of arr.
Example:
>>> add_elements([111, 21, 3, 4000, 5, 6, 7, 8, 9], 4)
24
... | [
[
0,
0.7310585975646973,
0.5949661135673523,
0.6054607629776001,
0.4105266034603119
],
[
0.7310585975646973,
0,
0.5949661135673523,
0.6054607629776001,
0.4105266034603119
],
[
0,
0.5949661135673523,
0,
0.4882138669490814,
0.3437255918979645
],
... | [
0,
0,
0,
0,
0
] |
def fib4(n: int) -> int:
"""The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fib4(0) -> 0
fib4(1) -> 0
fib4(2) -> 2
fib4(3) -> 0
fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
Please write a function to efficiently compute the n-... | [
[
0,
0.7310585975646973,
0.5543820261955261,
0.5795750617980957,
0.38226136565208435
],
[
0,
0,
0.5543820261955261,
0.5795750617980957,
0.38226136565208435
],
[
0,
0,
0,
0.4438852369785309,
0.3204600512981415
],
[
0,
0.5795750617980957,... | [
0,
0,
0,
0,
0
] |
from typing import List
def unique_digits(x: List[int]) -> List[int]:
"""Given a list of positive integers x. return a sorted list of all
elements that hasn't any even digit.
Note: Returned list should be sorted in increasing order.
For example:
>>> unique_digits([15, 33, 1422, 1])
[1, 1... | [
[
0,
0.7310585975646973,
0.5897971987724304,
0.6025541424751282,
0.4070347249507904
],
[
0.7310585975646973,
0,
0.5897971987724304,
0.6025541424751282,
0.4070347249507904
],
[
0.5897971987724304,
0,
0,
0.48254719376564026,
0.3405384123325348
],
... | [
0,
0,
0,
0,
0
] |
from typing import List
def select_words(s: str, n: int) -> List[str]:
"""Given a string s and a natural number n, you have been tasked to implement
a function that returns a list of all words from string s that contain exactly
n consonants, in order these words appear in the string s.
If the string ... | [
[
0,
0.7310585975646973,
0.5546517968177795,
0.5762976408004761,
0.3811649680137634
],
[
0,
0,
0.5546517968177795,
0.5762976408004761,
0.3811649680137634
],
[
0,
0,
0,
0.4424263834953308,
0.32056504487991333
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def will_it_fly(q: List[int], w: int) -> bool:
"""
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.
... | [
[
0,
0.7310585975646973,
0.5805330872535706,
0.5973538756370544,
0.4015035033226013
],
[
0,
0,
0.5805330872535706,
0.5973538756370544,
0.4015035033226013
],
[
0.5805330872535706,
0.5805330872535706,
0,
0.47216519713401794,
0.33491700887680054
],
... | [
0,
0,
0,
0,
0
] |
def fib(n: int) -> int:
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
| [
[
0,
0.7310585975646973,
0.5793894529342651,
0.5955475568771362,
0.40078991651535034
],
[
0,
0,
0.5793894529342651,
0.5955475568771362,
0.40078991651535034
],
[
0,
0,
0,
0.4699932038784027,
0.33417069911956787
],
[
0,
0,
0.469993203... | [
0,
0,
0,
0,
0
] |
from typing import List
def Strongest_Extension(class_name: str, extensions: List[str]) -> str:
"""You will be given the name of a class (a string) and a list of extensions.
The extensions are to be used to load additional classes to the class. The
strength of the extension is as follows: Let CAP be the nu... | [
[
0,
0.7310585975646973,
0.55995774269104,
0.5838906168937683,
0.38615667819976807
],
[
0,
0,
0.55995774269104,
0.5838906168937683,
0.38615667819976807
],
[
0,
0,
0,
0.45019975304603577,
0.32343652844429016
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List, Optional
def next_smallest(lst: List[int]) -> Optional[int]:
"""
You are given a list of integers.
Write a function next_smallest() that returns the 2nd smallest element of the list.
Return None if there is no such element.
>>> next_smallest([1, 2, 3, 4, 5])
2
>>> n... | [
[
0,
0.7310585975646973,
0.6000675559043884,
0.6082530617713928,
0.4137435853481293
],
[
0,
0,
0.6000675559043884,
0.6082530617713928,
0.4137435853481293
],
[
0,
0.6000675559043884,
0,
0.4939919710159302,
0.34701818227767944
],
[
0,
0.6... | [
0,
0,
0,
0,
0
] |
def any_int(x: float, y: float, z: float) -> bool:
"""
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
Returns false in any other cases.
Examples
>>> any_int(5, 2, 7)
True
>>> any_int... | [
[
0,
0.7310585975646973,
0.6138161420822144,
0.6158602833747864,
0.42155376076698303
],
[
0,
0,
0.6138161420822144,
0.6158602833747864,
0.42155376076698303
],
[
0,
0.6138161420822144,
0,
0.5102178454399109,
0.3560820519924164
],
[
0,
0,... | [
0,
0,
0,
0,
0
] |
def truncate_number(number: float) -> float:
""" Given a positive floating point number, it can be decomposed into
and integer part (largest integer smaller than given number) and decimals
(leftover part always smaller than 1).
Return the decimal part of the number.
>>> truncate_number(3.5)
0.5... | [
[
0,
0.7310585975646973,
0.56861811876297,
0.5905695557594299,
0.39261406660079956
],
[
0.7310585975646973,
0,
0.56861811876297,
0.5905695557594299,
0.39261406660079956
],
[
0.56861811876297,
0,
0,
0.4598991274833679,
0.3280330300331116
],
[
... | [
0,
1,
0,
0,
0
] |
from typing import List
def incr_list(l: List[int]) -> List[int]:
"""Return list with elements incremented by 1.
>>> incr_list([1, 2, 3])
[2, 3, 4]
>>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
[6, 4, 6, 3, 4, 4, 10, 1, 124]
"""
| [
[
0,
0.7310585975646973,
0.5958303809165955,
0.6058320999145508,
0.4109688699245453
],
[
0,
0,
0.5958303809165955,
0.6058320999145508,
0.4109688699245453
],
[
0.5958303809165955,
0.5958303809165955,
0,
0.4892849326133728,
0.344424307346344
],
[... | [
0,
0,
1,
0,
0
] |
def x_or_y(n: int, x: int, y: int) -> int:
"""A simple program which should return the value of x if n is
a prime number and should return the value of y otherwise.
Examples:
>>> x_or_y(7, 34, 12)
34
>>> x_or_y(15, 8, 5)
5
"""
| [
[
0,
0.7310585975646973,
0.583605945110321,
0.5989648103713989,
0.40350762009620667
],
[
0,
0,
0.583605945110321,
0.5989648103713989,
0.40350762009620667
],
[
0,
0.583605945110321,
0,
0.4753410518169403,
0.3366687297821045
],
[
0,
0,
... | [
0,
0,
0,
0,
0
] |
def modp(n: int, p: int) -> int:
"""Return 2^n modulo p (be aware of numerics).
>>> modp(3, 5)
3
>>> modp(1101, 101)
2
>>> modp(0, 101)
1
>>> modp(3, 11)
8
>>> modp(100, 101)
1
"""
| [
[
0,
0.7310585975646973,
0.5646987557411194,
0.586878776550293,
0.3903690576553345
],
[
0,
0,
0.5646987557411194,
0.586878776550293,
0.3903690576553345
],
[
0,
0,
0,
0.45480698347091675,
0.3260306119918823
],
[
0,
0,
0.4548069834709... | [
0,
0,
0,
0,
0
] |
from typing import Tuple
def even_odd_count(num: int) -> Tuple[int, int]:
"""Given an integer. return a tuple that has the number of even and odd digits respectively.
Example:
>>> even_odd_count(-12)
(1, 1)
>>> even_odd_count(123)
(1, 2)
"""
| [
[
0,
0.7310585975646973,
0.5840105414390564,
0.599388599395752,
0.40274399518966675
],
[
0.7310585975646973,
0,
0.5840105414390564,
0.599388599395752,
0.40274399518966675
],
[
0.5840105414390564,
0,
0,
0.4763708710670471,
0.33687764406204224
],
... | [
0,
0,
0,
0,
0
] |
def is_happy(s: str) -> bool:
"""You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example:
>>> is_happy('a')
False
>>> is_happy('aa')
False
>>> is_happy('abcd'... | [
[
0,
0.7310585975646973,
0.5433745980262756,
0.5674501657485962,
0.37236952781677246
],
[
0,
0,
0.5433745980262756,
0.5674501657485962,
0.37236952781677246
],
[
0,
0,
0,
0.4305037260055542,
0.3148254156112671
],
[
0,
0,
0.4305037260... | [
0,
0,
0,
0,
1
] |
def largest_prime_factor(n: int) -> int:
"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
>>> largest_prime_factor(13195)
29
>>> largest_prime_factor(2048)
2
"""
| [
[
0,
0.7310585975646973,
0.5686620473861694,
0.5901235342025757,
0.3934708535671234
],
[
0,
0,
0.5686620473861694,
0.5901235342025757,
0.3934708535671234
],
[
0,
0,
0,
0.4593780040740967,
0.32820162177085876
],
[
0.5901235342025757,
0.5... | [
0,
0,
0,
0,
0
] |
def digitSum(s: str) -> int:
"""Task
Write a function that takes a string as input and returns the sum of the upper characters only'
ASCII codes.
Examples:
>>> digitSum('')
0
>>> digitSum('abAB')
131
>>> digitSum('abcCd')
67
>>> digitSum('helloE')
69
>>> digitSum('wo... | [
[
0,
0.7310585975646973,
0.545807421207428,
0.5712180733680725,
0.37381038069725037
],
[
0.7310585975646973,
0,
0.545807421207428,
0.5712180733680725,
0.37381038069725037
],
[
0,
0,
0,
0.4343608617782593,
0.31594789028167725
],
[
0,
0,
... | [
0,
0,
0,
1,
0
] |
from typing import List
def rescale_to_unit(numbers: List[float]) -> List[float]:
""" Given list of numbers (of at least two elements), apply a linear transform to that list,
such that the smallest number will become 0 and the largest will become 1
>>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
[0.0, 0... | [
[
0,
0.7310585975646973,
0.5859383344650269,
0.6003737449645996,
0.4046376645565033
],
[
0,
0,
0.5859383344650269,
0.6003737449645996,
0.4046376645565033
],
[
0,
0,
0,
0.478246808052063,
0.3381924629211426
],
[
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0
] |
from typing import List
def solution(lst: List[int]) -> int:
"""Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
Examples
>>> solution([5, 8, 7, 1])
12
>>> solution([3, 3, 3, 3, 3])
9
>>> solution([30, 13, 24, 321])
0
""... | [
[
0,
0.7310585975646973,
0.5922714471817017,
0.6040906310081482,
0.4078421890735626
],
[
0.7310585975646973,
0,
0.5922714471817017,
0.6040906310081482,
0.4078421890735626
],
[
0,
0,
0,
0.4855717718601227,
0.3418327867984772
],
[
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def pluck(arr: List[int]) -> List[int]:
"""
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the smallest even value.
If multiple nodes with the ... | [
[
0,
0.7310585975646973,
0.569451093673706,
0.5909125208854675,
0.39353612065315247
],
[
0.7310585975646973,
0,
0.569451093673706,
0.5909125208854675,
0.39353612065315247
],
[
0.569451093673706,
0,
0,
0.4606221914291382,
0.3286162316799164
],
[... | [
0,
0,
0,
0,
0
] |
def get_max_triples(n: int) -> int:
"""
You are given a positive integer n. You have to create an integer array a of length n.
For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
and a[i] + a[j] + a[k] is a multipl... | [
[
0,
0.7310585975646973,
0.5944256782531738,
0.6051740646362305,
0.4103638231754303
],
[
0,
0,
0.5944256782531738,
0.6051740646362305,
0.4103638231754303
],
[
0,
0,
0,
0.4875003695487976,
0.3433433473110199
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def median(l: List[int]) -> float:
"""Return median of elements in the list l.
>>> median([3, 1, 2, 4, 5])
3
>>> median([-10, 4, 6, 1000, 10, 20])
15.0
"""
| [
[
0,
0.7310585975646973,
0.5946719646453857,
0.6052678227424622,
0.41008877754211426
],
[
0,
0,
0.5946719646453857,
0.6052678227424622,
0.41008877754211426
],
[
0.5946719646453857,
0.5946719646453857,
0,
0.4880213737487793,
0.34358930587768555
],... | [
0,
0,
0,
0,
0
] |
def prime_length(string: str) -> bool:
"""Write a function that takes a string and returns True if the string
length is a prime number or False otherwise
Examples
>>> prime_length('Hello')
True
>>> prime_length('abcdcba')
True
>>> prime_length('kittens')
True
>>> prime_length('or... | [
[
0,
0.7310585975646973,
0.5525911450386047,
0.577632486820221,
0.3805767893791199
],
[
0,
0,
0.5525911450386047,
0.577632486820221,
0.3805767893791199
],
[
0,
0,
0,
0.441745400428772,
0.3195730447769165
],
[
0,
0,
0.441745400428772... | [
0,
0,
0,
0,
0
] |
from typing import List
def smallest_change(arr: List[int]) -> int:
"""
Given an array arr of integers, find the minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change ... | [
[
0,
0.7310585975646973,
0.5607568025588989,
0.5854937434196472,
0.3861747980117798
],
[
0,
0,
0.5607568025588989,
0.5854937434196472,
0.3861747980117798
],
[
0,
0,
0,
0.45194128155708313,
0.32377132773399353
],
[
0,
0,
0.4519412815... | [
0,
0,
0,
0,
0
] |
from typing import List
def sum_squares(lst: List[float]) -> int:
"""You are given a list of numbers.
You need to return the sum of squared numbers in the given list,
round each element in the list to the upper int(Ceiling) first.
Examples:
>>> lst([1.0, 2.0, 3.0])
14
>>> lst([1.0, 4.0, 9.0... | [
[
0,
0.7310585975646973,
0.5927611589431763,
0.6043702363967896,
0.4082050025463104
],
[
0.7310585975646973,
0,
0.5927611589431763,
0.6043702363967896,
0.4082050025463104
],
[
0,
0,
0,
0.48609086871147156,
0.34212741255760193
],
[
0,
0,... | [
0,
0,
0,
0,
0
] |
def file_name_check(file_name: str) -> str:
"""Create a function which takes a string representing a file's name, and returns
'Yes' if the the file's name is valid, and returns 'No' otherwise.
A file's name is considered to be valid if and only if all the following conditions
are met:
- There shoul... | [
[
0,
0.7310585975646973,
0.5367625951766968,
0.5601611137390137,
0.3666885495185852
],
[
0.7310585975646973,
0,
0.5367625951766968,
0.5601611137390137,
0.3666885495185852
],
[
0.5367625951766968,
0,
0,
0.42275285720825195,
0.31159472465515137
],
... | [
0,
0,
0,
0,
0
] |
from typing import List
def triples_sum_to_zero(l: List[int]) -> bool:
"""
triples_sum_to_zero takes a list of integers as an input.
it returns True if there are three distinct elements in the list that
sum to zero, and False otherwise.
>>> triples_sum_to_zero([1, 3, 5, 0])
False
>>> tripl... | [
[
0,
0.7310585975646973,
0.6003603935241699,
0.6084508299827576,
0.4136900007724762
],
[
0,
0,
0.6003603935241699,
0.6084508299827576,
0.4136900007724762
],
[
0,
0,
0,
0.4944375157356262,
0.34717974066734314
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import Tuple
def intersection(interval1: Tuple[int, int], interval2: Tuple[int, int]) -> str:
"""You are given two intervals,
where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
The given intervals are closed which means that the interval (start, end)
i... | [
[
0,
0.7310585975646973,
0.5897165536880493,
0.602515697479248,
0.4074074923992157
],
[
0,
0,
0.5897165536880493,
0.602515697479248,
0.4074074923992157
],
[
0,
0.5897165536880493,
0,
0.4822452664375305,
0.3404625654220581
],
[
0,
0.6025... | [
0,
0,
0,
0,
0
] |
from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace ... | [
[
0,
0.7310585975646973,
0.5544047355651855,
0.5752745866775513,
0.3808407783508301
],
[
0,
0,
0.5544047355651855,
0.5752745866775513,
0.3808407783508301
],
[
0,
0,
0,
0.44170063734054565,
0.3204469382762909
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
1
] |
from typing import List
def compare(game: List[int], guess: List[int]) -> List[int]:
"""I think we all remember that feeling when the result of some long-awaited
event is finally known. The feelings and thoughts you have at that moment are
definitely worth noting down and comparing.
Your task is to det... | [
[
0,
0.7310585975646973,
0.5794734358787537,
0.5967720746994019,
0.40049445629119873
],
[
0,
0,
0.5794734358787537,
0.5967720746994019,
0.40049445629119873
],
[
0.5794734358787537,
0.5794734358787537,
0,
0.47115597128868103,
0.3342715799808502
],... | [
0,
0,
0,
0,
0
] |
def valid_date(date: str) -> bool:
"""You have to write a function which validates a given date string and
returns True if the date is valid otherwise False.
The date is valid if all of the following rules are satisfied:
1. The date string is not empty.
2. The number of days is not less than 1 or hi... | [
[
0,
0.7310585975646973,
0.5504218935966492,
0.5763934850692749,
0.37874263525009155
],
[
0,
0,
0.5504218935966492,
0.5763934850692749,
0.37874263525009155
],
[
0,
0,
0,
0.4397432804107666,
0.3184210956096649
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def count_nums(arr: List[int]) -> int:
"""
Write a function count_nums which takes an array of integers and returns
the number of elements which has a sum of digits > 0.
If a number is negative, then its first signed digit will be negative:
e.g. -123 has signed digits -1, 2,... | [
[
0,
0.7310585975646973,
0.5882293581962585,
0.6017311811447144,
0.40599164366722107
],
[
0,
0,
0.5882293581962585,
0.6017311811447144,
0.40599164366722107
],
[
0.5882293581962585,
0.5882293581962585,
0,
0.48079735040664673,
0.3394944667816162
],... | [
0,
0,
1,
0,
0
] |
def anti_shuffle(s: str) -> str:
"""
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arranged in
ascending order based on ascii value.
Note: ... | [
[
0,
0.7310585975646973,
0.5233182907104492,
0.5444914102554321,
0.3545159101486206
],
[
0.7310585975646973,
0,
0.5233182907104492,
0.5444914102554321,
0.3545159101486206
],
[
0.5233182907104492,
0,
0,
0.40762990713119507,
0.30532315373420715
],
... | [
1,
1,
1,
1,
1
] |
def is_palindrome(text: str) -> bool:
"""
Checks if given string is a palindrome
>>> is_palindrome('')
True
>>> is_palindrome('aba')
True
>>> is_palindrome('aaaaa')
True
>>> is_palindrome('zbcd')
False
"""
| [
[
0,
0.7310585975646973,
0.5350460410118103,
0.5581983327865601,
0.36524850130081177
],
[
0,
0,
0.5350460410118103,
0.5581983327865601,
0.36524850130081177
],
[
0,
0.5350460410118103,
0,
0.42073771357536316,
0.310791552066803
],
[
0,
0,... | [
0,
0,
0,
0,
0
] |
def is_prime(n: int) -> bool:
"""Return true if a given number is prime, and false otherwise.
>>> is_prime(6)
False
>>> is_prime(101)
True
>>> is_prime(11)
True
>>> is_prime(13441)
True
>>> is_prime(61)
True
>>> is_prime(4)
False
>>> is_prime(1)
False
"""
| [
[
0,
0.7310585975646973,
0.5840052366256714,
0.5993255972862244,
0.4039573073387146
],
[
0,
0,
0.5840052366256714,
0.5993255972862244,
0.4039573073387146
],
[
0,
0.5840052366256714,
0,
0.4758242964744568,
0.3369399607181549
],
[
0,
0,
... | [
0,
0,
0,
0,
0
] |
def simplify(x: str, n: str) -> bool:
"""Your task is to implement a function that will simplify the expression
x * n. The function returns True if x * n evaluates to a whole number and False
otherwise. Both x and n, are string representation of a fraction, and have the following format,
<numerator>/<de... | [
[
0,
0.7310585975646973,
0.5647356510162354,
0.5882095098495483,
0.39063894748687744
],
[
0.7310585975646973,
0,
0.5647356510162354,
0.5882095098495483,
0.39063894748687744
],
[
0,
0.5647356510162354,
0,
0.45566317439079285,
0.3260744512081146
],... | [
0,
1,
1,
0,
1
] |
def hex_key(num: str) -> int:
"""You have been tasked to write a function that receives
a hexadecimal number as a string and counts the number of hexadecimal
digits that are primes (prime number, or a prime, is a natural number
greater than 1 that is not a product of two smaller natural numbers).
... | [
[
0,
0.7310585975646973,
0.5604940056800842,
0.5849973559379578,
0.38658392429351807
],
[
0,
0,
0.5604940056800842,
0.5849973559379578,
0.38658392429351807
],
[
0,
0.5604940056800842,
0,
0.4512520134449005,
0.3237161338329315
],
[
0,
0,... | [
0,
0,
0,
0,
0
] |
def words_in_sentence(sentence: str) -> str:
"""
You are given a string representing a sentence,
the sentence contains some words separated by a space,
and you have to return a string that contains the words from the original sentence,
whose lengths are prime numbers,
the order of the words in t... | [
[
0,
0.7310585975646973,
0.5317237377166748,
0.5525836944580078,
0.3620990514755249
],
[
0,
0,
0.5317237377166748,
0.5525836944580078,
0.3620990514755249
],
[
0,
0,
0,
0.4160088002681732,
0.30922770500183105
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
1
] |
from typing import Dict
def histogram(test: str) -> Dict[str, int]:
"""Given a string representing a space separated lowercase letters, return a dictionary
of the letter with the most repetition and containing the corresponding count.
If several letters have the same occurrence, return all of them.
... | [
[
0,
0.7310585975646973,
0.541121244430542,
0.5618743896484375,
0.3701690435409546
],
[
0.7310585975646973,
0,
0.541121244430542,
0.5618743896484375,
0.3701690435409546
],
[
0,
0,
0,
0.4261249005794525,
0.3137488067150116
],
[
0,
0,
... | [
0,
0,
0,
0,
1
] |
from typing import List, Tuple
def get_row(lst: List[List[int]], x: int) -> List[Tuple[int, int]]:
"""
You are given a 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find inte... | [
[
0,
0.7310585975646973,
0.5786038637161255,
0.596193790435791,
0.3996194005012512
],
[
0.7310585975646973,
0,
0.5786038637161255,
0.596193790435791,
0.3996194005012512
],
[
0,
0,
0,
0.4703744053840637,
0.33384689688682556
],
[
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def get_odd_collatz(n: int) -> List[int]:
"""
Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
as follows: start with any positive integer n. The... | [
[
0,
0.7310585975646973,
0.5756554007530212,
0.5936579704284668,
0.3975965082645416
],
[
0,
0,
0.5756554007530212,
0.5936579704284668,
0.3975965082645416
],
[
0,
0.5756554007530212,
0,
0.4665448069572449,
0.33204394578933716
],
[
0,
0.5... | [
0,
0,
0,
0,
1
] |
from typing import List
def can_arrange(arr: List[int]) -> int:
"""Create a function which returns the largest index of an element which
is not greater than or equal to the element immediately preceding it. If
no such element exists then return -1. The given array will not contain
duplicate values.
... | [
[
0,
0.7310585975646973,
0.584736704826355,
0.5996635556221008,
0.40427571535110474
],
[
0,
0,
0.584736704826355,
0.5996635556221008,
0.40427571535110474
],
[
0,
0,
0,
0.4767422676086426,
0.3374970853328705
],
[
0,
0.5996635556221008,
... | [
0,
0,
1,
0,
0
] |
def sort_numbers(numbers: str) -> str:
""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
Return the string with numbers sorted from smallest to largest
>>> sort_numbers('three one... | [
[
0,
0.7310585975646973,
0.5776221752166748,
0.5956207513809204,
0.3992435932159424
],
[
0,
0,
0.5776221752166748,
0.5956207513809204,
0.3992435932159424
],
[
0,
0,
0,
0.4692132771015167,
0.3333052098751068
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List
def sum_squares(lst: List[int]) -> int:
""""
This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a
multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3.... | [
[
0,
0.7310585975646973,
0.5936618447303772,
0.6048485040664673,
0.4089498817920685
],
[
0,
0,
0.5936618447303772,
0.6048485040664673,
0.4089498817920685
],
[
0,
0,
0,
0.48703962564468384,
0.3427361249923706
],
[
0,
0,
0.48703962564... | [
0,
0,
0,
0,
1
] |
from typing import List
def skjkasdkd(lst: List[int]) -> int:
"""You are given a list of integers.
You need to find the largest prime value and return the sum of its digits.
Examples:
>>> skjkasdkd([0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3])
10
>>> skjkasdkd([1, ... | [
[
0,
0.7310585975646973,
0.5802977085113525,
0.5972254276275635,
0.40067994594573975
],
[
0,
0,
0.5802977085113525,
0.5972254276275635,
0.40067994594573975
],
[
0,
0.5802977085113525,
0,
0.47220709919929504,
0.3347657322883606
],
[
0,
0... | [
0,
0,
0,
0,
0
] |
from typing import List, Tuple
def sum_product(numbers: List[int]) -> Tuple[int, int]:
""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
Empty sum should be equal to 0 and empty product should be equal to 1.
>>> sum_product([])
(0, 1)
... | [
[
0,
0.7310585975646973,
0.6062941551208496,
0.6117088198661804,
0.4172549247741699
],
[
0,
0,
0.6062941551208496,
0.6117088198661804,
0.4172549247741699
],
[
0,
0,
0,
0.501312255859375,
0.3510749042034149
],
[
0,
0,
0.5013122558593... | [
0,
0,
0,
0,
1
] |
def choose_num(x: int, y: int) -> int:
"""This function takes two positive numbers x and y and returns the
biggest even integer number that is in the range [x, y] inclusive. If
there's no such number, then the function should return -1.
For example:
>>> choose_num(12, 15)
14
>>> choose_num... | [
[
0,
0.7310585975646973,
0.5862179398536682,
0.6005951762199402,
0.40520885586738586
],
[
0,
0,
0.5862179398536682,
0.6005951762199402,
0.40520885586738586
],
[
0,
0,
0,
0.47833430767059326,
0.3382611870765686
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
1
] |
from typing import List, Tuple, Optional
def largest_smallest_integers(lst: List[int]) -> Tuple[Optional[int], Optional[int]]:
"""
Create a function that returns a tuple (a, b), where 'a' is
the largest of negative integers, and 'b' is the smallest
of positive integers in a list.
If there is no neg... | [
[
0,
0.7310585975646973,
0.6037754416465759,
0.6103050112724304,
0.4158819019794464
],
[
0.7310585975646973,
0,
0.6037754416465759,
0.6103050112724304,
0.4158819019794464
],
[
0,
0,
0,
0.49832046031951904,
0.34943071007728577
],
[
0,
0,... | [
0,
0,
0,
0,
0
] |
def count_distinct_characters(string: str) -> int:
""" Given a string, find out how many distinct characters (regardless of case) does it consist of
>>> count_distinct_characters('xyzXYZ')
3
>>> count_distinct_characters('Jerry')
4
"""
| [
[
0,
0.7310585975646973,
0.538064181804657,
0.5617998242378235,
0.36745497584342957
],
[
0.7310585975646973,
0,
0.538064181804657,
0.5617998242378235,
0.36745497584342957
],
[
0,
0,
0,
0.4245395064353943,
0.3121894896030426
],
[
0,
0,
... | [
0,
0,
0,
0,
1
] |
from typing import List
def make_a_pile(n: int) -> List[int]:
"""
Given a positive integer n, you have to make a pile of n levels of stones.
The first level has n stones.
The number of stones in the next level is:
- the next odd number if n is odd.
- the next even number if n is even.
... | [
[
0,
0.7310585975646973,
0.5898783802986145,
0.6026273965835571,
0.40741705894470215
],
[
0,
0,
0.5898783802986145,
0.6026273965835571,
0.40741705894470215
],
[
0,
0,
0,
0.4824644923210144,
0.3405419886112213
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
from typing import List, Optional
def prod_signs(arr: List[int]) -> Optional[int]:
"""
You are given an array arr of integers and you need to return
sum of magnitudes of integers multiplied by product of all signs
of each number in the array, represented by 1, -1 or 0.
Note: return None for empty a... | [
[
0,
0.7310585975646973,
0.5830348134040833,
0.5987851023674011,
0.4025266170501709
],
[
0,
0,
0.5830348134040833,
0.5987851023674011,
0.4025266170501709
],
[
0,
0,
0,
0.4751497805118561,
0.33637896180152893
],
[
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0
] |
AGP-Training is the dataset for training Adaptive Graph Pruning (AGP). We open-source our training set so that you can reproduce our work.
For further usage, please refer to our repository
If you find AGP helpful in your research, please consider citing:
@article{li2025adaptive,
title={Adaptive Graph Pruning for Multi-Agent Communication},
author={Li, Boyi and Zhao, Zhonghan and Lee, Der-Horng and Wang, Gaoang},
journal={arXiv preprint arXiv:2506.02951},
year={2025}
}