problem stringlengths 14 4.09k | solution stringlengths 1 802k | task_type stringclasses 3
values | problem_tokens int64 5 895 |
|---|---|---|---|
Solve the programming task below in a Python markdown code block.
Make a program that takes a value (x) and returns "Bang" if the number is divisible by 3, "Boom" if it is divisible by 5, "BangBoom" if it divisible by 3 and 5, and "Miss" if it isn't divisible by any of them.
Note: Your program should only return one va... | {"functional": "_inputs = [[30], [3], [98], [65], [23], [15], [4], [2], [45], [90], [21], [7], [6], [10003823], [41535], [712], [985], [164523]]\n_outputs = [['BangBoom'], ['Bang'], ['Miss'], ['Boom'], ['Miss'], ['BangBoom'], ['Miss'], ['Miss'], ['BangBoom'], ['BangBoom'], ['Bang'], ['Miss'], ['Bang'], ['Miss'], ['Bang... | coding | 146 |
Solve the programming task below in a Python markdown code block.
Roughly speaking, this problem asks you to create the checker of [*the problem used in December CookOff*].
You are given a tree with N vertices and a string C of length N, consisting of the characters 'R', 'G' and 'B'.
For each integer i\ (1≤ i≤ N), C_... | {"inputs": ["5\n4\nBRGB\n3 2\n1 2\n4 3\n3\nRGB\n1 2\n2 3\n1\nB\n2\nBB\n1 2\n4\nBRGB\n3 2\n1 2\n4 2"], "outputs": ["Yes\nYes\nYes\nNo\nNo"]} | coding | 617 |
Solve the programming task below in a Python markdown code block.
Complete the function that takes an array of words.
You must concatenate the `n`th letter from each word to construct a new word which should be returned as a string, where `n` is the position of the word in the list.
For example:
```
["yoda", "best",... | {"functional": "_inputs = [[['yoda', 'best', 'has']], [[]], [['X-ray']], [['No', 'No']], [['Chad', 'Morocco', 'India', 'Algeria', 'Botswana', 'Bahamas', 'Ecuador', 'Micronesia']]]\n_outputs = [['yes'], [''], ['X'], ['No'], ['Codewars']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinsta... | coding | 154 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You have k bags. You are given a 0-indexed integer array weights where weights[i] is the weight of the ith marble. You are also given the integer k.
Divide the marbles into the k bags according to the following rules:... | {"functional": "def check(candidate):\n assert candidate(weights = [1,3,5,1], k = 2) == 4\n assert candidate(weights = [1, 3], k = 2) == 0\n\n\ncheck(Solution().putMarbles)"} | coding | 209 |
Solve the programming task below in a Python markdown code block.
*** No Loops Allowed ***
You will be given an array (a) and a limit value (limit). You must check that all values in the array are below or equal to the limit value. If they are, return true. Else, return false.
You can assume all values in the array a... | {"functional": "_inputs = [[[66, 101], 200], [[78, 117, 110, 99, 104, 117, 107, 115], 100], [[101, 45, 75, 105, 99, 107], 107], [[80, 117, 115, 104, 45, 85, 112, 115], 120]]\n_outputs = [[True], [False], [True], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):\n ... | coding | 168 |
Solve the programming task below in a Python markdown code block.
Ayush is a cashier at the shopping center. Recently his department has started a ''click and collect" service which allows users to shop online.
The store contains k items. n customers have already used the above service. Each user paid for m items. Le... | {"inputs": ["1 1 1\n1\n1\n", "1 1 1\n1\n1\n", "2 2 5\n3 4 1 2 5\n1 5\n3 1\n", "3 2 3\n3 1 2\n1 2\n2 1\n2 3\n", "3 2 3\n3 1 2\n1 2\n2 1\n2 3\n", "3 2 3\n3 1 2\n1 2\n3 1\n2 3\n", "2 2 5\n3 4 1 0 5\n1 5\n3 1\n", "2 2 5\n3 4 1 0 5\n1 5\n4 1\n"], "outputs": ["1\n", "1\n", "14\n", "13\n", "13\n", "17\n", "14\n", "15\n"]} | coding | 644 |
Solve the programming task below in a Python markdown code block.
Write a function named `first_non_repeating_letter` that takes a string input, and returns the first character that is not repeated anywhere in the string.
For example, if given the input `'stress'`, the function should return `'t'`, since the letter *t... | {"functional": "_inputs = [['a'], ['stress'], ['moonmen'], [''], ['abba'], ['aa'], ['~><#~><'], ['hello world, eh?'], ['sTreSS'], [\"Go hang a salami, I'm a lasagna hog!\"]]\n_outputs = [['a'], ['t'], ['e'], [''], [''], [''], ['#'], ['w'], ['T'], [',']]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, ... | coding | 182 |
Solve the programming task below in a Python markdown code block.
Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degree_{v} and s_{v}, were the fir... | {"inputs": ["1\n0 0\n", "1\n0 0\n", "1\n0 1\n", "1\n0 2\n", "1\n0 3\n", "1\n0 -1\n", "1\n0 -2\n", "1\n0 -3\n"], "outputs": ["0\n", "0\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "0\n\n"]} | coding | 443 |
Solve the programming task below in a Python markdown code block.
A valid postal code $\mbox{P}$ have to fullfil both below requirements:
$\mbox{P}$ must be a number in the range from 100000 to 9999 inclusive.
$\mbox{P}$ must not contain more than one alternating repetitive digit pair.
Alternating repetitive digit... | {"inputs": ["110000\n"], "outputs": ["False\n"]} | coding | 475 |
Solve the programming task below in a Python markdown code block.
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first release the memory manager will be... | {"inputs": ["3 1\nerase 0\nerase 0\nerase -2147483648\n", "3 1\nerase -1\nerase 0\nerase -2147483648\n", "3 1\nerase -1\nerase 0\nerase -2666718247\n", "6 10\nalloc 6\nalloc 3\nerase 1\nalloc 6\ndefragment\nalloc 6\n", "6 4\nalloc 5\nalloc 3\nerase 2\nalloc 18\ndefragment\nalloc 6\n", "6 6\nalloc 5\nalloc 3\nerase 1\na... | coding | 704 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x.
Notice that x does not hav... | {"functional": "def check(candidate):\n assert candidate(nums = [3,5]) == 2\n assert candidate(nums = [0,0]) == -1\n assert candidate(nums = [0,4,3,0,4]) == 3\n assert candidate(nums = [3,6,7,7,0]) == -1\n\n\ncheck(Solution().specialArray)"} | coding | 131 |
Solve the programming task below in a Python markdown code block.
The first input array is the key to the correct answers to an exam, like ["a", "a", "b", "d"]. The second one contains a student's submitted answers.
The two arrays are not empty and are the same length. Return the score for this array of answers, givi... | {"functional": "_inputs = [[['a', 'a', 'b', 'b'], ['a', 'c', 'b', 'd']], [['a', 'a', 'c', 'b'], ['a', 'a', 'b', '']], [['a', 'a', 'b', 'c'], ['a', 'a', 'b', 'c']], [['b', 'c', 'b', 'a'], ['', 'a', 'a', 'c']]]\n_outputs = [[6], [7], [16], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or i... | coding | 273 |
Solve the programming task below in a Python markdown code block.
# Introduction
You are the developer working on a website which features a large counter on its homepage, proudly displaying the number of happy customers who have downloaded your companies software.
You have been tasked with adding an effect to this c... | {"functional": "_inputs = [['1250'], ['0050'], ['0000']]\n_outputs = [[[[0, 1], [0, 1, 2], [0, 1, 2, 3, 4, 5], [0]]], [[[0], [0], [0, 1, 2, 3, 4, 5], [0]]], [[[0], [0], [0], [0]]]]\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_to... | coding | 257 |
Solve the programming task below in a Python markdown code block.
Read problems statements in mandarin chinese, russian and vietnamese as well.
Chef Ada loves trees, she thinks that the beauty of a tree is determined by the distance between its center and centroid. If the tree has multiple centers or centroids, then ... | {"inputs": ["1\n4 0"], "outputs": ["YES\n1 2\n1 3\n1 4"]} | coding | 415 |
Solve the programming task below in a Python markdown code block.
You already know that Valery's favorite sport is biathlon. Due to your help, he learned to shoot without missing, and his skills are unmatched at the shooting range. But now a smaller task is to be performed, he should learn to complete the path fastest.... | {"inputs": ["1 2 4\nST\n", "1 2 1\nST\n", "2 1 4\nS\nT\n", "1 3 3\nSaT\n", "2 1 1\nS\nT\n", "1 3 3\nTyS\n", "1 4 1\nSxyT\n", "3 3 1\naaa\naaa\nTSa\n"], "outputs": ["\n", "\n", "\n", "a\n", "\n", "y\n", "-1\n", "\n"]} | coding | 592 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).
Given an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.
Â
Please com... | {"functional": "def check(candidate):\n assert candidate(matrix = [[1,2,3],[3,1,2],[2,3,1]]) == True\n assert candidate(matrix = [[1,1,1],[1,2,3],[1,2,3]]) == False\n\n\ncheck(Solution().checkValid)"} | coding | 96 |
Solve the programming task below in a Python markdown code block.
Given $n$ integers $a_1, a_2, \dots, a_n$. You can perform the following operation on them:
select any element $a_i$ ($1 \le i \le n$) and divide it by $2$ (round down). In other words, you can replace any selected element $a_i$ with the value $\left \l... | {"inputs": ["1\n2\n1000000000 2\n", "1\n2\n2000000000 1\n", "7\n3\n3 6 5\n4\n5 3 2 1\n5\n1 2 3 4 5\n1\n1000000000\n4\n2 8 7 5\n5\n8 26 5 21 10\n2\n5 14\n", "1\n30\n1073741824 1073741824 1610612736 1073741824 1342177280 1610612736 1879048192 1073741824 1207959552 1342177280 1476395008 1610612736 1744830464 1879048192 10... | coding | 666 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a 0-indexed integer array nums of size n and two integers lower and upper, return the number of fair pairs.
A pair (i, j) is fair if:
0 <= i < j < n, and
lower <= nums[i] + nums[j] <= upper
Â
Please complete t... | {"functional": "def check(candidate):\n assert candidate(nums = [0,1,7,4,4,5], lower = 3, upper = 6) == 6\n assert candidate(nums = [1,7,9,2,5], lower = 11, upper = 11) == 1\n\n\ncheck(Solution().countFairPairs)"} | coding | 116 |
Solve the programming task below in a Python markdown code block.
A superhero fights with a monster. The battle consists of rounds, each of which lasts exactly $n$ minutes. After a round ends, the next round starts immediately. This is repeated over and over again.
Each round has the same scenario. It is described by ... | {"inputs": ["1 1\n-1\n", "1 1\n-1\n", "1 2\n1 -1\n", "1 2\n-1 1\n", "1 2\n-1 1\n", "1 2\n1 -1\n", "2 2\n1 -1\n", "1 1\n-1000000\n"], "outputs": ["1\n", "1\n", "-1\n", "1\n", "1\n", "-1\n", "-1\n", "1\n"]} | coding | 510 |
Solve the programming task below in a Python markdown code block.
Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. The original problem is i... | {"inputs": ["6\n", "4\n", "5\n", "1\n", "9\n", "8\n", "7\n", "2\n"], "outputs": ["10 2\n1 2", "6 2\n1 2", "8 2\n1 2\n", "1 1\n1\n", "16 2\n1 2\n", "14 2\n1 2", "12 2\n1 2\n", "2 2\n1 2"]} | coding | 573 |
Solve the programming task below in a Python markdown code block.
There are N cats. We number them from 1 through N.
Each of the cats wears a hat. Cat i says: "there are exactly a_i different colors among the N - 1 hats worn by the cats except me."
Determine whether there exists a sequence of colors of the hats that ... | {"inputs": ["3\n1 1 3", "3\n0 2 2", "3\n4 2 2", "3\n1 0 3", "3\n0 2 4", "3\n4 0 2", "3\n0 2 8", "3\n0 0 2"], "outputs": ["No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n"]} | coding | 260 |
Solve the programming task below in a Python markdown code block.
Its Christmas time and Santa has started his ride to deliver gifts to children waiting for him in a 1-dimentional city. All houses in this city are on a number line numbered as 1, 2, 3… and so on. Santa wants to deliver to houses from n to m, but he foun... | {"inputs": ["1\n2 20 2 1"], "outputs": ["5"]} | coding | 428 |
Solve the programming task below in a Python markdown code block.
We have a two-dimensional grid with H \times W squares. There are M targets to destroy in this grid - the position of the i-th target is \left(h_i, w_i \right).
Takahashi will choose one square in this grid, place a bomb there, and ignite it. The bomb wi... | {"inputs": ["2 3 3\n2 2\n1 1\n1 2", "2 3 3\n2 1\n1 1\n1 3", "2 3 3\n2 1\n1 1\n1 2", "2 4 3\n2 1\n1 1\n1 2", "2 3 3\n2 2\n2 1\n1 2", "4 3 3\n2 1\n1 1\n1 2", "4 3 3\n3 1\n1 1\n1 2", "8 3 3\n3 1\n1 1\n1 2"], "outputs": ["3\n", "3\n", "3\n", "3\n", "3\n", "3\n", "3\n", "3\n"]} | coding | 347 |
Solve the programming task below in a Python markdown code block.
The eval() expression is a very powerful built-in function of Python. It helps in evaluating an expression. The expression can be a Python statement, or a code object.
For example:
>>> eval("9 + 5")
14
>>> x = 2
>>> eval("x + 3")
5
Here, eval() ca... | {"inputs": ["print(2 + 3)\n"], "outputs": ["5\n"]} | coding | 214 |
Solve the programming task below in a Python markdown code block.
Write a function that checks if all the letters in the second string are present in the first one at least once, regardless of how many times they appear:
```
["ab", "aaa"] => true
["trances", "nectar"] => true
["compadres", "DRAPES"] => true
... | {"functional": "_inputs = [[['abcd', 'aaa']], [['trances', 'nectar']], [['THE EYES', 'they see']], [['assert', 'staring']], [['arches', 'later']], [['dale', 'caller']], [['parses', 'parsecs']], [['replays', 'adam']], [['mastering', 'streaming']], [['drapes', 'compadres']], [['deltas', 'slated']], [['deltas', '']], [[''... | coding | 154 |
Solve the programming task below in a Python markdown code block.
There is a line with 1000 cells numbered from 1 to 1000 from left to right and N coins placed on it. Coin i is placed at cell X_{i}, and no two coins are placed at the same cell.
Bob would like to move the coins to the N leftmost cells of the line. To d... | {"inputs": ["2\n3 2\n2 4 7\n5 3\n1 2 3 4 5", "2\n3 2\n2 4 7\n3 3\n1 2 3 4 5", "2\n3 2\n2 4 7\n3 3\n1 2 3 4 9", "2\n3 2\n2 4 7\n3 3\n1 2 3 4 7", "2\n4 2\n1 4 7\n5 3\n1 2 3 4 9", "2\n4 1\n1 4 7\n5 6\n1 2 5 6 9", "2\n4 2\n1 4 5\n5 6\n1 2 3 4 9", "2\n3 2\n2 4 8\n6 3\n1 2 3 4 5"], "outputs": ["5\n0", "5\n0\n", "5\n4\n", "5\... | coding | 409 |
Solve the programming task below in a Python markdown code block.
Guddu was participating in a programming contest. He only had one problem left when his mother called him for dinner. Guddu is well aware how angry his mother could get if he was late for dinner and he did not want to sleep on an empty stomach, so he had... | {"inputs": ["1\n3\n5 2 7"], "outputs": ["2"]} | coding | 557 |
Solve the programming task below in a Python markdown code block.
Whereas humans nowadays read fewer and fewer books on paper, book readership among marmots has surged. Heidi has expanded the library and is now serving longer request sequences.
-----Input-----
Same as the easy version, but the limits have changed: 1... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "4 1\n1 2 2 1\n", "4 2\n1 2 3 1\n", "4 2\n1 2 3 2\n", "4 2\n1 2 3 2\n", "4 3\n1 1 1 1\n", "4 2\n2 2 3 1\n"], "outputs": ["1\n", "1\n", "3\n", "3\n", "3\n", "3\n", "1\n", "3\n"]} | coding | 146 |
Solve the programming task below in a Python markdown code block.
Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another stage of the... | {"inputs": ["4 4\n1 7 4 7\n1 4 3\n2 10\n2 2\n1 3 3\n", "4 5\n5 2 6 1\n2 8\n2 7\n1 4 4\n2 9\n1 3 9\n", "4 5\n6 9 5 1\n1 4 9\n1 3 9\n1 4 7\n2 10\n2 7\n", "5 4\n4 8 3 4 10\n1 4 10\n1 4 6\n1 3 10\n2 1\n", "5 5\n1 2 3 4 5\n1 1 5\n2 10\n1 5 11\n1 4 1\n2 1\n", "5 5\n5 6 2 10 10\n1 2 7\n2 4\n1 1 10\n2 8\n1 3 4\n", "5 6\n1 2 3 ... | coding | 737 |
Solve the programming task below in a Python markdown code block.
# The Problem
Dan, president of a Large company could use your help. He wants to implement a system that will switch all his devices into offline mode depending on his meeting schedule. When he's at a meeting and somebody texts him, he wants to send an ... | {"functional": "_inputs = [[[['09:30', '10:15'], ['12:20', '15:50']], '10:00'], [[['09:30', '10:15'], ['12:20', '15:50']], '11:00'], [[['09:30', '10:15'], ['12:20', '15:50']], '10:15'], [[], '10:15'], [[['12:13', '23:50']], '10:15'], [[['12:13', '23:50']], '23:55'], [[['12:13', '23:50']], '17:43']]\n_outputs = [['10:15... | coding | 450 |
Solve the programming task below in a Python markdown code block.
[Run-length encoding](http://en.wikipedia.org/wiki/Run-length_encoding) (RLE) is a very simple form of lossless data compression in which runs of data are stored as a single data value and count.
A simple form of RLE would encode the string `"AAABBBCCCD... | {"functional": "_inputs = [['A'], ['AAA'], ['AB'], ['AAABBBCCCA'], ['QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ... | coding | 163 |
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"]} | coding | 367 |
Solve the programming task below in a Python markdown code block.
For every string, after every occurrence of `'and'` and `'but'`, insert the substring `'apparently'` directly after the occurrence.
If input does not contain 'and' or 'but', return the original string. If a blank string, return `''`.
If substring `'app... | {"functional": "_inputs = [['A fast-food resteraunt down the street was grumbling my tummy but I could not go.'], ['apparently'], ['and'], ['but'], ['but apparently'], ['and apparently'], ['but but but and and and'], [''], ['but and apparently apparently apparently apparently'], ['and apparentlybutactuallynot voilewtfm... | coding | 303 |
Solve the programming task below in a Python markdown code block.
# Task
Suppose there are `n` people standing in a circle and they are numbered 1 through n in order.
Person 1 starts off with a sword and kills person 2. He then passes the sword to the next person still standing, in this case person 3. Person 3 the... | {"functional": "_inputs = [[5], [11], [1], [2], [3], [4], [8], [16], [15], [31]]\n_outputs = [[3], [7], [1], [1], [3], [1], [1], [1], [15], [31]]\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 isinsta... | coding | 256 |
Solve the programming task below in a Python markdown code block.
After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how... | {"inputs": ["1 5\n", "3 8\n", "5 7\n", "1 1\n", "3 4\n", "1 4\n", "4 4\n", "3 9\n"], "outputs": ["1\n", "5\n", "7\n", "0\n", "3\n", "1\n", "4\n", "6\n"]} | coding | 454 |
Solve the programming task below in a Python markdown code block.
Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k.
-----Input-----
The only line contains two integers n and k (1 ≤ n, k ≤ 10^9).
-----Output-----
Print the smal... | {"inputs": ["5 3\n", "1 1\n", "8 8\n", "8 8\n", "1 1\n", "1 2\n", "4 3\n", "2 2\n"], "outputs": ["6\n", "2\n", "16\n", "16", "2", "2\n", "6\n", "4\n"]} | coding | 129 |
Solve the programming task below in a Python markdown code block.
You've come to your favorite store Infinitesco to buy some ice tea.
The store sells ice tea in bottles of different volumes at different costs. Specifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, ... | {"inputs": ["6 3 -1 0\n3", "5 39 -1 4\n1", "5 39 -2 4\n1", "5 39 -4 4\n1", "22 12 1 2\n2", "22 12 1 2\n3", "4 21 63 7\n10", "20 30 70 83\n3"], "outputs": ["-3\n", "-1\n", "-2\n", "-4\n", "2\n", "3\n", "35\n", "143\n"]} | coding | 352 |
Solve the programming task below in a Python markdown code block.
Nexus 4.O is going to be organized by ASME, GLA University. Shubhanshu, Head of Finance Team is working for it. He has $N$ number of bills of different values as $a$$1$,$ a$$2$, $a$$3$…$a$$n$.
He is interested in a game in which one has to do the additio... | {"inputs": ["1\n8 3\n1 2 3 4 5 6 7 8\n2 3\n1 6\n5 8"], "outputs": ["5\n21\n26"]} | coding | 700 |
Solve the programming task below in a Python markdown code block.
Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.
- Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choi... | {"inputs": ["9", "5", "2", "3", "4", "6", "6\n", "2\n"], "outputs": ["5\n", "3\n", "1\n", "2\n", "3\n", "3", "3\n", "1\n"]} | coding | 239 |
Solve the programming task below in a Python markdown code block.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentively and use it... | {"inputs": ["A\n", "B\n", "B\n", "A\n", "C\n", "@\n", "D\n", "?\n"], "outputs": ["<A>\n", "<B>\n", "<B>\n", "<A>\n", "<C>\n", "<@>\n", "<D>\n", "<?>\n"]} | coding | 714 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two 0-indexed integer arrays player1 and player2, representing the number of pins that player 1 and player 2 hit in a bowling game, respectively.
The bowling game consists of n turns, and the number of p... | {"functional": "def check(candidate):\n assert candidate(player1 = [4,10,7,9], player2 = [6,5,2,3]) == 1\n assert candidate(player1 = [3,5,7,6], player2 = [8,10,10,2]) == 2\n assert candidate(player1 = [2,3], player2 = [4,1]) == 0\n\n\ncheck(Solution().isWinner)"} | coding | 235 |
Solve the programming task below in a Python markdown code block.
Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power ... | {"inputs": ["1 5 2 1 6 3\n2 4\n", "1 0 2 1 6 9\n1 4\n", "1 5 0 1 6 3\n3 4\n", "1 2 0 1 6 3\n3 4\n", "1 5 2 1 6 3\n1 4\n", "1 3 2 1 5 9\n1 4\n", "1 3 2 1 6 9\n1 4\n", "1 5 0 1 6 3\n2 4\n"], "outputs": ["10\n", "0\n", "5\n", "2\n", "15\n", "9\n", "9\n", "10\n"]} | coding | 413 |
Solve the programming task below in a Python markdown code block.
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then ... | {"inputs": ["4\n1\n2\n3\n4"], "outputs": ["1\n10\n10\n101\n101\n101\n1010\n1010\n1010\n1010"]} | coding | 216 |
Solve the programming task below in a Python markdown code block.
In Chefland, everyone who earns strictly more than Y rupees per year, has to pay a tax to Chef. Chef has allowed a special scheme where you can invest any amount of money and claim exemption for it.
You have earned X (X > Y) rupees this year. Find the m... | {"inputs": ["4\n4 2\n8 7\n5 1\n2 1\n"], "outputs": ["2\n1\n4\n1\n"]} | coding | 447 |
Solve the programming task below in a Python markdown code block.
The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number a i... | {"inputs": ["11\n", "11\n", "101\n", "111\n", "111\n", "110\n", "100\n", "101\n"], "outputs": ["1\n", "1\n", "11\n", "11\n", "11\n", "11\n", "10\n", "11\n"]} | coding | 306 |
Solve the programming task below in a Python markdown code block.
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on the inte... | {"inputs": ["2 2 2\n", "2 3 4\n", "1 1 1\n", "3 3 1\n", "3 3 2\n", "3 3 3\n", "3 3 5\n", "3 3 8\n"], "outputs": ["2\n", "3\n", "1\n", "1\n", "2\n", "2\n", "3\n", "6\n"]} | coding | 289 |
Solve the programming task below in a Python markdown code block.
Given an array A of n non-negative integers. Find the number of ways to partition/divide the array into subarrays, such that mex in each subarray is not more than k. For example, mex of the arrays [1, 2] will be 0, and that of [0, 2] will be 1, and that... | {"inputs": ["3 1\n0 1 2\n\n", "10 3\n0 1 2 3 4 0 1 2 5 3\n\n"], "outputs": ["2", "379"]} | coding | 403 |
Solve the programming task below in a Python markdown code block.
The only difference between this problem and D2 is the bound on the size of the tree.
You are given an unrooted tree with $n$ vertices. There is some hidden vertex $x$ in that tree that you are trying to find.
To do this, you may ask $k$ queries $v_1, ... | {"inputs": ["3\n1\n2\n1 2\n10\n2 4\n2 1\n5 7\n3 10\n8 6\n6 1\n1 3\n4 7\n9 6\n"], "outputs": ["0\n1\n2\n"]} | coding | 547 |
Solve the programming task below in a Python markdown code block.
B: 階層的計算機 (Hierarchical Calculator)
Problem
Ebi-chan has N formulae: y = a_i x for i =1, ..., N (inclusive). Now she considers a subsequence of indices with length k: s_1, s_2, ..., s_k. At first, let x_0 be 1 and evaluate s_1-th formulae with x = x_0.... | {"inputs": ["4\n0 0 0 2", "4\n2 0 0 0", "4\n0 0 0 1", "4\n0 0 0 0", "4\n1 0 0 0", "4\n1 0 0 1", "4\n2 0 -1 1", "4\n2 -1 1 2"], "outputs": ["1\n4\n", "1\n1\n", "0\n", "0\n", "0\n", "0\n", "1\n1\n", "2\n1\n4\n"]} | coding | 620 |
Solve the programming task below in a Python markdown code block.
You are developing frog-shaped robots, and decided to race them against each other.
First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 <... | {"inputs": ["3\n0 2 3", "3\n2 3 8", "3\n0 0 8", "3\n0 2 4", "3\n3 3 8", "3\n0 2 8", "3\n6 3 8", "3\n0 4 8"], "outputs": ["2\n", "6\n", "1\n", "2\n", "6\n", "2\n", "6\n", "2\n"]} | coding | 435 |
Solve the programming task below in a Python markdown code block.
It is the final day of La Liga. Chef has a certain criteria for assessing football matches.
In particular, he only likes a match if:
The match ends in a draw, and,
At least one goal has been scored by either team.
Given the goals scored by both the ... | {"inputs": ["4\n1 1\n0 1\n0 0\n2 2\n"], "outputs": ["YES\nNO\nNO\nYES"]} | coding | 395 |
Solve the programming task below in a Python markdown code block.
You are given a tree with N nodes and each has a value associated with it. You are given Q queries, each of which is either an update or a retrieval operation.
Initially all node values are zero.
The update query is of the format
a1 d1 a2 d2 A B
T... | {"inputs": ["7 2\n1 2\n1 3\n2 4\n2 6\n4 5\n6 7\n1 4\n1 1 1 1 4 6\n4 5\n2 7\n4 7\n5 3\n"], "outputs": ["1\n44\n45\n9\n"]} | coding | 649 |
Solve the programming task below in a Python markdown code block.
Read problem statement in Mandarin chinese and Vietnamese.
Suzumo is the coach of the ChefLand OI team. Physical condition is very important in any olympiad, so he wants to make the children run a bit as a warmup.
The team consists of $N$ children num... | {"inputs": ["1\n3\n10 10\n20 30\n30 10"], "outputs": ["0.5"]} | coding | 624 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string word to which you can insert letters "a", "b" or "c" anywhere and any number of times, return the minimum number of letters that must be inserted so that word becomes valid.
A string is called valid if ... | {"functional": "def check(candidate):\n assert candidate(word = \"b\") == 2\n assert candidate(word = \"aaa\") == 6\n assert candidate(word = \"abc\") == 0\n\n\ncheck(Solution().addMinimum)"} | coding | 111 |
Solve the programming task below in a Python markdown code block.
Champa loved traveling the world. He loved going from one city to the other. Being the miser that he is, he never wishes spend any money. Champa, instead, jumps from one city to the other. Also he likes trips of high quality.
He can start at any city of... | {"inputs": ["1\n2 1000\n1 3000000\n"], "outputs": ["2999999000\n"]} | coding | 450 |
Solve the programming task below in a Python markdown code block.
You are given $3$ unweighted, undirected graphs, $G_1$, $G_2$, and $G_3$, with $n$ vertices each, where the $k^{th}$ graph has $m_{k}$ edges and the vertices in each graph are numbered from $\mbox{1}$ through $n$. Find the number of ordered triples $(a,b... | {"inputs": ["3\n2\n1 2\n2 3\n3\n1 2\n1 3\n2 3\n2\n1 3\n2 3\n"], "outputs": ["3\n"]} | coding | 479 |
Solve the programming task below in a Python markdown code block.
The Chef's latest idea is that some cooks might work better in pairs. So, he is going to experiment by pairing up some of his employees to see if the quality of the food prepared in his kitchen increases. However, only some pairs of employees are compati... | {"inputs": ["2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 1", "2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n0 3\n1 3\n1 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n1 3\n1 3\n2 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n1 3\n0 3\n3 0\n4 1\n0 1\n2 3\n2 1", "2\n8 5\n0 1\n1 2\n1 3\n0 3\n4 0\... | coding | 533 |
Solve the programming task below in a Python markdown code block.
Given an Integer N, write a program to reverse it.
-----Input-----
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.
-----Output-----
For each test case, display the reverse of the ... | {"inputs": ["4\n12345\n31203\n2123\n2300"], "outputs": ["54321\n30213\n3212\n32"]} | coding | 157 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given a string s, reverse only all the vowels in the string and return it.
The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once.
Â
Please complete the following... | {"functional": "def check(candidate):\n assert candidate(s = \"hello\") == \"holle\"\n assert candidate(s = \"leetcode\") == \"leotcede\"\n\n\ncheck(Solution().reverseVowels)"} | coding | 100 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
Â
Please complete the following python code precisely:
```python
# Definition for a binary tree node.
# clas... | {"functional": "def check(candidate):\n assert candidate(root = tree_node([1,2,2,3,4,4,3])) == True\n assert candidate(root = tree_node([1,2,2,None,3,None,3])) == False\n\n\ncheck(Solution().isSymmetric)"} | coding | 126 |
Solve the programming task below in a Python markdown code block.
An ordered sequence of numbers from 1 to N is given. One number might have deleted from it, then the remaining numbers were mixed. Find the number that was deleted.
Example:
- The starting array sequence is `[1,2,3,4,5,6,7,8,9]`
- The mixed array wit... | {"functional": "_inputs = [[[1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 7, 9, 4, 8, 1, 2, 3]], [[1, 2, 3, 4, 5, 6, 7], [2, 3, 6, 1, 5, 4, 7]], [[1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 7, 6, 9, 4, 8, 1, 2, 3]], [[1], []], [[], []]]\n_outputs = [[6], [0], [0], [1], [0]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, flo... | coding | 186 |
Solve the programming task below in a Python markdown code block.
Find out the maximum sub-array of non negative numbers from an array.
The sub-array should be continuous. That is, a sub-array created by choosing the second and fourth element and skipping the third element is invalid.
Maximum sub-array is defined in... | {"inputs": ["1\n6\n1 2 5 -7 2 3"], "outputs": ["1 2 5"]} | coding | 262 |
Solve the programming task below in a Python markdown code block.
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.
Initially, you are in Square X.
You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.
However, for each i = 1, 2, ..., M, there is ... | {"inputs": ["5 3 3\n1 2 4\n", "7 3 2\n4 5 6\n", "10 7 5\n1 2 3 4 6 8 9\n"], "outputs": ["1\n", "0\n", "3\n"]} | coding | 376 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.
Â
Please complete the followi... | {"functional": "def check(candidate):\n assert candidate(nums = [\"777\",\"7\",\"77\",\"77\"], target = \"7777\") == 4\n assert candidate(nums = [\"123\",\"4\",\"12\",\"34\"], target = \"1234\") == 2\n assert candidate(nums = [\"1\",\"1\",\"1\"], target = \"11\") == 6\n\n\ncheck(Solution().numOfPairs)"} | coding | 99 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1. You are given a 0-indexed integer array parents, where parents[i] is the parent for node i. Since node 0 is the root, parents[0] == -1.
The... | {"functional": "def check(candidate):\n assert candidate(parents = [-1,0,0,2], nums = [1,2,3,4]) == [5,1,1,1]\n assert candidate(parents = [-1,0,1,0,3,3], nums = [5,4,6,2,1,3]) == [7,1,1,4,2,1]\n assert candidate(parents = [-1,2,3,0,2,4,1], nums = [2,3,4,5,6,7,8]) == [1,1,1,1,1,1,1]\n\n\ncheck(Solution().small... | coding | 213 |
Solve the programming task below in a Python markdown code block.
A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy!
It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and ... | {"inputs": ["2\n10 3 1 2\n2 4 1 3\n1 2 1 1", "2\n10 3 1 2\n2 4 1 3\n1 3 1 1", "2\n10 3 1 2\n3 4 1 3\n1 3 1 1", "2\n10 3 2 2\n3 4 1 3\n1 3 1 1", "2\n10 3 2 2\n3 8 1 3\n1 3 1 1", "2\n10 3 2 2\n3 8 1 3\n1 6 1 1", "2\n10 2 2 2\n3 8 1 3\n1 6 1 1", "2\n10 2 2 2\n3 5 1 3\n1 6 1 1"], "outputs": ["4\n", "5\n", "9\n", "6\n", "-1... | coding | 366 |
Solve the programming task below in a Python markdown code block.
In this problem you are given a sequence of $N$ positive integers $S[1],S[2],\dots,S[N]$. In addition you are given an integer $T$, and your aim is to find the number of quadruples $(i,j,k,l)$, such that $1 \le i < j < k < l \le N$, and $S[i] + S[j] + S... | {"inputs": ["6 20 3 1 1 2 5 10"], "outputs": ["1"]} | coding | 557 |
Solve the programming task below in a Python markdown code block.
In Omkar's last class of math, he learned about the least common multiple, or $LCM$. $LCM(a, b)$ is the smallest positive integer $x$ which is divisible by both $a$ and $b$.
Omkar, having a laudably curious mind, immediately thought of a problem involvi... | {"inputs": ["1\n2\n", "1\n2\n", "2\n7\n8\n", "2\n7\n8\n", "2\n7\n16\n", "2\n8\n11\n", "3\n4\n6\n9\n", "3\n4\n5\n2\n"], "outputs": ["1 1\n", "1 1\n", "1 6\n4 4\n", "1 6\n4 4\n", "1 6\n8 8\n", "4 4\n1 10\n", "2 2\n3 3\n3 6\n", "2 2\n1 4\n1 1\n"]} | coding | 469 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given a binary string binary consisting of only 0's or 1's. You can apply each of the following operations any number of times:
Operation 1: If the number contains the substring "00", you can replace it with ... | {"functional": "def check(candidate):\n assert candidate(binary = \"000110\") == \"111011\"\n assert candidate(binary = \"01\") == \"01\"\n\n\ncheck(Solution().maximumBinaryString)"} | coding | 199 |
Solve the programming task below in a Python markdown code block.
A group of $n$ dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of them — a bla... | {"inputs": ["1 100 1\n0\n", "1 1 100\n2\n", "1 100 1\n2\n", "2 9 6\n2 2\n", "1 1 100\n1\n", "1 100 1\n1\n", "1 1 100\n0\n", "2 1 1\n2 2\n"], "outputs": ["0\n", "1\n", "1\n", "12\n", "0\n", "0\n", "0\n", "2\n"]} | coding | 637 |
Solve the programming task below in a Python markdown code block.
Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive factor of that number other than the number itself. For example, the proper diviso... | {"functional": "_inputs = [[220, 284], [220, 280], [1184, 1210], [220221, 282224], [10744, 10856], [299920, 9284], [999220, 2849], [122265, 139815]]\n_outputs = [[True], [False], [True], [False], [True], [False], [False], [True]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, ... | coding | 283 |
Solve the programming task below in a Python markdown code block.
Valera has array a, consisting of n integers a_0, a_1, ..., a_{n} - 1, and function f(x), taking an integer from 0 to 2^{n} - 1 as its single argument. Value f(x) is calculated by formula $f(x) = \sum_{i = 0}^{n - 1} a_{i} \cdot b i t(i)$, where value bi... | {"inputs": ["1\n0\n1\n", "1\n1\n0\n", "1\n1\n1\n", "1\n0\n0\n", "1\n1\n1\n", "1\n0\n1\n", "1\n1\n0\n", "1\n0\n0\n"], "outputs": ["0\n", "0\n", "1\n", "0\n", "1\n", "0\n", "0\n", "0\n"]} | coding | 515 |
Solve the programming task below in a Python markdown code block.
You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck.
$\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\... | {"inputs": ["chris alan\n"], "outputs": ["Chris Alan\n"]} | coding | 641 |
Solve the programming task below in a Python markdown code block.
Bear Limak likes watching sports on TV. He is going to watch a game today. The game lasts 90 minutes and there are no breaks.
Each minute can be either interesting or boring. If 15 consecutive minutes are boring then Limak immediately turns TV off.
You... | {"inputs": ["1\n1\n", "1\n1\n", "1\n5\n", "1\n9\n", "1\n3\n", "1\n4\n", "1\n8\n", "1\n6\n"], "outputs": ["16\n", "16\n", "20\n", "24\n", "18\n", "19\n", "23\n", "21\n"]} | coding | 383 |
Solve the programming task below in a Python markdown code block.
You are given an array $a$, consisting of $n$ positive integers.
Let's call a concatenation of numbers $x$ and $y$ the number that is obtained by writing down numbers $x$ and $y$ one right after another without changing the order. For example, a concate... | {"inputs": ["4 2\n2 78 4 2\n", "4 2\n1 78 4 2\n", "4 2\n2 78 4 10\n", "4 4\n1 130 4 2\n", "4 2\n1 130 4 2\n", "4 2\n2 78 4 10\n", "5 2\n3 7 19 3 3\n", "1 2\n1000000000\n"], "outputs": ["12\n", "9\n", "12\n", "3\n", "9\n", "12", "0\n", "0\n"]} | coding | 497 |
Solve the programming task below in a Python markdown code block.
Zaikia has $N$ sticks of distinct positive lengths $A_1,A_2,\dots,A_N$. For no good reason at all, he wants to know if there is a triplet of sticks which when connected end-to-end will form a non-trivial triangle. Here non-trivial refers to a triangle wi... | {"inputs": ["5\n4 2 10 3 5"], "outputs": ["YES\n5 4 3"]} | coding | 418 |
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing a game. Initially, they are given a non-empty string $s$, consisting of lowercase Latin letters. The length of the string is even. Each player also has a string of their own, initially empty.
Alice starts, then they alternate m... | {"inputs": ["2\nforces\nabba\n"], "outputs": ["Alice\nDraw\n"]} | coding | 597 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an encoded string, return its decoded string.
The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a pos... | {"functional": "def check(candidate):\n assert candidate(s = \"3[a]2[bc]\") == \"aaabcbc\"\n assert candidate(s = \"3[a2[c]]\") == \"accaccacc\"\n assert candidate(s = \"2[abc]3[cd]ef\") == \"abcabccdcdcdef\"\n assert candidate(s = \"abc3[cd]xyz\") == \"abccdcdcdxyz\"\n\n\ncheck(Solution().decodeString)"} | coding | 183 |
Solve the programming task below in a Python markdown code block.
You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break the chocolate bar.
In one move you can break any single rectangular piece of chocolate in two rectangular pieces. You c... | {"inputs": ["4\n2 2 1\n2 2 3\n2 2 2\n2 2 4\n", "4\n2 2 1\n2 2 1\n2 2 2\n2 2 4\n", "4\n2 2 2\n2 2 1\n2 2 2\n2 2 4\n", "4\n2 2 4\n2 2 1\n2 2 2\n2 2 4\n", "4\n2 1 1\n2 2 3\n2 2 2\n2 2 4\n", "4\n2 1 1\n2 2 3\n2 2 2\n4 2 4\n", "4\n2 2 2\n2 2 1\n4 2 2\n2 2 2\n", "4\n2 1 1\n2 3 3\n2 2 2\n4 2 8\n"], "outputs": ["5\n5\n4\n0\n",... | coding | 524 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two identical eggs and you have access to a building with n floors labeled from 1 to n.
You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will brea... | {"functional": "def check(candidate):\n assert candidate(n = 2) == 2\n assert candidate(n = 100) == 14\n\n\ncheck(Solution().twoEggDrop)"} | coding | 190 |
Solve the programming task below in a Python markdown code block.
You are given a tree with $N$ vertices (numbered $1$ through $N$) and a sequence of integers $A_1, A_2, \ldots, A_N$. You may choose an arbitrary permutation $p_1, p_2, \ldots, p_N$ of the integers $1$ through $N$. Then, for each vertex $i$, you should a... | {"inputs": ["2\n4\n1 2 3 4\n1 2\n2 3\n2 4\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5"], "outputs": ["24\n15"]} | coding | 591 |
Solve the programming task below in a Python markdown code block.
This is now a little serie :)
Funny Dots
You will get two Integer n (width) and m (height) and your task is to draw following pattern. Each line is seperated with '\n'.
Both integers are equal or greater than 1. No need to check for invalid parameters... | {"functional": "_inputs = [[1, 1], [3, 2]]\n_outputs = [['+---+\\n| o |\\n+---+'], ['+---+---+---+\\n| o | o | o |\\n+---+---+---+\\n| o | o | o |\\n+---+---+---+']]\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=... | coding | 207 |
Solve the programming task below in a Python markdown code block.
After the phenomenal success of the 36th Chamber of Shaolin, San Te has decided to start 37th Chamber of Shaolin. The aim this time is to equip women with shaolin self-defence techniques.
The only condition for a woman to be eligible for the special tra... | {"inputs": ["3\n3\n15 23 65\n3\n15 62 16\n2\n35 9"], "outputs": ["2\n2\n1"]} | coding | 462 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
Given an integer x, return true if x is a palindrome, and false otherwise.
Â
Please complete the following python code precisely:
```python
class Solution:
def isPalindrome(self, x: int) -> bool:
``` | {"functional": "def check(candidate):\n assert candidate(x = 121) == True\n assert candidate(x = -121) == False\n assert candidate(x = 10) == False\n\n\ncheck(Solution().isPalindrome)"} | coding | 64 |
Solve the programming task below in a Python markdown code block.
You are given 2 numbers is `n` and `k`. You need to find the number of integers between 1 and n (inclusive) that contains exactly `k` non-zero digit.
Example1
`
almost_everywhere_zero(100, 1) return 19`
by following condition we have 19 numbers that ... | {"functional": "_inputs = [[100, 1], [11, 2], [20, 2], [101, 2], [10001, 2], [10001000, 2], [500309160, 2], [10000000000000000000000, 3], [10000000000000000000000, 21], [1203, 4]]\n_outputs = [[19], [1], [9], [82], [487], [1729], [2604], [1122660], [2407217760893271902598], [81]]\nimport math\ndef _deep_eq(a, b, tol=1e... | coding | 250 |
Solve the programming task below in a Python markdown code block.
Polycarp has $x$ of red and $y$ of blue candies. Using them, he wants to make gift sets. Each gift set contains either $a$ red candies and $b$ blue candies, or $a$ blue candies and $b$ red candies. Any candy can belong to at most one gift set.
Help Poly... | {"inputs": ["9\n8 9 2 8\n0 0 2 2\n38 204 6 13\n1010010010 0000000000 6 2\n1000000000 2 1 0100001000\n1 1000100110 1000011100 1\n1 0 1 1\n6 8 2 2\n4 1 2 5\n", "9\n10 8 2 5\n1 1 2 2\n52 311 22 9\n1000000000 1000000000 1 1\n1000000000 1 1 1000000000\n1 1000000000 1000000000 1\n1 1 1 1\n7 8 1 2\n4 1 2 3\n", "9\n10 8 2 5\n1... | coding | 492 |
Solve the programming task below in a Python markdown code block.
Given a $6\times6$ 2D Array, $\textbf{arr}$:
1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
An hourglass in $\mbox{A}$ is a subset of values with indices falling in this pattern in $\textbf{arr}$'s graphical representation:
a... | {"inputs": ["1 1 1 0 0 0\n0 1 0 0 0 0\n1 1 1 0 0 0\n0 0 2 4 4 0\n0 0 0 2 0 0\n0 0 1 2 4 0\n"], "outputs": ["19\n"]} | coding | 727 |
Solve the programming task below in a Python markdown code block.
Arkady coordinates rounds on some not really famous competitive programming platform. Each round features $n$ problems of distinct difficulty, the difficulties are numbered from $1$ to $n$.
To hold a round Arkady needs $n$ new (not used previously) prob... | {"inputs": ["1 1\n1\n", "1 1\n1\n", "9 1\n1\n", "2 1\n1\n", "3 1\n1\n", "10 1\n1\n", "10 1\n1\n", "10 1\n2\n"], "outputs": ["1\n", "1", "0\n", "0\n", "0\n", "0\n", "0", "0\n"]} | coding | 492 |
Solve the programming task below in a Python markdown code block.
Chef is here with another matrix A having N rows and M columns,
such that A_{(i,j)} = (i-1)\cdot M+j.
Chef decided to make this matrix interesting. He performed K operations on the matrix. In each operation, he will choose either a row or column and ... | {"inputs": ["2\n2 2 2\n1 2 0\n0 1 2\n1 3 1\n1 2 6"], "outputs": ["5\n16\n"]} | coding | 712 |
Solve the programming task below in a Python markdown code block.
This kata aims to show the vulnerabilities of hashing functions for short messages.
When provided with a SHA-256 hash, return the value that was hashed. You are also given the characters that make the expected value, but in alphabetical order.
The retu... | {"functional": "_inputs = [['b8c49d81cb795985c007d78379e98613a4dfc824381be472238dbd2f974e37ae', 'deGioOstu'], ['f58262c8005bb64b8f99ec6083faf050c502d099d9929ae37ffed2fe1bb954fb', 'abc']]\n_outputs = [['GoOutside'], [None]]\nimport math\ndef _deep_eq(a, b, tol=1e-5):\n if isinstance(a, float) or isinstance(b, float):... | coding | 211 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
A substring is a contiguous (non-empty) sequence of characters within a string.
A vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it.
Given ... | {"functional": "def check(candidate):\n assert candidate(word = \"aeiouu\") == 2\n assert candidate(word = \"unicornarihan\") == 0\n assert candidate(word = \"cuaieuouac\") == 7\n assert candidate(word = \"bbaeixoubb\") == 0\n\n\ncheck(Solution().countVowelSubstrings)"} | coding | 117 |
Solve the programming task below in a Python markdown code block.
There's a new security company in Paris, and they decided to give their employees an algorithm to make first name recognition faster. In the blink of an eye, they can now detect if a string is a first name, no matter if it is a one-word name or an hyphen... | {"functional": "_inputs = [['Francis'], ['Jean-Eluard'], ['Le Mec'], ['Bernard-Henry-Levy'], ['Meme Gertrude'], ['A-a-a-a----a-a'], ['Z-------------'], ['Jean-luc'], ['Jean--Luc'], ['JeanLucPicard'], ['-Jean-Luc'], ['Jean-Luc-Picard-']]\n_outputs = [[True], [True], [False], [True], [False], [False], [False], [False], [... | coding | 321 |
Solve the programming task below in a Python markdown code block.
Two T-shirt sizes are given: $a$ and $b$. The T-shirt size is either a string M or a string consisting of several (possibly zero) characters X and one of the characters S or L.
For example, strings M, XXL, S, XXXXXXXS could be the size of some T-shirts.... | {"inputs": ["1\nM S\n", "3\nM XS\nM S\nS M\n", "3\nM XS\nM S\nM M\n", "6\nS L\nL S\nM L\nL M\nS M\nM S\n", "5\nM XS\nM XS\nM XS\nM XS\nM XS\n", "1\nXXXXXXXXXXXXXXXXS XXXXXXXXXXS\n", "5\nXS XXXS\nXXL M\nXXS M\nM XXS\nXXS XXS\n", "6\nXXXS XS\nXXXL XL\nXL M\nXXL XXL\nXXXXXS M\nL M\n"], "outputs": [">\n", ">\n>\n<\n", ">\n... | coding | 440 |
Solve the programming task below in a Python markdown code block.
AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $n$ cities in Italy indexed from $1$ to $n$ and $m$ directed roads indexed from $1$ to $m$. Initially, Keshi is located in the city $1$ and wants to go to AmShZ's house in the ci... | {"inputs": ["2 1\n1 2\n", "4 4\n1 2\n1 4\n2 4\n1 4\n", "5 7\n1 2\n2 3\n3 5\n1 4\n4 3\n4 5\n3 1\n"], "outputs": ["1\n", "2\n", "4\n"]} | coding | 713 |
Solve the programming task below in a Python markdown code block.
Takahashi and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obstacles on this grid; the i-th obstacle is at (X_i,Y_i). Here, we represent the cell at the i-th row and j-th column (1 \leq i \leq H, 1 \leq j \leq... | {"inputs": ["3 6 1\n3 2", "3 4 1\n3 2", "5 6 1\n3 2", "3 3 1\n3 2", "100001 100000 0", "100101 100000 0", "110101 100000 0", "110111 100000 0"], "outputs": ["2\n", "2\n", "2\n", "2", "100001\n", "100101\n", "110101\n", "110111\n"]} | coding | 575 |
Solve the programming task below in a Python markdown code block.
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed dir... | {"inputs": ["1\n1\n0\n", "1\n1\n1\n", "1\n1\n0\n", "1\n1\n1\n", "2\n1 2\n0 0\n", "2\n2 1\n0 0\n", "2\n1 2\n0 1\n", "2\n2 1\n1 0\n"], "outputs": ["1\n", "0\n", "1\n", "0\n", "3\n", "1\n", "2\n", "0\n"]} | coding | 541 |
Solve the programming task below in a Python markdown code block.
In this challenge, the task is to debug the existing code to successfully execute all provided test files.
Given two strings consisting of digits 0 and 1 only, find the XOR of the two strings.
To know more about XOR Click Here
Debug the given function... | {"inputs": ["10101\n00101\n"], "outputs": ["10000\n"]} | coding | 322 |
Please solve the programming task below using a self-contained code snippet in a markdown code block.
You are given two strings s and t consisting of only lowercase English letters.
Return the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s.
A subsequence is a... | {"functional": "def check(candidate):\n assert candidate(s = \"coaching\", t = \"coding\") == 4\n assert candidate(s = \"abcde\", t = \"a\") == 0\n assert candidate(s = \"z\", t = \"abcde\") == 5\n\n\ncheck(Solution().appendCharacters)"} | coding | 120 |
Solve the programming task below in a Python markdown code block.
Read problem statements in [Mandarin], [Russian], and [Vietnamese] as well.
Chef is a great mechanic. As the cost of petrol is increasing day by day he decided to build a water car to take his girlfriend Natasha on a date. Water car has great build qual... | {"inputs": ["3\n3 1\n4 2\n4 3\n"], "outputs": ["3 3\n6 4\n6 3\n"]} | coding | 554 |
Solve the programming task below in a Python markdown code block.
A bracket sequence is a string, containing only characters "(", ")", "[" and "]".
A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original char... | {"inputs": ["[[]\n", "([]\n", "()(\n", "))(\n", "*)(\n", "(((\n", "[[])\n", "(][)\n"], "outputs": ["1\n[]", "1\n[]", "0\n\n", "0\n\n", "0\n\n", "0\n\n", "1\n[]", "0\n"]} | coding | 330 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.