formatted_conversations
stringlengths
1.13k
138k
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An onion array is an array that satisfies the following condition for all values of `j` and `k`: If all of the following are `true`: * `j >= 0` * `k >= 0` * `j + k = array.l...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Fixed xor Write a function that takes two hex strings as input and XORs them against each other. If the strings are different lengths the output should be the length of th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In some ranking people collects points. The challenge is sort by points and calulate position for every person. But remember if two or more persons have same number of points,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A country has coins with denominations ```python coins_list = d1 < d2 < · · · < dn. ``` You want to make change for n cents, using the smallest number of coins. ```python # E...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task A ciphertext alphabet is obtained from the plaintext alphabet by means of rearranging some characters. For example "bacdef...xyz" will be a simple ciphertext alphabet ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.NOTE: It is recommended you complete [Introduction to Esolangs](https://www.codewars.com/kata/esolang-interpreters-number-1-introduction-to-esolangs-and-my-first-interpreter-m...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A group of friends (n >= 2) have reunited for a get-together after a very long time. They agree that they will make presentations on holiday destinations or expeditions th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Define a "prime prime" number to be a rational number written as one prime number over another prime number: `primeA / primeB` (e.g. `7/31`) Given a whole number `N`, generat...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An array is called `zero-balanced` if its elements sum to `0` and for each positive element `n`, there exists another element that is the negative of `n`. Write a function nam...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A core idea of several left-wing ideologies is that the wealthiest should *support* the poorest, no matter what and that is exactly what you are called to do using this kata (...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this kata, we want to discover a small property of numbers. We say that a number is a **dd** number if it contains d occurences of a digit d, (d is in [1,9]). ## Examples...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your task is to get Zodiac Sign using input ```day``` and ```month```. For exapmle: ```python get_zodiac_sign(1,5) => 'Taurus' get_zodiac_sign(10,10) => 'Libra' ``` Correc...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This kata is inspired on the problem #50 of the Project Euler. The prime ``` 41``` is the result of the sum of many consecutive primes. In fact, ``` 2 + 3 + 5 + 7 + 11 + 1...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Description: Count the number of exclamation marks and question marks, return the product. # Examples ``` Product("") == 0 product("!") == 0 Product("!ab? ?") == 2 Produ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.>When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said # Description: In kinderg...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task You are given a regular array `arr`. Let's call a `step` the difference between two adjacent elements. Your task is to sum the elements which belong to the sequenc...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.>When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said # Description: Give you...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two numbers and an arithmetic operator (the name of it, as a string), return the result of the two numbers having that operator used on them. ```a``` and ```b``` will ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Time to win the lottery! Given a lottery ticket (ticket), represented by an array of 2-value arrays, you must find out if you've won the jackpot. Example ticket: To do this...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The __Hamming weight__ of a string is the number of symbols that are different from the zero-symbol of the alphabet used. There are several algorithms for efficient computing ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have to create a function named reverseIt. Write your function so that in the case a string or a number is passed in as the data , you will return the data in reverse ord...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every positive integer number, that is not prime, may be decomposed in prime factors. For example the prime factors of 20, are: ``` 2, 2, and 5, because: 20 = 2 . 2 . 5 ``` T...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the d...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Gematria is an Assyro-Babylonian-Greek system of code and numerology later adopted into Jewish culture. The system assigns numerical value to a word or a phrase in the belief ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Ever the learned traveller, Alan Partridge has pretty strong views on London: ``` "Go to London. I guarantee you'll either be mugged or not appreciated. Catch the train to Lo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Imagine a funnel filled with letters. The bottom letter drops out of the funnel and onto a conveyor belt: ``` \b,c/ --> \b,c/ \a/ --> \ / a ----...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every now and then people in the office moves teams or departments. Depending what people are doing with their time they can become more or less boring. Time to assess the cur...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Bob has a server farm crunching numbers. He has `nodes` servers in his farm. His company has a lot of work to do. The work comes as a number `workload` which indicates how m...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Yup!! The problem name reflects your task; just add a set of numbers. But you may feel yourselves condescended, to write a C/C++ program just to add a set of numbers. Such a p...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Find the difference between two collections. The difference means that either the character is present in one collection or it is present in other, but not in both. Return a s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We have an integer array with unique elements and we want to do the permutations that have an element fixed, in other words, these permutations should have a certain element a...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this Kata, you will be given an array of unique elements, and your task is to rerrange the values so that the first max value is followed by the first minimum, followed by ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a function that takes a string which has integers inside it separated by spaces, and your task is to convert each integer in the string into an integer and return their ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are a biologist working on the amino acid composition of proteins. Every protein consists of a long chain of 20 different amino acids with different properties. Currentl...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Assume we take a number `x` and perform any one of the following operations: ```Pearl a) Divide x by 3 (if it is divisible by 3), or b) Multiply x by 2 ``` After each operatio...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Grains Write a program that calculates the number of grains of wheat on a chessboard given that the number on each square is double the previous one. There are 64 squares ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.I have started studying electronics recently, and I came up with a circuit made up of 2 LEDs and 3 buttons. Here 's how it works: 2 buttons (`red` and `blue`) are connected t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the function that takes 3 numbers `x, y and k` (where `x ≤ y`), and returns the number of integers within the range `[x..y]` (both ends included) that are divisible b...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a program that will take a string of digits and give you all the possible consecutive slices of length `n` in that string. Raise an error if `n` is larger than the leng...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your job is to change the given string `s` using a non-negative integer `n`. Each bit in `n` will specify whether or not to swap the case for each alphabetic character in `s`...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider X as the aleatory variable that count the number of letters in a word. Write a function that, give in input an array of words (strings), calculate the variance of...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Happy traveller [Part 1] There is a play grid NxN; Always square! 0 1 2 3 0 [o, o, o, X] 1 [o, o, o, o] 2 [o, o, o, o] 3 [o, o, o, o] You start from a random point....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a certain integer, ```n, n > 0```. You have to search the partition or partitions, of n, with maximum product value. Let'see the case for ```n = 8```. ``` Parti...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Exclusive "or" (xor) Logical Operator ## Overview In some scripting languages like PHP, there exists a logical operator (e.g. ```&&```, ```||```, ```and```, ```or```, etc....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Problem There are `n` apples that need to be divided into four piles. We need two mysterious number `x` and `y`. Let The number of first pile equals to `x+y`, the number o...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You will be given a string (x) featuring a cat 'C' and a mouse 'm'. The rest of the string will be made up of '.'. You need to find out if the cat can catch the mouse from i...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two positive integers `a` and `b` (`a < b <= 20000`). Complete the function which returns a list of all those numbers in the interval `[a, b)` whose digits are m...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement `String#whitespace?(str)` (Ruby), `String.prototype.whitespace(str)` (JavaScript), `String::whitespace(str)` (CoffeeScript), or `whitespace(str)` (Python), which sho...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.While most devs know about [big/little-endianness](https://en.wikipedia.org/wiki/Endianness), only a selected few know the secret of real hard core coolness with mid-endians. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We define the sequence ```SF``` in the following way in terms of four previous sequences: ```S1```, ```S2```, ```S3``` and ```ST``` We are interested in collecting the term...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We define the score of permutations of combinations, of an integer number (the function to obtain this value:```sc_perm_comb```) as the total sum of all the numbers obtained f...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You're given a string of dominos. For each slot, there are 3 options: * "|" represents a standing domino * "/" represents a knocked over domino * " " represents a spa...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Make a function that returns the value multiplied by 50 and increased by 6. If the value entered is a string it should return "Error". Note: in `C#`, you'll always get the in...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a string of integers, return the number of odd-numbered substrings that can be formed. For example, in the case of `"1341"`, they are `1, 1, 3, 13, 41, 341, 1341`, a t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In number theory, Euler's totient is an arithmetic function, introduced in 1763 by Euler, that counts the positive integers less than or equal to `n` that are relatively prime...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In programming you know the use of the logical negation operator (**!**), it reverses the meaning of a condition. Your task is to complete the function 'negationValue()' that...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You get an array of different numbers to sum up. But there is one problem, those numbers all have different bases. For example: ```python You get an array of numbers with thei...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Challenge: Given a two-dimensional array, return a new array which carries over only those arrays from the original, which were not empty and whose items are all of the same ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Here you have to do some mathematical operations on a "dirty string". This kata checks some basics, it's not too difficult. __So what to do?__ Input: String which consists ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task You are given two string `a` an `s`. Starting with an empty string we can do the following two operations: ``` append the given string a to the end of the current stri...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this kata, you've to count lowercase letters in a given string and return the letter count in a hash with 'letter' as key and count as 'value'. The key must be 'symbol' ins...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Suppose I have two vectors: `(a1, a2, a3, ..., aN)` and `(b1, b2, b3, ..., bN)`. The dot product between these two vectors is defined as: ``` a1*b1 + a2*b2 + a3*b3 + ... + aN...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An acrostic is a text in which the first letter of each line spells out a word. It is also a quick and cheap way of writing a poem for somebody, as exemplified below : Writ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your task is to define a function that understands basic mathematical expressions and solves them. For example: ```python calculate("1 + 1") # => 2 calculate("18 + 4*6...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Your task is to find the smallest number which is evenly divided by all numbers between `m` and `n` (both inclusive). # Example For `m = 1, n = 2`, the output shoul...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Alireza and Ali have a `3×3 table` and playing on that. they have 4 table(2×2) A,B,C and D in this table. At beginning all of 9 numbers in 3×3 table is zero. Ali...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.How much bigger is a 16-inch pizza compared to an 8-inch pizza? A more pragmatic question is: How many 8-inch pizzas "fit" in a 16-incher? The answer, as it turns out, is exa...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this Kata, you will be given a string with brackets and an index of an opening bracket and your task will be to return the index of the matching closing bracket. Both the ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a number `n`, make a down arrow shaped pattern. For example, when `n = 5`, the output would be: 123454321 1234321 12321 121 1 and for `n...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Description: The mean (or average) is the most popular measure of central tendency; however it does not behave very well when the data is skewed (i.e. wages distribution). In...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this simple assignment you are given a number and have to make it negative. But maybe the number is already negative? **Example:** ``` c makeNegative(1); // return -1 make...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task You are given a string `s`. Let's call its substring a group, if all letters in it are adjacent and the same(such as `"aa","bbb","cccc"`..). Let's call the substiring ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Make a function **"add"** that will be able to sum elements of **list** continuously and return a new list of sums. For example: ``` add [1,2,3,4,5] == [1, 3, 6, 10, 15], b...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A nested list (or *array* in JavaScript) is a list that apears as a value inside another list, ```python [item, item, [item, item], item] ``` in the above list, [item, item] ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this exercise, you will have to create a function named tiyFizzBuzz. This function will take on a string parameter and will return that string with some characters replaced...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array (or list) of scores, return the array of _ranks_ for each value in the array. The largest value has rank 1, the second largest value has rank 2, and so on. Tie...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A family of kookaburras are in my backyard. I can't see them all, but I can hear them! # How many kookaburras are there? ## Hint The trick to counting kookaburras is t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a function that calculates the *least common multiple* of its arguments; each argument is assumed to be a non-negative integer. In the case that there are no arguments (...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.To celebrate the start of the Rio Olympics (and the return of 'the Last Leg' on C4 tonight) this is an Olympic inspired kata. Given a string of random letters, you need to ex...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The pizza store wants to know how long each order will take. They know: - Prepping a pizza takes 3 mins - Cook a pizza takes 10 mins - Every salad takes 3 mins to make - Ever...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Solve For X You will be given an equation as a string and you will need to [solve for X](https://www.mathplacementreview.com/algebra/basic-algebra.php#solve-for-a-variable)...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write function heron which calculates the area of a triangle with sides a, b, and c. Heron's formula: sqrt (s \* (s - a) \* (s - b) \* (s - c)), where s = (a + b + c) / 2. Ou...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.HELP! Jason can't find his textbook! It is two days before the test date, and Jason's textbooks are all out of order! Help him sort a list (ArrayList in java) full of textbook...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Create a function xMasTree(height) that returns a christmas tree of the correct height. The height is passed through to the function and the function should return a list cont...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task Your challenge is to write a function named `getSlope`/`get_slope`/`GetSlope` that calculates the slope of the line through two points. ## Input ```if:javascript,py...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.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: ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this kata, you need to make a (simplified) LZ78 encoder and decoder. [LZ78](https://en.wikipedia.org/wiki/LZ77_and_LZ78#LZ78) is a dictionary-based compression method creat...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task The sequence of `Chando` is an infinite sequence of all Chando's numbers in ascending order. A number is called `Chando's` if it is an integer that can be represente...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In another Kata I came across a weird `sort` function to implement. We had to sort characters as usual ( 'A' before 'Z' and 'Z' before 'a' ) except that the `numbers` had to b...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a list of white pawns on a chessboard (any number of them, meaning from 0 to 64 and with the possibility to be positioned everywhere), determine how many of them have th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Count the number of divisors of a positive integer `n`. Random tests go up to `n = 500000`. ## Examples ```python divisors(4) == 3 # 1, 2, 4 divisors(5) == 2 # 1, 5 divi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For a pole vaulter, it is very important to begin the approach run at the best possible starting mark. This is affected by numerous factors and requires fine-tuning in practic...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the function that accepts a valid string and returns an integer. Wait, that would be too easy! Every character of the string should be converted to the hex value of ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Create a function that returns the average of an array of numbers ("scores"), rounded to the nearest whole number. You are not allowed to use any loops (including for, for/in,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task You are given an array of integers. On each move you are allowed to increase exactly one of its element by one. Find the minimal number of moves required to obtain a ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A hero is on his way to the castle to complete his mission. However, he's been told that the castle is surrounded with a couple of powerful dragons! each dragon takes 2 bullet...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two strings. In a single move, you can choose any of them, and delete the first (i.e. leftmost) character. For Example: * By applying a move to the string `"wh...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have an array of numbers. Your task is to sort ascending odd numbers but even numbers must be on their places. Zero isn't an odd number and you don't need to move it. I...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Pythagorean Triples A Pythagorean triplet is a set of three numbers a, b, and c where `a^2 + b^2 = c^2`. In this Kata, you will be tasked with finding the Pythagorean tripl...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Define n!! as n!! = 1 \* 3 \* 5 \* ... \* n if n is odd, n!! = 2 \* 4 \* 6 \* ... \* n if n is even. Hence 8!! = 2 \* 4 \* 6 \* 8 = 384, there is no zero at the end. 3...