problem_id int64 175 4.97k | instruction_seed stringlengths 90 4.89k | solutions stringlengths 199 48.4k | input_output stringlengths 0 505k | difficulty stringclasses 3
values | url stringlengths 43 77 | starter_code stringlengths 0 103 | _source stringclasses 1
value | _fasttext_score float64 0.99 1 |
|---|---|---|---|---|---|---|---|---|
4,656 | # Task
Christmas is coming. In the [previous kata](https://www.codewars.com/kata/5a405ba4e1ce0e1d7800012e), we build a custom Christmas tree with the specified characters and the specified height.
Now, we are interested in the center of the Christmas tree.
Please imagine that we build a Christmas tree with `chars =... | ["def center_of(chars):\n if not chars:\n return \"\"\n total=0\n res=[]\n for i in range(1,len(chars)*2+1): \n if i%2==1:\n res.append((i+1)//2+total)\n res[-1]=chars[(res[-1]-1)%len(chars)]\n total+=i\n res=\"\".join(res)\n for i in range(len(res)//2+... | {"fn_name": "center_of", "inputs": [[""], ["a"], ["ab"], ["abc"], ["abab"], ["abcde"], ["aaaaaaaaaaaaaa"], ["abaabaaab"], ["dbdbebedbddbedededeeddbbdeddbeddeebdeddeebbbb"], ["vttussvutvuvvtustsvsvtvu"]], "outputs": [[""], ["a"], ["a"], ["aba"], ["a"], ["aecea"], ["a"], ["aba"], ["deededebddeebeddeddeddbddeddeddebeeddbe... | introductory | https://www.codewars.com/kata/5a4076f3e1ce0ee6d4000010 |
def center_of(chars):
| codeparrot/apps | 0.999992 |
4,177 | # Scenario
*Now that the competition gets tough it will* **_Sort out the men from the boys_** .
**_Men_** are the **_Even numbers_** and **_Boys_** are the **_odd_**  
___
# Task
**_Given_** an *array/list [] of n integers* , **_Se... | ["def men_from_boys(arr):\n men = []\n boys = []\n for i in sorted(set(arr)):\n if i % 2 == 0:\n men.append(i)\n else:\n boys.append(i)\n return men + boys[::-1]", "def men_from_boys(arr):\n return sorted(set(arr), key=lambda n: (n%2, n * (-1)**(n%2)))", "def men_from_... | {"fn_name": "men_from_boys", "inputs": [[[7, 3, 14, 17]], [[2, 43, 95, 90, 37]], [[20, 33, 50, 34, 43, 46]], [[82, 91, 72, 76, 76, 100, 85]], [[2, 15, 17, 15, 2, 10, 10, 17, 1, 1]], [[-32, -39, -35, -41]], [[-64, -71, -63, -66, -65]], [[-94, -99, -100, -99, -96, -99]], [[-53, -26, -53, -27, -49, -51, -14]], [[-17, -45,... | introductory | https://www.codewars.com/kata/5af15a37de4c7f223e00012d |
def men_from_boys(arr):
| codeparrot/apps | 0.999916 |
4,965 | Your task in this kata is to implement a function that calculates the sum of the integers inside a string. For example, in the string "The30quick20brown10f0x1203jumps914ov3r1349the102l4zy dog", the sum of the integers is 3635.
*Note: only positive integers will be tested.* | ["import re\n\ndef sum_of_integers_in_string(s):\n return sum(int(x) for x in re.findall(r\"(\\d+)\", s))", "import re\n\ndef sum_of_integers_in_string(s):\n return sum(map(int, re.findall(\"\\d+\", s)))", "import re\n\ndef sum_of_integers_in_string(s):\n return sum(int(i) for i in re.findall('\\d+', s))\n", "de... | {"fn_name": "sum_of_integers_in_string", "inputs": [], "outputs": []} | introductory | https://www.codewars.com/kata/598f76a44f613e0e0b000026 |
def sum_of_integers_in_string(s):
| codeparrot/apps | 0.999843 |
4,280 | Determine the **area** of the largest square that can fit inside a circle with radius *r*. | ["def area_largest_square(r):\n return 2 * r ** 2", "def area_largest_square(r):\n return 2 * r * r", "def area_largest_square(r):\n return r*r*2", "area_largest_square = lambda r: r*(r+r)", "area_largest_square = lambda r: r*r*2", "def area_largest_square(r):\n return r ** 2 * 2", "area_largest_square = lam... | {"fn_name": "area_largest_square", "inputs": [[5], [7], [50]], "outputs": [[50], [98], [5000]]} | introductory | https://www.codewars.com/kata/5887a6fe0cfe64850800161c |
def area_largest_square(r):
| codeparrot/apps | 0.99976 |
4,093 | In an infinite array with two rows, the numbers in the top row are denoted
`. . . , A[β2], A[β1], A[0], A[1], A[2], . . .`
and the numbers in the bottom row are denoted
`. . . , B[β2], B[β1], B[0], B[1], B[2], . . .`
For each integer `k`, the entry `A[k]` is directly above
the entry `B[k]` in the array, as shown:
... | ["def find_a(lst,n):\n if n<0: return find_a(lst[::-1], 3-n)\n if n<4: return lst[n]\n a,b,c,d = lst\n for _ in range(n-3):\n a,b,c,d = b, c, d, 6*d-10*c+6*b-a\n return d", "def find_a(A, n):\n if 0 <= n < 4: return A[n]\n if n < 0:\n A, n = A[::-1], abs(n) + 3\n B = [0] * 4\n B... | {"fn_name": "find_a", "inputs": [[[1, 2, 3, 4], 2], [[38, 200, -18, 45], 1], [[1, 0, 0, 1], 5], [[0, 2, 0, 3], -2], [[-20, 1, -3, 14], -5], [[1, 2, 3, 5], 100], [[0, 4, 6, 13], 100]], "outputs": [[3], [200], [20], [-126], [-44402], [60560100487003612846322657690093088848428068520476594299], [335254562473098582210532865... | introductory | https://www.codewars.com/kata/5d1eb2db874bdf9bf6a4b2aa |
def find_a(array, n):
| codeparrot/apps | 0.99973 |
3,221 | Given an array of integers, find the one that appears an odd number of times.
There will always be only one integer that appears an odd number of times. | ["def find_it(seq):\n for i in seq:\n if seq.count(i)%2!=0:\n return i", "def find_it(seq):\n counts = dict()\n for n in seq:\n if n not in counts:\n counts[n] = 0\n \n counts[n] += 1\n \n for n, n_count in list(counts.items()):\n if n_count % ... | {"fn_name": "find_it", "inputs": [[[20, 1, -1, 2, -2, 3, 3, 5, 5, 1, 2, 4, 20, 4, -1, -2, 5]], [[1, 1, 2, -2, 5, 2, 4, 4, -1, -2, 5]], [[20, 1, 1, 2, 2, 3, 3, 5, 5, 4, 20, 4, 5]], [[10]], [[1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1]]], "outputs": [[5], [-1], [5], [10], [10]]} | introductory | https://www.codewars.com/kata/54da5a58ea159efa38000836 |
def find_it(seq):
| codeparrot/apps | 0.999645 |
4,104 | # Task
**_Given_** an *array/list [] of n integers* , *find maximum triplet sum in the array* **_Without duplications_** .
___
# Notes :
* **_Array/list_** size is *at least 3* .
* **_Array/list_** numbers could be a *mixture of positives , negatives and zeros* .
* **_Repetition_** of numbers in *the array/list ... | ["def max_tri_sum(numbers):\n return sum(sorted(set(numbers))[-3:])", "from heapq import nlargest\n\ndef max_tri_sum(numbers):\n return sum(nlargest(3, set(numbers)))", "def max_tri_sum(n):\n return sum(sorted(set(n))[-3:])", "def max_tri_sum(nums): return sum(sorted(set(nums))[-3:])\n", "max_tri_sum=lambda l:... | {"fn_name": "max_tri_sum", "inputs": [[[3, 2, 6, 8, 2, 3]], [[2, 9, 13, 10, 5, 2, 9, 5]], [[2, 1, 8, 0, 6, 4, 8, 6, 2, 4]], [[-3, -27, -4, -2, -27, -2]], [[-14, -12, -7, -42, -809, -14, -12]], [[-13, -50, 57, 13, 67, -13, 57, 108, 67]], [[-7, 12, -7, 29, -5, 0, -7, 0, 0, 29]], [[-2, 0, 2]], [[-2, -4, 0, -9, 2]], [[-5, ... | introductory | https://www.codewars.com/kata/5aa1bcda373c2eb596000112 |
def max_tri_sum(numbers):
| codeparrot/apps | 0.99964 |
3,557 | Given a number **n**, return the number of positive odd numbers below **n**, EASY!
Expect large Inputs! | ["def odd_count(n):\n return len(range(1, n, 2))", "def odd_count(n):\n if n < 1:\n return 0\n\n return int(n / 2)\n \n", "def odd_count(n):\n #Return number of positive odd numbers below N\n #Find numbers below N -> Add +1 to count \n #More of a math problem\n #Try to find a way besides ... | {"fn_name": "odd_count", "inputs": [[15], [15023]], "outputs": [[7], [7511]]} | introductory | https://www.codewars.com/kata/59342039eb450e39970000a6 |
def odd_count(n):
| codeparrot/apps | 0.99949 |
4,519 | # Task
**_Given_** *a number* , **_Return_** **_The Maximum number _** *could be formed from the digits of the number given* .
___
# Notes
* **_Only Natural numbers_** *passed to the function , numbers Contain digits [0:9] inclusive*
* **_Digit Duplications_** *could occur* , So also **_consider it when formin... | ["def max_number(n):\n return int(''.join(sorted(str(n), reverse=True)))", "max_number = lambda n: int(\"\".join(sorted(str(n)))[::-1])", "def max_number(n):\n n = \"\".join(sorted(str(n), reverse=True))\n return int(n)", "max_number= lambda n : int(''.join(sorted(list(str(n)),reverse=True)))\n", "max_number=... | {"fn_name": "max_number", "inputs": [[213], [7389], [63792], [566797], [1000000]], "outputs": [[321], [9873], [97632], [977665], [1000000]]} | introductory | https://www.codewars.com/kata/5a4ea304b3bfa89a9900008e |
def max_number(n):
| codeparrot/apps | 0.99926 |
4,285 | Given an array of 4 integers
```[a,b,c,d]``` representing two points ```(a, b)``` and ```(c, d)```, return a string representation of the slope of the line joining these two points.
For an undefined slope (division by 0), return ```undefined``` . Note that the "undefined" is case-sensitive.
```
a:x1
b:y1
... | ["def find_slope(points):\n x1, y1, x2, y2 = points\n if x2 - x1 == 0:\n return \"undefined\"\n return str((y2 - y1) // (x2 - x1))", "def find_slope(points):\n x1, y1, x2, y2 = points\n dx = x2 - x1\n dy = y2 - y1\n if dx != 0:\n return str(int(dy / dx))\n else:\n return 'un... | {"fn_name": "find_slope", "inputs": [[[12, -18, -15, -18]], [[3, -20, 5, 8]], [[17, -3, 17, 8]], [[1, -19, -2, -7]], [[19, 3, 20, 3]], [[6, -12, 15, -3]], [[15, -3, 15, -3]], [[9, 3, 19, -17]], [[3, 6, 4, 10]], [[2, 7, 4, -7]], [[1, 24, 2, 88]], [[4, 384, 8, 768]], [[4, 16, 4, 18]], [[7, 28, 9, 64]], [[18, -36, 12, 36]... | introductory | https://www.codewars.com/kata/55a75e2d0803fea18f00009d |
def find_slope(points):
| codeparrot/apps | 0.999258 |
4,207 | Write a function that takes a positive integer n, sums all the cubed values from 1 to n, and returns that sum.
Assume that the input n will always be a positive integer.
Examples:
```python
sum_cubes(2)
> 9
# sum of the cubes of 1 and 2 is 1 + 8
``` | ["def sum_cubes(n):\n return sum(i**3 for i in range(0,n+1))", "def sum_cubes(n):\n return (n*(n+1)/2)**2", "def sum_cubes(n):\n return sum(x ** 3 for x in range(n+1))", "def sum_cubes(n):\n return (n*(n+1)//2)**2", "def sum_cubes(n):\n return sum([i**3 for i in range(1,n+1)])", "def sum_cubes(n):\n r... | {"fn_name": "sum_cubes", "inputs": [[1], [2], [3], [4], [10], [123]], "outputs": [[1], [9], [36], [100], [3025], [58155876]]} | introductory | https://www.codewars.com/kata/59a8570b570190d313000037 |
def sum_cubes(n):
| codeparrot/apps | 0.999199 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 5