task_type stringclasses 1
value | problem stringlengths 209 3.39k | answer stringlengths 35 6.15k | problem_tokens int64 60 774 | answer_tokens int64 12 2.04k |
|---|---|---|---|---|
coding | Solve the programming task below in a Python markdown code block.
The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following n days. According to the bear's data, on the i-th (1 ≤ i ≤ n) day, the price for one barrel of... | {"inputs": ["2 0\n2 1\n", "2 5\n5 4\n", "2 0\n2 1\n", "2 5\n5 4\n", "2 2\n7 0\n", "2 5\n5 5\n", "2 5\n7 5\n", "2 2\n7 5\n"], "outputs": ["1\n", "0\n", "1\n", "0\n", "5\n", "0\n", "0\n", "0\n"]} | 609 | 118 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an integer array rolls of length n and an integer k. You roll a k sided dice numbered from 1 to k, n times, where the result of the ith roll is rolls[i].
Return the length of the shortest sequence of rol... | {"functional": "def check(candidate):\n assert candidate(rolls = [4,2,1,2,3,3,2,4,1], k = 4) == 3\n assert candidate(rolls = [1,1,2,2], k = 2) == 2\n assert candidate(rolls = [1,1,3,2,2,2,3,3], k = 4) == 1\n\n\ncheck(Solution().shortestSequence)"} | 133 | 110 |
coding | Solve the programming task below in a Python markdown code block.
In this kata we want to convert a string into an integer. The strings simply represent the numbers in words.
Examples:
* "one" => 1
* "twenty" => 20
* "two hundred forty-six" => 246
* "seven hundred eighty-three thousand nine hundred and nineteen" => 7... | {"functional": "_inputs = [['zero'], ['one'], ['two'], ['three'], ['four'], ['five'], ['six'], ['seven'], ['eight'], ['nine'], ['ten'], ['twenty'], ['twenty-one'], ['thirty-seven'], ['forty-six'], ['fifty-nine'], ['sixty-eight'], ['seventy-two'], ['eighty-three'], ['ninety-four'], ['one hundred'], ['one hundred one'], ... | 190 | 565 |
coding | Solve the programming task below in a Python markdown code block.
Let's suppose you have an array a, a stack s (initially empty) and an array b (also initially empty).
You may perform the following operations until both a and s are empty:
Take the first element of a, push it into s and remove it from a (if a is not... | {"inputs": ["5 1\n3\n", "2 1\n1\n", "2 1\n1\n", "9 1\n6\n", "7 1\n1\n", "5 1\n3\n", "10 1\n6\n", "10 1\n1\n"], "outputs": ["3 2 1 5 4 ", "1 2 ", "1 2 ", "6 5 4 3 2 1 9 8 7 ", "1 7 6 5 4 3 2 ", "3 2 1 5 4 ", "6 5 4 3 2 1 10 9 8 7 ", "1 10 9 8 7 6 5 4 3 2 "]} | 682 | 183 |
coding | Solve the programming task below in a Python markdown code block.
Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.
- Let s' be the concatenation of 10^{100} copies of s. t is a sub... | {"inputs": ["d\nd\n", "j\nw\n", "zv\nz\n", "jh\nh\n", "l\nll\n", "s\nsv\n", "csnteot\nson", "vtaletn\ntnn"], "outputs": ["1\n", "-1\n", "1\n", "2\n", "2\n", "-1\n", "10\n", "14\n"]} | 365 | 93 |
coding | Solve the programming task below in a Python markdown code block.
You are given a square grid with $n$ rows and $n$ columns, where each cell has a non-negative integer written in it. There is a chip initially placed at the top left cell (the cell with coordinates $(1, 1)$). You need to move the chip to the bottom right... | {"inputs": ["2\n1 2\n3 4\n", "3\n10 10 10\n10 0 10\n10 10 10\n", "3\n0 0 1000000000\n0 1000000000 0\n1000000000 0 0\n", "3\n167301 677798 614819\n732414 586919 7990\n768516 777873 977915\n", "4\n0 0 0 1000000000\n0 0 1000000000 0\n0 1000000000 0 0\n1000000000 0 0 0\n", "3\n1000000000 1000000000 1\n1000000000 1 10000000... | 501 | 596 |
coding | Solve the programming task below in a Python markdown code block.
You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute of the movie. By pressing this button, you watch the current minute of the movie and the player automatically proceeds to the next ... | {"inputs": ["1 1\n1 1\n", "1 3\n5 6\n", "1 2\n1 1\n", "1 1\n1 1\n", "1 3\n5 6\n", "1 2\n1 1\n", "1 3\n3 6\n", "1 4\n3 6\n"], "outputs": ["1\n", "3\n", "1\n", "1\n", "3\n", "1\n", "6\n", "6\n"]} | 593 | 118 |
coding | Solve the programming task below in a Python markdown code block.
Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows: $f(0) = a$; ... | {"inputs": ["1\n1 2 3\n", "1\n1 2 3\n", "1\n1 3 3\n", "1\n1 3 4\n", "1\n1 0 4\n", "1\n6 3 5\n", "1\n1 3 6\n", "1\n1 0 7\n"], "outputs": ["1\n", "1\n", "1\n", "3\n", "0\n", "5\n", "1\n", "0\n"]} | 335 | 118 |
coding | Solve the programming task below in a Python markdown code block.
There are $n$ models in the shop numbered from $1$ to $n$, with sizes $s_1, s_2, \ldots, s_n$.
Orac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes).
Orac thinks that the obtained arrang... | {"inputs": ["4\n4\n5 3 4 6\n7\n1 4 2 3 6 4 9\n5\n5 4 3 2 1\n1\n9\n", "4\n4\n5 3 4 6\n7\n1 4 2 3 6 4 9\n5\n5 4 6 2 1\n1\n9\n", "4\n4\n5 3 4 6\n7\n1 4 2 3 6 4 9\n5\n5 5 6 2 1\n1\n9\n", "4\n4\n5 3 4 6\n7\n1 4 2 1 6 4 9\n5\n5 4 6 2 1\n1\n9\n", "4\n4\n5 3 4 6\n7\n1 4 2 3 6 4 9\n5\n5 4 3 2 1\n1\n9\n", "4\n4\n6 6 3 6\n7\n1 4 ... | 618 | 457 |
coding | Solve the programming task below in a Python markdown code block.
Your job at E-Corp is both boring and difficult. It isn't made any easier by the fact that everyone constantly wants to have a meeting with you, and that the meeting rooms are always taken!
In this kata, you will be given an array. Each value represents... | {"functional": "_inputs = [[['X', 'O', 'X']], [['O', 'X', 'X', 'X', 'X']], [['X', 'X', 'O', 'X', 'X']], [['X']]]\n_outputs = [[1], [0], [2], ['None available!']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)... | 187 | 206 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.
You are given a string $S$ with length $N$. Determine if it is possible to find two non-empty strings $A$ and $B$ which satisfy the following condit... | {"inputs": ["5\n6\ncabdab\n21\nyourcrushlovesyouback\n16\nwubbalubbadubdub\n5\nsplit\n7\nsplitit"], "outputs": ["YES\nNO\nYES\nNO\nYES"]} | 553 | 58 |
coding | Solve the programming task below in a Python markdown code block.
Most of the time when rounding a given number, it is customary to round to some multiple of a power of 10. However, there is no reason why we cannot use another multiple to do our rounding to. For example, you could round to the nearest multiple of 7, or... | {"inputs": ["26\n5 10\n4 10\n100 3\n123456 7\n49 7\n158854 50\n822992 101\n691238 345\n682373 49\n643378 53\n328697 62\n446656 228\n368684 130\n530193 371\n864163 325\n708578 207\n915093 485\n711860 28\n234554 366\n309089 25\n595700 393\n10 6\n9 19\n4 10\n11 2\n11 3"], "outputs": ["10\n0\n99\n123459\n49\n158850\n822948... | 201 | 379 |
coding | Solve the programming task below in a Python markdown code block.
In mathematics, binomial coefficients are a family of positive integers that occur as coefficients in the binomial theorem.
$\left(\begin{matrix}n\\ k\end{matrix}\right)$
denotes the number of ways of choosing k objects from n different objects.
Howev... | {"inputs": ["3\n2 2\n3 2\n4 3\n"], "outputs": ["1\n0\n1\n"]} | 266 | 30 |
coding | Solve the programming task below in a Python markdown code block.
Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.
Munhattan consists of n streets and m avenues. There is exactly one resta... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "1 1\n1000000000\n", "1 1\n1000000000\n", "3 3\n1 2 3\n2 3 1\n3 1 2\n", "3 3\n0 2 3\n2 3 1\n3 1 2\n", "3 3\n0 2 3\n2 3 1\n5 1 2\n", "3 3\n0 2 3\n2 3 1\n5 1 1\n"], "outputs": ["1\n", "1\n", "1000000000\n", "1000000000\n", "1\n", "1\n", "1\n", "1\n"]} | 450 | 202 |
coding | Solve the programming task below in a Python markdown code block.
You play a computer game. In this game, you lead a party of $m$ heroes, and you have to clear a dungeon with $n$ monsters. Each monster is characterized by its power $a_i$. Each hero is characterized by his power $p_i$ and endurance $s_i$.
The heroes cl... | {"inputs": ["2\n6\n1 3 11 8 1 8\n2\n3 2\n100 1\n5\n0 5 100 3 3\n2\n5 5\n95 1\n", "2\n6\n1 3 11 8 1 8\n2\n3 2\n000 1\n5\n0 5 100 3 3\n2\n5 5\n95 1\n", "2\n6\n3 1 2 3 1 8\n2\n3 2\n000 1\n5\n3 5 100 2 3\n2\n30 5\n90 2\n", "2\n6\n1 3 11 8 1 8\n2\n0 2\n000 1\n5\n0 5 100 3 3\n2\n5 5\n95 1\n", "2\n6\n1 3 11 8 1 8\n2\n3 2\n100... | 728 | 514 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.
A grid is said to be valid if all the cells above the main diagonal are zeros.
Return the minimum number of steps nee... | {"functional": "def check(candidate):\n assert candidate(grid = [[0,0,1],[1,1,0],[1,0,0]]) == 3\n assert candidate(grid = [[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]) == -1\n assert candidate(grid = [[1,0,0],[1,1,0],[1,1,1]]) == 0\n\n\ncheck(Solution().minSwaps)"} | 143 | 118 |
coding | Solve the programming task below in a Python markdown code block.
*** Nova polynomial subtract***
This kata is from a series on polynomial handling. ( [#1](http://www.codewars.com/kata/nova-polynomial-1-add-1) [#2](http://www.codewars.com/kata/570eb07e127ad107270005fe) [#3](http://www.codewars.com/kata/5714041e880... | {"functional": "_inputs = [[[], []], [[1, 2, 3, 4, 5, 6], []], [[], [1, 2, 3, 4, 5, 6]]]\n_outputs = [[[]], [[1, 2, 3, 4, 5, 6]], [[-1, -2, -3, -4, -5, -6]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n ... | 404 | 233 |
coding | Solve the programming task below in a Python markdown code block.
In this task, we would like for you to appreciate the usefulness of the groupby() function of itertools . To read more about this function, Check this out .
You are given a string $\mbox{S}$. Suppose a character '$\textbf{C}$' occurs consecutively $\mbo... | {"inputs": ["1222311\n"], "outputs": ["(1, 1) (3, 2) (1, 3) (2, 1)\n"]} | 312 | 43 |
coding | Solve the programming task below in a Python markdown code block.
Allen wants to enter a fan zone that occupies a round square and has $n$ entrances.
There already is a queue of $a_i$ people in front of the $i$-th entrance. Each entrance allows one person from its queue to enter the fan zone in one minute.
Allen uses... | {"inputs": ["2\n0 1\n", "2\n0 0\n", "2\n3 3\n", "2\n1 0\n", "2\n1 1\n", "2\n1 1\n", "2\n1 0\n", "2\n0 0\n"], "outputs": ["1\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n", "1\n"]} | 724 | 102 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.
A substring is a contiguous (non-empty) sequence of characters within a string.
Note: Due to the la... | {"functional": "def check(candidate):\n assert candidate(word = \"aba\") == 6\n assert candidate(word = \"abc\") == 3\n assert candidate(word = \"ltcd\") == 0\n assert candidate(word = \"noosabasboosa\") == 237\n\n\ncheck(Solution().countVowels)"} | 129 | 77 |
coding | Solve the programming task below in a Python markdown code block.
Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exam... | {"inputs": ["1\n2 1\n", "1\n2 1\n", "1\n4 1\n", "2\n3 2\n3 2\n", "2\n3 1\n3 2\n", "2\n4 2\n4 1\n", "2\n5 2\n5 1\n", "2\n3 1\n3 2\n"], "outputs": ["1\n", "1\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n"]} | 636 | 122 |
coding | Solve the programming task below in a Python markdown code block.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland.... | {"inputs": ["1 1\n*\n", "2 1\n*\n.\n", "2 1\n*\n*\n", "1 1\n*\n.\n", "2 2\n..\n*.\n", "2 2\n*.\n..\n", "2 2\n..\n.*\n", "2 2\n.*\n..\n"], "outputs": ["*\n", "*\n", "*\n*\n", "*\n", "*\n", "*\n", "*\n", "*\n"]} | 340 | 122 |
coding | Solve the programming task below in a Python markdown code block.
The smallest unit of data handled by a computer is called a bit, and the amount of information that represents multiple bits together is called a word. Currently, many computers process one word as 32 bits.
For a computer that represents one word in 32 ... | {"inputs": ["0", "5", "1", "2", "8", "6", "7", "9"], "outputs": ["0\n", "160\n", "32\n", "64\n", "256\n", "192\n", "224\n", "288\n"]} | 153 | 74 |
coding | Solve the programming task below in a Python markdown code block.
1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:
- the dogs numbered 1,2,\cdots,26 were respectively ... | {"inputs": ["1", "4", "3", "6", "9", "7", "5", "8"], "outputs": ["a\n", "d\n", "c\n", "f\n", "i\n", "g\n", "e\n", "h\n"]} | 484 | 62 |
coding | Solve the programming task below in a Python markdown code block.
$m$ chairs are arranged in a circle sequentially. The chairs are numbered from $0$ to $m-1$. $n$ people want to sit in these chairs. The $i$-th of them wants at least $a[i]$ empty chairs both on his right and left side.
More formally, if the $i$-th pers... | {"inputs": ["6\n3 2\n1 1 1\n2 4\n1 1\n2 5\n2 1\n3 8\n1 2 1\n4 12\n1 2 1 3\n4 19\n1 2 1 3\n"], "outputs": ["NO\nYES\nNO\nYES\nNO\nYES\n"]} | 689 | 86 |
coding | Solve the programming task below in a Python markdown code block.
You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.
You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one t... | {"inputs": ["1\n1\n100\n", "1\n100000000\n1\n", "5\n5 4 3 7 3\n7 7 14 57 94\n", "5\n5 4 3 7 3\n7 7 14 45 94\n", "5\n5 8 3 7 3\n7 7 14 45 94\n", "5\n99 65 5 94 25\n1 5 6 2 3\n", "5\n99 65 93 94 17\n1 5 6 2 3\n", "5\n99 65 93 94 25\n1 5 6 2 3\n"], "outputs": ["10\n", "100000000000\n", "89\n", "96\n", "124\n", "12934\n", ... | 586 | 259 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed m x n binary matrix grid.
Let us call a non-empty subset of rows good if the sum of each column of the subset is at most half of the length of the subset.
More formally, if the length of the ... | {"functional": "def check(candidate):\n assert candidate(grid = [[0,1,1,0],[0,0,0,1],[1,1,1,1]]) == [0,1]\n assert candidate(grid = [[0]]) == [0]\n assert candidate(grid = [[1,1,1],[1,1,1]]) == []\n\n\ncheck(Solution().goodSubsetofBinaryMatrix)"} | 200 | 94 |
coding | Solve the programming task below in a Python markdown code block.
You are given a keyboard that consists of $26$ keys. The keys are arranged sequentially in one row in a certain order. Each key corresponds to a unique lowercase Latin letter.
You have to type the word $s$ on this keyboard. It also consists only of lowe... | {"inputs": ["1\nabcdefghilkjmnopqrstuvwxyz\nabdes\n", "1\nabcdefghilkjmnopqrstuvwxyz\nabdes\n", "1\nabcdefyhilkjmnopqrstuvwxgz\nabdes\n", "1\nzhxwvutsrqponmjklihyfedcba\nasdeb\n", "1\nzhxwvutsrqponmjklihyfedcba\naseeb\n", "1\nzhxwvutsrqponmjklihyfedcba\nbbdes\n", "1\nzhxwvutsrqponmjklihyfedcba\nsaeeb\n", "1\nabcdefjhil... | 562 | 189 |
coding | Solve the programming task below in a Python markdown code block.
Taro had his own personal computer and set a password for login. However, Taro inadvertently forgot the password. Then, remembering that there was a piece of paper with the password written down, Taro found the paper and was surprised to see it. The pape... | {"inputs": ["AI[U\n_A", "U[IA\n_A", "U[IA\n^A", "U[HA\n^A", "U[H@\n^A", "U[H@\n^B", "U[H@\nB^", "@H[U\nB^"], "outputs": ["No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | 226 | 98 |
coding | Solve the programming task below in a Python markdown code block.
Striver$Striver$ wants to strive hard in order to reach his goals, hence asks his mentor to give him a question for which he has to strive hard.
The mentor gives Striver$Striver$ a N$N$ X N$N$ matrix consisting of lowercase characters (′a′$'a'$ to ′z′$'... | {"inputs": ["1\n3 2\na b a\na c d\nb a b\n1 3\n3 3"], "outputs": ["1\n2"]} | 582 | 38 |
coding | Solve the programming task below in a Python markdown code block.
It is given a positive integer $n$. In $1$ move, one can select any single digit and remove it (i.e. one selects some position in the number and removes the digit located at this position). The operation cannot be performed if only one digit remains. If ... | {"inputs": ["5\n100\n71345\n3259\n50555\n2050047\n"], "outputs": ["0\n3\n1\n3\n2\n"]} | 538 | 51 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array of unique numbers. The numbers represent points. The higher the number the higher the points.
In the array [1,3,2] 3 is the highest point value so it gets 1st place. 2 is the second highest so it gets second place. 1 is the 3rd h... | {"functional": "_inputs = [[[1, 3, 2]], [[1, 2, 3, 4, 5]], [[3, 4, 1, 2, 5]], [[10, 20, 40, 50, 30]], [[1, 10]], [[22, 33, 18, 9, 110, 4, 1, 88, 6, 50]]]\n_outputs = [[[3, 1, 2]], [[5, 4, 3, 2, 1]], [[3, 2, 5, 4, 1]], [[5, 4, 2, 1, 3]], [[2, 1]], [[5, 4, 6, 7, 1, 9, 10, 2, 8, 3]]]\nimport math\ndef _deep_eq(a, b, tol=1... | 339 | 342 |
coding | Solve the programming task below in a Python markdown code block.
Bob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with t humps, representing them as polylines in the plane. Each polyline consists of n vertice... | {"inputs": ["4 9\n", "4 1\n", "3 2\n", "5 5\n", "3 3\n", "4 3\n", "5 3\n", "6 2\n"], "outputs": ["0\n", "22\n", "0\n", "0\n", "0\n", "0\n", "0\n", "232\n"]} | 448 | 89 |
coding | Solve the programming task below in a Python markdown code block.
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes:
* Hit his pocket, which magically increases the number of biscuits by one.
* Exchange A b... | {"inputs": ["5 2 6", "7 5 4", "5 3 6", "7 1 4", "3 3 6", "7 2 6", "4 2 6", "7 3 4"], "outputs": ["10\n", "8\n", "7\n", "11\n", "4\n", "14\n", "7", "8"]} | 240 | 95 |
coding | Solve the programming task below in a Python markdown code block.
Recently, Mishka started noticing that his keyboard malfunctions — maybe it's because he was playing rhythm games too much. Empirically, Mishka has found out that every other time he presses a key, it is registered as if the key was pressed twice. For ex... | {"inputs": ["4\n4\nossu\n2\naa\n6\naddonn\n3\nqwe\n"], "outputs": ["YES\nNO\nYES\nNO\n"]} | 600 | 39 |
coding | Solve the programming task below in a Python markdown code block.
You are given several queries. Each query consists of three integers $p$, $q$ and $b$. You need to answer whether the result of $p/q$ in notation with base $b$ is a finite fraction.
A fraction in notation with base $b$ is finite if it contains finite nu... | {"inputs": ["2\n6 12 10\n4 3 10\n", "2\n8 12 10\n4 3 10\n", "2\n8 12 10\n4 6 10\n", "2\n6 12 10\n4 3 10\n", "2\n14 12 10\n4 6 10\n", "2\n19 12 10\n4 6 10\n", "1\n1 5244319080000 30030\n", "1\n1 5942671135120 30030\n"], "outputs": ["Finite\nInfinite\n", "Infinite\nInfinite\n", "Infinite\nInfinite\n", "Finite\nInfinite\n... | 407 | 229 |
coding | Solve the programming task below in a Python markdown code block.
Little penguin Polo adores strings. But most of all he adores strings of length n.
One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exact... | {"inputs": ["7 4\n", "4 7\n", "1 1\n", "2 2\n", "1 2\n", "3 3\n", "2 2\n", "3 3\n"], "outputs": ["ababacd\n", "-1\n", "a\n", "ab\n", "-1\n", "abc\n", "ab", "abc"]} | 406 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color c_{i}. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to ... | {"inputs": ["1\n1\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n3\n", "1\n6\n", "1\n9\n", "2\n1 1\n"], "outputs": ["1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 424 | 88 |
coding | Solve the programming task below in a Python markdown code block.
You are the Dungeon Master for a public DnD game at your local comic shop and recently you've had some trouble keeping your players' info neat and organized so you've decided to write a bit of code to help keep them sorted!
The goal of this code is to c... | {"functional": "_inputs = [['a, 5'], ['jane, 801, dave, 123'], ['Amelia, 8165254325, Jessie, 9187162345, Marcus Kaine, 8018273245'], [''], [None]]\n_outputs = [[[{'player': 'a', 'contact': 5}]], [[{'player': 'jane', 'contact': 801}, {'player': 'dave', 'contact': 123}]], [[{'player': 'Amelia', 'contact': 8165254325}, {'... | 421 | 341 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Alice and Bob are traveling to Rome for separate business meetings.
You are given 4 strings arriveAlice, leaveAlice, arriveBob, and leaveBob. Alice will be in the city from the dates arriveAlice to leaveAlice (inclusi... | {"functional": "def check(candidate):\n assert candidate(arriveAlice = \"08-15\", leaveAlice = \"08-18\", arriveBob = \"08-16\", leaveBob = \"08-19\") == 3\n assert candidate(arriveAlice = \"10-01\", leaveAlice = \"10-31\", arriveBob = \"11-01\", leaveBob = \"12-31\") == 0\n\n\ncheck(Solution().countDaysTogether)... | 251 | 116 |
coding | Solve the programming task below in a Python markdown code block.
# Task:
This kata asks you to make a custom esolang interpreter for the language [MiniBitMove](https://esolangs.org/wiki/MiniBitMove). MiniBitMove has only two commands and operates on a array of bits. It works like this:
- `1`: Flip the bit at the curr... | {"functional": "_inputs = [['10', '1100101'], ['100', '1111111111'], ['110', '1010'], ['0', '100010001'], ['101010', '111']]\n_outputs = [['0011010'], ['0101010101'], ['1010'], ['100010001'], ['000']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.... | 246 | 259 |
coding | Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Lucky number is super lucky if it's ... | {"inputs": ["4\n", "1\n", "9\n", "7\n", "5\n", "2\n", "0\n", "73\n"], "outputs": ["47\n", "47\n", "47\n", "47\n", "47", "47", "47", "74\n"]} | 240 | 76 |
coding | Solve the programming task below in a Python markdown code block.
Write a program to find the remainder when an integer A is divided by an integer B.
-----Input-----
The first line contains an integer T, the total number of test cases. Then T lines follow, each line contains two Integers A and B.
-----Output-----
F... | {"inputs": ["3 \n0 3\n100 43\n1 3", "3 \n0 3\n101 43\n1 3", "3 \n0 2\n100 79\n1 40", "3 \n0 2\n100 75\n1 40", "3 \n0 2\n000 75\n1 40", "3 \n0 2\n100 79\n0 40", "3 \n0 2\n001 75\n1 40", "3 \n2 4\n100 465\n0 3"], "outputs": ["0\n14\n1\n", "0\n15\n1\n", "0\n21\n1\n", "0\n25\n1\n", "0\n0\n1\n", "0\n21\n0\n", "0\n1\n1\n", "... | 156 | 235 |
coding | Solve the programming task below in a Python markdown code block.
You were strolling outside the restaurant at the end of the universe. On a metaspiral path you stumble upon a weird device which takes a three-digit number as input and processes it. The Hitchhiker's guide to the galaxy explains that it processes the inp... | {"inputs": ["1\n123 5"], "outputs": ["27"]} | 376 | 19 |
coding | Solve the programming task below in a Python markdown code block.
Alice is driving from her home to her office which is A kilometers away and will take her X hours to reach.
Bob is driving from his home to his office which is B kilometers away and will take him Y hours to reach.
Determine who is driving faster, else... | {"inputs": ["3\n20 6 20 5\n10 3 20 6\n9 1 1 1\n"], "outputs": ["Bob\nEqual\nAlice\n"]} | 436 | 46 |
coding | Solve the programming task below in a Python markdown code block.
Spin-off of this kata, here you will have to figure out an efficient strategy to solve the problem of finding the sole duplicate number among an unsorted array/list of numbers starting from 1 up to n.
Hints: a solution in linear time can be found; using... | {"functional": "_inputs = [[[1, 1, 2, 3]], [[1, 2, 2, 3]], [[5, 4, 3, 2, 1, 1]], [[1, 3, 2, 5, 4, 5, 7, 6]], [[8, 2, 6, 3, 7, 2, 5, 1, 4]]]\n_outputs = [[1], [2], [1], [5], [2]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=t... | 109 | 256 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only.
You are given two integers bottom and top, w... | {"functional": "def check(candidate):\n assert candidate(bottom = 2, top = 9, special = [4,6]) == 3\n assert candidate(bottom = 6, top = 8, special = [7,6,8]) == 0\n\n\ncheck(Solution().maxConsecutive)"} | 151 | 70 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a lin... | {"functional": "def check(candidate):\n assert is_same_list(candidate(l1 = list_node([2,4,3]), l2 = list_node([5,6,4])), list_node([7,0,8]))\n assert is_same_list(candidate(l1 = list_node([0]), l2 = list_node([0])), list_node([0]))\n assert is_same_list(candidate(l1 = list_node([9,9,9,9,9,9,9]), l2 = list_node... | 166 | 151 |
coding | Solve the programming task below in a Python markdown code block.
Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as tha... | {"inputs": ["1 2 3 2 5 6\n6 5 4 3 2 1", "1 2 3 2 5 6\n6 1 4 3 2 1", "1 2 3 2 5 6\n6 0 4 3 2 1", "1 2 3 2 5 6\n6 0 4 3 4 1", "1 2 3 2 7 6\n6 0 4 3 4 1", "1 2 3 2 7 3\n6 0 4 3 4 1", "1 2 2 2 7 6\n6 0 4 3 4 1", "1 2 2 2 7 9\n6 0 4 3 4 1"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | 235 | 238 |
coding | Solve the programming task below in a Python markdown code block.
Constanze is the smartest girl in her village but she has bad eyesight.
One day, she was able to invent an incredible machine! When you pronounce letters, the machine will inscribe them onto a piece of paper. For example, if you pronounce 'c', 'o', 'd',... | {"inputs": ["a\n", "a\n", "w\n", "`\n", "x\n", "b\n", "y\n", "c\n"], "outputs": ["1\n", "1\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n"]} | 639 | 70 |
coding | Solve the programming task below in a Python markdown code block.
A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.
There are n schools numerated from 1 to n. One can travel between each pair of them, to do s... | {"inputs": ["2\n", "1\n", "2\n", "3\n", "4\n", "1\n", "3\n", "1\n"], "outputs": ["0\n", "0\n", "0\n", "1\n", "1\n", "0\n", "1\n", "0\n"]} | 246 | 70 |
coding | Solve the programming task below in a Python markdown code block.
# Letterss of Natac
In a game I just made up that doesn’t have anything to do with any other game that you may or may not have played, you collect resources on each turn and then use those resources to build settlements, roads, and cities or buy a develo... | {"functional": "_inputs = [['bwoo'], [''], ['ogogoogogo'], ['bwbwwwbb']]\n_outputs = [[['road']], [[]], [['city']], [['road']]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tupl... | 505 | 180 |
coding | Solve the programming task below in a Python markdown code block.
For the upcoming semester, the admins of your university decided to keep a total of X seats for the MATH-1 course. A student interest survey was conducted by the admins and it was found that Y students were interested in taking up the MATH-1 course.
Fin... | {"inputs": ["4\n1 1\n12 34\n50 49\n49 50\n"], "outputs": ["0\n22\n0\n1"]} | 486 | 42 |
coding | Solve the programming task below in a Python markdown code block.
Chef has a rectangular plate of length N cm and width M cm. He wants to make a wireframe around the plate. The wireframe costs X rupees per cm.
Determine the cost Chef needs to incur to buy the wireframe.
------ Input Format ------
- First line wi... | {"inputs": ["3\n10 10 10\n23 3 12\n1000 1000 1000\n"], "outputs": ["400\n624\n4000000"]} | 465 | 59 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array of n integer numbers. Let sum(l, r) be the sum of all numbers on positions from l to r non-inclusive (l-th element is counted, r-th element is not counted). For indices l and r holds 0 ≤ l ≤ r ≤ n. Indices in array are numbered fro... | {"inputs": ["1\n0\n", "1\n1\n", "1\n2\n", "1\n4\n", "1\n6\n", "1\n3\n", "1\n9\n", "1\n-1\n"], "outputs": ["0 0 0\n", "0 0 1\n", "0 0 1\n", "0 0 1\n", "0 0 1\n", "0 0 1\n", "0 0 1\n", "0 0 0\n"]} | 398 | 119 |
coding | Solve the programming task below in a Python markdown code block.
The Chef has been hunting for a machine developed to change numbers in a rather peculiar manner. This machine has a fixed number c associated with it and a changing number X.
In a single step, the Chef can do the following:
First, choose any positive i... | {"inputs": ["3\n1 5\n10 1\n20 4"], "outputs": ["1\n1\n20"]} | 442 | 31 |
coding | Solve the programming task below in a Python markdown code block.
There are N children and Chef wants to give them 1 candy each. Chef already has X candies with him. To buy the rest, he visits a candy shop. In the shop, packets containing exactly 4 candies are available.
Determine the minimum number of candy packets C... | {"inputs": ["4\n20 12\n10 100\n10 9\n20 9\n"], "outputs": ["2\n0\n1\n3\n"]} | 432 | 43 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given ind... | {"functional": "def check(candidate):\n assert candidate(s = \"LeetcodeHelpsMeLearn\", spaces = [8,13,15]) == \"Leetcode Helps Me Learn\"\n assert candidate(s = \"icodeinpython\", spaces = [1,5,7,9]) == \"i code in py thon\"\n assert candidate(s = \"spacing\", spaces = [0,1,2,3,4,5,6]) == \" s p a c i n g\"\n\... | 160 | 119 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an m x n binary grid grid where each 1 marks the home of one friend, return the minimal total travel distance.
The total travel distance is the sum of the distances between the houses of the friends and the meet... | {"functional": "def check(candidate):\n assert candidate(grid = [[1,0,0,0,1],[0,0,0,0,0],[0,0,1,0,0]]) == 6\n assert candidate(grid = [[1,1]]) == 1\n\n\ncheck(Solution().minTotalDistance)"} | 133 | 74 |
coding | Solve the programming task below in a Python markdown code block.
HTML Element Generator
In this kata, you will be creating a python function that will take arguments and turn them into an HTML element.
An HTML tag has three parts:
The opening tag, which consists of a tag name and potentially attributes, all in betwee... | {"functional": "_inputs = [['br'], ['title', 'Webpage Title']]\n_outputs = [['<br />'], ['<title>Webpage Title</title>']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n... | 520 | 174 |
coding | Solve the programming task below in a Python markdown code block.
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his n... | {"inputs": ["maohiro", "orihoam", "anphiro", "onphira", "arihpno", "nmpgira", "sgi`pmn", "nlp`igs"], "outputs": ["mao\n", "ori\n", "anp\n", "onp\n", "ari\n", "nmp\n", "sgi\n", "nlp\n"]} | 150 | 86 |
coding | Solve the programming task below in a Python markdown code block.
Gena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called an almost arithmetical progression. A sequence is an almost arithmetical progression, if its elements can be represented as:
* a1 = p, where p is some... | {"inputs": ["1\n63\n", "1\n68\n", "1\n170\n", "1\n331\n", "2\n3 0\n", "2\n2 0\n", "1\n120\n", "1\n116\n"], "outputs": ["1\n", "1\n", "1", "1\n", "2\n", "2\n", "1\n", "1\n"]} | 354 | 99 |
coding | Solve the programming task below in a Python markdown code block.
There is an infinite sequence consisting of all positive integers in the increasing order: p = {1, 2, 3, ...}. We performed n swap operations with this sequence. A swap(a, b) is an operation of swapping the elements of the sequence on positions a and b. ... | {"inputs": ["2\n4 2\n1 4\n", "2\n3 2\n1 4\n", "2\n4 2\n1 4\n", "3\n1 6\n3 4\n2 5\n", "3\n1 3\n4 6\n5 2\n", "3\n1 3\n4 6\n5 2\n", "3\n1 6\n6 4\n2 5\n", "3\n1 6\n6 8\n2 5\n"], "outputs": ["4\n", "6\n", "4", "15\n", "7\n", "7", "11\n", "17\n"]} | 367 | 155 |
coding | Solve the programming task below in a Python markdown code block.
You are given a tree with N vertices and N-1 edges. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and b_i.
You have coloring materials of K colors.
For each vertex in the tree, you will choose one of the K colors to paint it, so... | {"inputs": ["4 3\n1 2\n2 3\n3 4\n", "5 4\n1 2\n1 3\n1 4\n4 5\n", "16 22\n12 1\n3 1\n4 16\n7 12\n6 2\n2 15\n5 16\n14 16\n10 11\n3 10\n3 13\n8 6\n16 8\n9 12\n4 3\n"], "outputs": ["6\n", "48\n", "271414432\n"]} | 352 | 148 |
coding | Solve the programming task below in a Python markdown code block.
Our chef has been assigned a task to make a necklace of length N, from gold, diamond and platinum.There is single kind of gold, two types of diamond and three types of platinum available.
A necklace can be represented as strings of the form (G)∗(D1|D2)∗(... | {"inputs": ["2\n1\n2"], "outputs": ["6\n25"]} | 415 | 19 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an even integer n. You initially have a permutation perm of size n where perm[i] == i (0-indexed).
In one operation, you will create a new array arr, and for each i:
If i % 2 == 0, then arr... | {"functional": "def check(candidate):\n assert candidate(n = 2) == 1\n assert candidate(n = 4) == 2\n assert candidate(n = 6) == 4\n\n\ncheck(Solution().reinitializePermutation)"} | 185 | 57 |
coding | Solve the programming task below in a Python markdown code block.
Utkarsh has recently started taking English-language classes to improve his reading and writing skills. However, he is still struggling to learn English. His teacher gave him the following problem to improve his vowel-identification skills:
There is a s... | {"inputs": ["2\n10\nabcdefghij\n7\nbcadage"], "outputs": ["hgfeabcdij\ngacbade"]} | 452 | 31 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array nums of size n, return the majority element.
The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.
Please compl... | {"functional": "def check(candidate):\n assert candidate(nums = [3,2,3]) == 3\n assert candidate(nums = [2,2,1,1,1,2,2]) == 2\n\n\ncheck(Solution().majorityElement)"} | 94 | 60 |
coding | Solve the programming task below in a Python markdown code block.
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or les... | {"inputs": ["6\n1110\n9\n65\n6\n63\n7", "6\n1656\n7\n892\n2\n63\n6", "6\n1100\n7\n892\n2\n63\n6", "6\n1100\n7\n360\n2\n63\n6", "6\n1100\n7\n346\n2\n63\n7", "6\n1110\n17\n65\n6\n63\n7", "6\n1042\n8\n892\n2\n311\n9", "6\n1042\n8\n892\n2\n361\n9"], "outputs": ["210\n", "437\n", "345\n", "256\n", "254\n", "211\n", "377\n",... | 201 | 223 |
coding | Solve the programming task below in a Python markdown code block.
Chef likes toys. His favourite toy is an array of length N. This array contains only integers. He plays with this array every day. His favourite game with this array is Segment Multiplication. In this game, the second player tells the left and right side... | {"inputs": ["5\n1 2 3 4 5\n4\n1 2 3\n2 3 4\n1 1 1\n1 5 1000000000"], "outputs": ["2\n2\n0\n120"]} | 387 | 65 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two positive integer arrays nums and numsDivide. You can delete any number of elements from nums.
Return the minimum number of deletions such that the smallest element in nums divides all the elements of... | {"functional": "def check(candidate):\n assert candidate(nums = [2,3,2,4,3], numsDivide = [9,6,9,3,15]) == 2\n assert candidate(nums = [4,3,6], numsDivide = [8,2,6,10]) == -1\n\n\ncheck(Solution().minOperations)"} | 126 | 85 |
coding | Solve the programming task below in a Python markdown code block.
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be... | {"inputs": ["3\n1 2\n1 3", "3\n1 3\n2 3", "3\n1 3\n2 1", "3\n1 2\n2 3", "3\n1 2\n2 3\n", "4\n1 2\n2 3\n2 4", "4\n1 2\n2 3\n1 4", "4\n1 2\n1 3\n2 4"], "outputs": ["125000001\n", "125000001\n", "125000001\n", "125000001", "125000001\n", "250000002\n", "375000003\n", "375000003\n"]} | 503 | 202 |
coding | Solve the programming task below in a Python markdown code block.
You are given an integer $n$ from $1$ to $10^{18}$ without leading zeroes.
In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the ... | {"inputs": ["1\n", "1\n", "2\n", "6\n", "10\n", "25\n", "52\n", "57\n"], "outputs": ["-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "0\n", "1\n", "1\n"]} | 315 | 75 |
coding | Solve the programming task below in a Python markdown code block.
Description overhauled by V
---
I've invited some kids for my son's birthday, during which I will give to each kid some amount of candies.
Every kid hates receiving less amount of candies than any other kids, and I don't want to have any candies left ... | {"functional": "_inputs = [[1], [2], [5], [6], [9], [10], [60], [61], [100], [101]]\n_outputs = [[1], [2], [60], [60], [2520], [2520], [9690712164777231700912800], [591133442051411133755680800], [69720375229712477164533808935312303556800], [7041757898200960193617914702466542659236800]]\nimport math\ndef _deep_eq(a, b, ... | 178 | 358 |
coding | Solve the programming task below in a Python markdown code block.
George is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers b. During the game, George modifies the array by using special changes. Let's mark George's current array as b_1, b_2, ..., b_{|}b| (record |b| ... | {"inputs": ["7\n", "1\n", "1\n", "7\n", "6\n", "3\n", "45\n", "10\n"], "outputs": ["1", "1", "1", "1", "1\n", "1\n", "1", "1"]} | 699 | 66 |
coding | Solve the programming task below in a Python markdown code block.
Chef has some numbers. His girlfriend Chefina feels good when chef gives her a particular pattern number also called as Armstrong number.
Armstrong number is a number whose sum of its all individual digit raise to the power of the number of digit in that... | {"inputs": ["3\n153\n11\n1634"], "outputs": ["FEELS GOOD\nFEELS BAD\nFEELS GOOD"]} | 343 | 34 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.
A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times con... | {"functional": "def check(candidate):\n assert candidate(arr = [1,2,4,4,4,4], m = 1, k = 3) == True\n assert candidate(arr = [1,2,1,2,1,1,1,3], m = 2, k = 2) == True\n assert candidate(arr = [1,2,1,2,1,3], m = 2, k = 3) == False\n assert candidate(arr = [1,2,3,1,2], m = 2, k = 2) == False\n assert candid... | 143 | 172 |
coding | Solve the programming task below in a Python markdown code block.
A tree is an undirected connected graph without cycles.
You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected vert... | {"inputs": ["1\n\n6 2\n1 4\n1 6\n3 1\n6 2\n1 5\n", "1\n\n6 2\n1 4\n1 6\n3 1\n6 2\n2 5\n", "1\n\n6 4\n2 4\n1 2\n5 1\n6 1\n3 5\n", "1\n\n6 4\n1 4\n1 6\n3 1\n6 2\n1 5\n", "1\n\n6 2\n1 4\n1 2\n3 1\n6 2\n2 5\n", "1\n\n6 2\n1 4\n1 2\n3 1\n6 1\n2 5\n", "1\n\n6 2\n1 4\n1 2\n3 1\n6 1\n3 5\n", "1\n\n6 2\n1 4\n1 6\n3 1\n1 2\n2 5\... | 431 | 276 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.
Basically, the deletion can be divided into two stages:
Sea... | {"functional": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([5,3,6,2,4,None,7]), key = 3), tree_node([5,4,6,2,None,None,7]))\n\n\ncheck(Solution().deleteNode)"} | 170 | 65 |
coding | Solve the programming task below in a Python markdown code block.
You need to write a function, that returns the first non-repeated character in the given string.
For example for string `"test"` function should return `'e'`.
For string `"teeter"` function should return `'r'`.
If a string contains all unique cha... | {"functional": "_inputs = [['test'], ['teeter'], ['1122321235121222'], ['rend']]\n_outputs = [['e'], ['r'], ['5'], ['r']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n... | 157 | 190 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays.
Please complete the following python code precisely:
... | {"functional": "def check(candidate):\n assert candidate(arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8]) == [1,5]\n assert candidate(arr1 = [197,418,523,876,1356], arr2 = [501,880,1593,1710,1870], arr3 = [521,682,1337,1395,1764]) == []\n\n\ncheck(Solution().arraysIntersection)"} | 99 | 157 |
coding | Solve the programming task below in a Python markdown code block.
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.
After finishing the document, she noticed that she... | {"inputs": ["2017/01/06", "2017/01/32", "2017/01//7", "2010/01/77", "2010/01/76", "2016/01/70", "2016/01/80", "2017/01/21"], "outputs": ["2018/01/06\n", "2018/01/32\n", "2018/01//7\n", "2018/01/77\n", "2018/01/76\n", "2018/01/70\n", "2018/01/80\n", "2018/01/21\n"]} | 262 | 204 |
coding | Solve the programming task below in a Python markdown code block.
In input string ```word```(1 word):
* replace the vowel with the nearest left consonant.
* replace the consonant with the nearest right vowel.
P.S. To complete this task imagine the alphabet is a circle (connect the first and last element of the array i... | {"functional": "_inputs = [['cat'], ['codewars'], ['abcdtuvwxyz']]\n_outputs = [['ezu'], ['enedazuu'], ['zeeeutaaaaa']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, tuple)):\n ... | 292 | 178 |
coding | Solve the programming task below in a Python markdown code block.
Given the time in numerals we may convert it into words, as shown below:
$\begin{array}{l}5.00\rightarrow\:five \quad o'clock\\
5.01\rightarrow\:one\quad minute \quad past\quad five\\
5.10\rightarrow\:ten\quad minutes\quad past\quad five\\
5.15\righ... | {"inputs": ["5\n47\n", "3\n00\n", "7\n15\n"], "outputs": ["thirteen minutes to six\n", "three o' clock\n", "quarter past seven\n"]} | 445 | 48 |
coding | Solve the programming task below in a Python markdown code block.
problem
There are many $ N $ colored balls of different weights in the queue. The queue is in ascending order from the beginning: $ 1,2,3, \ dots, N-1, N, 1,2,3, \ dots, N-1, N, 1,2,3, \ dots $ The balls are lined up, followed by the balls of color $ N ... | {"inputs": ["6 3\n1 1 9 0 1 47 0 72", "6 4\n1 1 9 0 1 47 0 72", "6 4\n1 1 9 0 0 47 0 72", "6 3\n2 0 5 0 2 23 15 72", "6 3\n2 0 5 0 0 25 15 72", "6 3\n2 0 9 0 1 25 15 72", "6 3\n2 1 9 0 1 25 15 72", "7 4\n1 78 15 3 1 14 15 72"], "outputs": ["55\n", "102\n", "103\n", "28\n", "30\n", "34\n", "33\n", "350\n"]} | 460 | 240 |
coding | Solve the programming task below in a Python markdown code block.
A forest fire has been spotted at *fire*, a simple 2 element array with x, y coordinates.
The forest service has decided to send smoke jumpers in by plane and drop them in the forest.
The terrain is dangerous and surveyors have determined that there ar... | {"functional": "_inputs = [[[6, 8], [[3, 2], [6, 1], [7, 9]]], [[9, 2], [[1, 4], [9, 9], [5, 5]]]]\n_outputs = [[[7, 9]], [[5, 5]]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=tol, abs_tol=tol)\n if isinstance(a, (list, ... | 279 | 210 |
coding | Solve the programming task below in a Python markdown code block.
Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to increase creativity by drawing pictures. Let's draw a pattern well using a square stamp.
I want t... | {"inputs": ["1\n2 3\nRRGG\nGGRB\nBRRR\nBRRR", "1\n2 1\nRRGG\nGGRB\nBRRR\nBRRR", "1\n2 1\nGGRR\nGGRB\nBRRR\nBRRR", "1\n1 1\nGGRR\nGGRB\nBRRR\nBRRR", "1\n2 3\nRRGG\nGGRB\nBRRR\nRRBR", "1\n2 1\nRRGG\nGGRB\nRRRB\nBRRR", "1\n2 4\nRRGG\nGGRB\nBRRR\nRRRB", "1\n4 1\nGRGR\nGGRB\nRRRB\nBRRR"], "outputs": ["6\n", "12\n", "9\n", "... | 551 | 214 |
coding | Solve the programming task below in a Python markdown code block.
Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly n + 1 bus stops. All of them a... | {"inputs": ["1 0\n", "2 0\n", "6 1\n0 6\n", "3 2\n0 1\n1 2\n", "2 2\n0 1\n1 2\n", "1000000000 0\n", "3 2\n-1 1\n1 2\n", "3 3\n1 2\n2 3\n1 3\n"], "outputs": ["0\n", "0\n", "1\n", "0\n", "1\n", "0\n", "0\n", "0\n"]} | 615 | 136 |
coding | Solve the programming task below in a Python markdown code block.
In this problem, we use the 24-hour clock.
Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is th... | {"inputs": ["4 0 12 0 22", "6 -1 15 1 5", "6 -2 15 1 5", "6 -2 16 1 5", "6 -1 16 1 5", "6 -1 16 1 0", "6 -1 27 1 0", "6 -1 51 1 0"], "outputs": ["458\n", "537\n", "538\n", "598\n", "597\n", "602\n", "1262\n", "2702\n"]} | 273 | 153 |
coding | Solve the programming task below in a Python markdown code block.
*Inspired by the [Fold an Array](https://www.codewars.com/kata/fold-an-array) kata. This one is sort of similar but a little different.*
---
## Task
You will receive an array as parameter that contains 1 or more integers and a number `n`.
Here is a li... | {"functional": "_inputs = [[[1, 2, 3, 4, 5], 2], [[1, 2, 3, 4, 5], 3], [[15], 3], [[1, 2, 3, 4], 1], [[1, 2, 3, 4, 5, 6], 20], [[32, 45, 43, 23, 54, 23, 54, 34], 2], [[32, 45, 43, 23, 54, 23, 54, 34], 0], [[3, 234, 25, 345, 45, 34, 234, 235, 345], 3], [[3, 234, 25, 345, 45, 34, 234, 235, 345, 34, 534, 45, 645, 645, 645... | 456 | 588 |
coding | Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing.
In one operation, you can choose two indices 0 <= i < arr1.length and 0 <= j < a... | {"functional": "def check(candidate):\n assert candidate(arr1 = [1,5,3,6,7], arr2 = [1,3,2,4]) == 1\n assert candidate(arr1 = [1,5,3,6,7], arr2 = [4,3,1]) == 2\n assert candidate(arr1 = [1,5,3,6,7], arr2 = [1,6,3,3]) == -1\n\n\ncheck(Solution().makeArrayIncreasing)"} | 150 | 117 |
coding | Solve the programming task below in a Python markdown code block.
-----Problem-----
Nikki's latest work is writing a story of letters. However, she finds writing story so boring that, after working for three hours, she realized that all she has written are M long words consisting entirely of letters A and B. Having... | {"inputs": ["3\nABAB\nAABB\nABBA"], "outputs": ["2"]} | 446 | 21 |
coding | Solve the programming task below in a Python markdown code block.
In Uttu's college, a semester is said to be a:
Overload semester if the number of credits taken > 65.
Underload semester if the number of credits taken < 35.
Normal semester otherwise
Given the number of credits X taken by Uttu, determine whether the s... | {"inputs": ["4\n65\n80\n23\n58\n"], "outputs": ["Normal\nOverload\nUnderload\nNormal\n"]} | 393 | 34 |
coding | Solve the programming task below in a Python markdown code block.
A high school has a strange principal. On the first day, he has his students perform an odd opening day ceremony:
There are number of lockers "n" and number of students "n" in the school. The principal asks the first student to go to every locker and op... | {"functional": "_inputs = [[0], [1], [4], [56], [128], [500], [562], [74864], [3991700], [950811894]]\n_outputs = [[0], [1], [2], [7], [11], [22], [23], [273], [1997], [30835]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n return math.isclose(a, b, rel_tol=to... | 296 | 248 |
coding | Solve the programming task below in a Python markdown code block.
The door of Snuke's laboratory is locked with a security code.
The security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.
You are given the current security code S. If S is ... | {"inputs": ["44", "333", "446", "199", "110", "100", "000", "377"], "outputs": ["Bad\n", "Bad\n", "Bad\n", "Bad\n", "Bad\n", "Bad\n", "Bad\n", "Bad\n"]} | 166 | 77 |
coding | Solve the programming task below in a Python markdown code block.
You are given an array $a$ of length $n$. The array is called 3SUM-closed if for all distinct indices $i$, $j$, $k$, the sum $a_i + a_j + a_k$ is an element of the array. More formally, $a$ is 3SUM-closed if for all integers $1 \leq i < j < k \leq n$, th... | {"inputs": ["1\n4\n-3 -1 1 1\n", "1\n4\n-1 -4 2 3\n", "1\n4\n7 7 7 -21\n", "1\n4\n3 -3 -3 9\n", "1\n3\n0 65536 65536\n", "4\n3\n-1 0 1\n5\n1 -2 -2 1 -3\n6\n0 0 0 0 0 0\n4\n-1 2 -3 4\n"], "outputs": ["YES\n", "NO\n", "NO\n", "YES\n", "NO\n", "YES\nNO\nYES\nNO\n"]} | 608 | 165 |
coding | Solve the programming task below in a Python markdown code block.
The T9 typing predictor helps with suggestions for possible word combinations on an old-style numeric keypad phone. Each digit in the keypad (2-9) represents a group of 3-4 letters. To type a letter, press once the key which corresponds to the letter gro... | {"functional": "_inputs = [[['hello', 'world'], '43556'], [['good', 'home', 'new'], '4663'], [['gone', 'hood', 'good', 'old'], '4663'], [['Hello', 'world'], '43556'], [['gOOD', 'hOmE', 'NeW'], '4663'], [['goNe', 'hood', 'GOOD', 'old'], '4663'], [[], '43556'], [['gold'], '4663'], [['gone', 'hood', 'good', 'old'], '729']... | 490 | 336 |
coding | Solve the programming task below in a Python markdown code block.
You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language.
Input
This program has on... | {"inputs": ["1\n", "2\n", "0\n", "4\n", "8\n", "6\n", "3\n", "5\n"], "outputs": ["INTERCAL\n", "INTERCAL\n", "INTERCAL\n", "INTERCAL\n", "INTERCAL\n", "INTERCAL\n", "INTERCAL\n", "INTERCAL\n"]} | 127 | 78 |
coding | Solve the programming task below in a Python markdown code block.
Mountaineers Mr. Takahashi and Mr. Aoki recently trekked across a certain famous mountain range. The mountain range consists of N mountains, extending from west to east in a straight line as Mt. 1, Mt. 2, ..., Mt. N. Mr. Takahashi traversed the range fro... | {"inputs": ["1\n17\n17", "5\n2 3 3 3 3\n3 3 2 2 2", "5\n1 1 1 2 2\n6 2 1 1 1", "5\n1 1 1 4 2\n6 2 1 1 1", "5\n1 1 1 4 2\n6 2 1 1 0", "5\n1 1 1 4 2\n6 0 1 1 0", "5\n1 1 1 4 2\n6 1 1 1 0", "5\n1 1 1 4 2\n6 2 1 2 0"], "outputs": ["1", "4\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n"]} | 562 | 207 |
coding | Solve the programming task below in a Python markdown code block.
Read problems statements in Russian here
Chef has a special affection for sets of binary strings of equal length which have same numbers of 1's. Given three integers n, k and m, your task is to find the the lexicographically m^{th} smallest string amon... | {"inputs": ["1\n3 2 2", "1\n3 2 3", "1\n3 3 3", "1\n6 3 3", "1\n6 4 3", "1\n6 4 6", "1\n3 1 3", "1\n9 3 3"], "outputs": ["101", "110\n", "-1\n", "001101\n", "011011\n", "100111\n", "100\n", "000001101\n"]} | 323 | 138 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.