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.## Terminal game move function In this game, the hero moves from left to right. The player rolls the dice and moves the number of spaces indicated by the dice **two times**. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement `String.eight_bit_signed_number?` (Ruby), `String.eightBitSignedNumber()` (Python), `eight_bit_signed_number()` (JS) or `StringUtils.isSignedEightBitNumber(String)` ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two words and a letter, return a single word that's a combination of both words, merged at the point where the given letter first appears in each word. The returned word...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You certainly can tell which is the larger number between 2^(10) and 2^(15). But what about, say, 2^(10) and 3^(10)? You know this one too. Things tend to get a bit more com...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider the following numbers (where `n!` is `factorial(n)`): ``` u1 = (1 / 1!) * (1!) u2 = (1 / 2!) * (1! + 2!) u3 = (1 / 3!) * (1! + 2! + 3!) ... un = (1 / n!) * (1! + 2! +...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The squarefree part of a positive integer is the largest divisor of that integer which itself has no square factors (other than 1). For example, the squareefree part of 12 is ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For building the encrypted string:Take every 2nd char from the string, then the other chars, that are not every 2nd char, and concat them as new String. Do this n times! Exam...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have been recruited by an unknown organization for your cipher encrypting/decrypting skills. Being new to the organization they decide to test your skills. Your first ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The look and say sequence is a sequence in which each number is the result of a "look and say" operation on the previous element. Considering for example the classical versio...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Americans are odd people: in their buildings, the first floor is actually the ground floor and there is no 13th floor (due to superstition). Write a function that given a flo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Is the number even? If the numbers is even return `true`. If it's odd, return `false`. Oh yeah... the following symbols/commands have been disabled! use of ```%``` use ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.General primality test are often computationally expensive, so in the biggest prime number race the idea is to study special sub-families of prime number and develop more effe...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Find the longest substring in alphabetical order. Example: the longest alphabetical substring in `"asdfaaaabbbbcttavvfffffdf"` is `"aaaabbbbctt"`. There are tests with strin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Hi there! You have to implement the `String get_column_title(int num) // syntax depends on programming language` function that takes an integer number (index of the Excel ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.What's in a name? ..Or rather, what's a name in? For us, a particular string is where we are looking for a name. Task Test whether or not the string contains all of the lett...
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 in a binary string and returns the equivalent decoded text (the text is ASCII encoded). Each 8 bits on the binary string represent 1 character on ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A [Narcissistic Number](https://en.wikipedia.org/wiki/Narcissistic_number) is a positive number which is the sum of its own digits, each raised to the power of the number of d...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in...
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 `sierpinski` to generate an ASCII representation of a Sierpinski triangle of order **N**. Seperate each line with `\n`. You don't have to check the input v...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42. These divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764. The sum of the squared divisors is 2500 which is 50 * 50, a square...
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 remove all duplicate words from a string, leaving only single (first) words entries. Example: Input: 'alpha beta beta gamma gamma gamma delta alpha beta bet...
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 accepts two square matrices (`N x N` two dimensional arrays), and return the sum of the two. Both matrices being passed into the function will be of size...
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 define an arithmetic progression as a series of integers in which the differences between adjacent numbers are the same. You will be given an array of ints of...
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 random string of letters and tasked with returning them as a string of comma-separated sequences sorted alphabetically, with each sequence sta...
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` of digital numbers, return a new array of length `number` containing the last even numbers from the original array (in the same order). The original array wil...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.With one die of 6 sides we will have six different possible results:``` 1, 2, 3, 4, 5, 6``` . With 2 dice of six sides, we will have 36 different possible results: ``` (1,1...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This kata focuses on the Numpy python package and you can read up on the Numpy array manipulation functions here: https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.ar...
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 and two indexes (`a` and `b`). Your task is to reverse the portion of that string between those two indices inclusive. ~~~if-not:for...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A **pandigital number** is one that has its digits from ```1``` to ```9``` occuring only once (they do not have the digit 0). The number ```169```, is the first pandigital sq...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Number is a palindrome if it is equal to the number with digits in reversed order. For example, 5, 44, 171, 4884 are palindromes and 43, 194, 4773 are not palindromes. Write ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Check Digits Some numbers are more important to get right during data entry than others: a common example is product codes. To reduce the possibility of mistakes, product...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Introduction Fish are an integral part of any ecosystem. Unfortunately, fish are often seen as high maintenance. Contrary to popular belief, fish actually reduce pond main...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task You got a `scratch lottery`, you want to know how much money you win. There are `6` sets of characters on the lottery. Each set of characters represents a chance to w...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The description is rather long but it tries to explain what a financing plan is. The fixed monthly payment for a fixed rate mortgage is the amount paid by the borrower every...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every natural number, ```n```, may have a prime factorization like: We define the **geometric derivative of n**, as a number with the following value: For example: calcu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Finish the solution so that it sorts the passed in array of numbers. If the function passes in an empty array or null/nil value then it should return an empty array. For exam...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Introduction: Reversi is a game usually played by 2 people on a 8x8 board. Here we're only going to consider a single 8x1 row. Players take turns placing pieces, which are...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Given a string `str`, find the shortest possible string which can be achieved by adding characters to the end of initial string to make it a palindrome. # Example F...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.John is developing a system to report fuel usage but needs help with the coding. First, he needs you to write a function that, given the actual consumption (in l/100 km) and ...
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 `N` ropes, where the length of each rope is a positive integer. At each step, you have to reduce all the ropes by the length of the smallest rope. The...
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 create a function that takes in a list and returns a list with the reverse order. ### Examples ```python reverse_list([1,2,3,4]) == [4,3,2,1] reverse_l...
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 will encrypt a given sentence into International Morse Code, both the input and out puts will be strings. Characters should be separated by a single spa...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Given a sorted array of integers `A`, find such an integer x that the value of `abs(A[0] - x) + abs(A[1] - x) + ... + abs(A[A.length - 1] - x)` is the smallest possibl...
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 this K...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Jamie is a programmer, and James' girlfriend. She likes diamonds, and wants a diamond string from James. Since James doesn't know how to make this happen, he needs your help. ...
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 numbers and a number `n`, and your task will be to determine if `any` array elements, when summed (or taken individually), are divi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A [Word Square](https://en.wikipedia.org/wiki/Word_square) is a set of words written out in a square grid, such that the same words can be read both horizontally and verticall...
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 to calculate compound tax using the following table: For $10 and under, the tax rate should be 10%. For $20 and under, the tax rate on the first $10 is %10, ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There is an array with some numbers. All numbers are equal except for one. Try to find it! ```python find_uniq([ 1, 1, 1, 2, 1, 1 ]) == 2 find_uniq([ 0, 0, 0.55, 0, 0 ]) == 0...
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 ```circleArea``` so that it will return the area of a circle with the given ```radius```. Round the returned number to two decimal places (except for Has...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# A wolf in sheep's clothing Wolves have been reintroduced to Great Britain. You are a sheep farmer, and are now plagued by wolves which pretend to be sheep. Fortunately, you...
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 containing only zeros and ones, find the index of the zero that, if converted to one, will make the longest sequence of ones. For instance, given the array: `...
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 two numbers `m,n`. The numbers could span from `0` to `10000`. We can get their product by using binary reduction as show in the table below. Example (to und...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Introduction There is a war and nobody knows - the alphabet war! There are two groups of hostile letters. The tension between left side letters and right side letters was...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Description In English we often use "neutral vowel sounds" such as "umm", "err", "ahh" as fillers in conversations to help them run smoothly. Bob always finds himself saying...
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 secret message you need to decipher. Here are the things you need to know to decipher it: For each word: - the second and the last letter is switched (e.g. `H...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If we multiply the integer `717 (n)` by `7 (k)`, the result will be equal to `5019`. Consider all the possible ways that this last number may be split as a string and ca...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an integer `n`, find two integers `a` and `b` such that: ```Pearl A) a >= 0 and b >= 0 B) a + b = n C) DigitSum(a) + Digitsum(b) is maximum of all possibilities. ``` Y...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Description Given a number `n`, you should find a set of numbers for which the sum equals `n`. This set must consist exclusively of values that are a power of `2` (eg: `2^0...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.It's the academic year's end, fateful moment of your school report. The averages must be calculated. All the students come to you and entreat you to calculate their average fo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A system is transmitting messages in binary, however it is not a perfect transmission, and sometimes errors will occur which result in a single bit flipping from 0 to 1, or fr...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task You're given a substring s of some cyclic string. What's the length of the smallest possible string that can be concatenated to itself many times to obtain this cyclic...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given the sum and gcd of two numbers, return those two numbers in ascending order. If the numbers do not exist, return `-1`, (or `NULL` in C, `tuple (-1,-1)` in C#, `pair (-1,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.#### Task: Your job here is to implement a method, `approx_root` in Ruby/Python/Crystal and `approxRoot` in JavaScript/CoffeeScript, that takes one argument, `n`, and returns...
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 name `nextPerfectSquare` that returns the first perfect square that is greater than its integer argument. A `perfect square` is a integer that is equal to som...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Due to another of his misbehaved, the primary school's teacher of the young Gauß, Herr J.G. Büttner, to keep the bored and unruly young schoolboy Karl Friedrich Gauss busy f...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The snail crawls up the column. During the day it crawls up some distance. During the night she sleeps, so she slides down for some distance (less than crawls up during the da...
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 an array that contains two strings. Your job is to create a function that will take those two strings and transpose them, so that the strings go from top to ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.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 am...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This challenge extends the previous [repeater()](https://www.codewars.com/kata/thinkful-string-drills-repeater) challenge. Just like last time, your job is to write a function...
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 finalGrade, which calculates the final grade of a student depending on two parameters: a grade for the exam and a number of completed projects. This functio...
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 accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return va...
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 two integers `n` and `k` and your task is to remove `k-digits` from `n` and return the lowest number possible, without changing the order of th...
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 ``string`` that contains only letters, you have to find out the number of **unique** strings (including ``string`` itself) that can be produced by re-arranging ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Two samurai generals are discussing dinner plans after a battle, but they can't seem to agree. The discussion gets heated and you are cannot risk favoring either of them as...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Introduction to Disjunctions In logic and mathematics, a disjunction is an operation on 2 or more propositions. A disjunction is true if and only if 1 or more of its operands...
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 `sumTimesTables` which sums the result of the sums of the elements specified in `tables` multiplied by all the numbers in between `min` and `max` including th...
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 should simply determine, whether a given year is a leap year or not. In case you don't know the rules, here they are: * years divisible by 4 are leap years *...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Description Write a function that checks whether a credit card number is correct or not, using the Luhn algorithm. The algorithm is as follows: * From the rightmost digit,...
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 will return ```true``` if the input is in the following date time format ```01-09-2016 01:20``` and ```false``` if it is not. This Kata has been inspir...
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 finds the [integral](https://en.wikipedia.org/wiki/Integral) of the expression passed. In order to find the integral all you need to do is add one to 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 `scramble(str1, str2)` that returns `true` if a portion of ```str1``` characters can be rearranged to match ```str2```, otherwise returns ```false```. ...
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 counts the number of unique consonants in a string (made up of printable ascii characters). Consonants are letters used in English other than `"a",...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The goal is to write a pair of functions the first of which will take a string of binary along with a specification of bits, which will return a numeric, signed complement in ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# MOD 256 without the MOD operator The MOD-operator % (aka mod/modulus/remainder): ``` Returns the remainder of a division operation. The sign of the result is the same as th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task You have set an alarm for some of the week days. Days of the week are encoded in binary representation like this: ``` 0000001 - Sunday 0000010 - Monday 0000100 - Tu...
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 write a function `doubles` that will remove double string characters that are adjacent to each other. For example: `doubles('abbcccdddda') = 'aca'`, b...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task Using `n` as a parameter in the function `pattern`, where `n>0`, complete the codes to get the pattern (take the help of examples): **Note:** There is no newline in...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement a function/class, which should return an integer if the input string is in one of the formats specified below, or `null/nil/None` otherwise. Format: * Optional `-` ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task The number is considered to be `unlucky` if it does not have digits `4` and `7` and is divisible by `13`. Please count all unlucky numbers not greater than `n`. # Exa...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Define a method that accepts 2 strings as parameters. The method returns the first string sorted by the second. ```python sort_string("foos", "of") == "oofs" sort_strin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Magic The Gathering is a collectible card game that features wizards battling against each other with spells and creature summons. The game itself can be quite complicated to ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We need a function (for commercial purposes) that may perform integer partitions with some constraints. The function should select how many elements each partition should have...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.As the title suggests, this is the hard-core version of another neat kata. The task is simple to explain: simply sum all the numbers from the first parameter being the begin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a method that takes a string as an argument and groups the number of time each character appears in the string as a hash sorted by the highest number of occurrences. Th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Create a program that will take in a string as input and, if there are duplicates of more than two alphabetical characters in the string, returns the string with all the extra...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This kata requires you to convert minutes (`int`) to hours and minutes in the format `hh:mm` (`string`). If the input is `0` or negative value, then you should return `"00:00...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Don't Drink the Water Given a two-dimensional array representation of a glass of mixed liquids, sort the array such that the liquids appear in the glass based on their densit...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task The game starts with `n` people standing in a circle. The presenter counts `m` people starting with the first one, and gives `1` coin to each of them. The rest of the ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Let's pretend your company just hired your friend from college and paid you a referral bonus. Awesome! To celebrate, you're taking your team out to the terrible dive bar next ...