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.The new football league season is coming and the Football Association need some help resetting the league standings. Normally the initial league standing is done in alphabetic...
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 write a function that does just what the title suggests (so, fair warning, be aware that you are not getting out of it just throwing a lame bas sorting method ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This is a follow up from my kata The old switcheroo Write ```python def encode(str) ``` that takes in a string ```str``` and replaces all the letters with their respective po...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Is every value in the array an array? This should only test the second array dimension of the array. The values of the nested arrays don't have to be arrays. Examples: ```...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Baby is getting his frst tooth. This means more sleepless nights, but with the fun of feeling round his gums and trying to guess which will be first out! Probably best have ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A series or sequence of numbers is usually the product of a function and can either be infinite or finite. In this kata we will only consider finite series and you are requir...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This challenge is based on [the kata](https://www.codewars.com/kata/n-smallest-elements-in-original-order) by GiacomoSorbi. Before doing this one it is advisable to complete t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Alex is transitioning from website design to coding and wants to sharpen his skills with CodeWars. He can do ten kata in an hour, but when he makes a mistake, he must do pus...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.One of the first chain emails I ever received was about a supposed Cambridge University study that suggests your brain can read words no matter what order the letters are in,...
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 find the first element of an array that is not consecutive. By not consecutive we mean not exactly 1 larger than the previous element of the array. E.g. If w...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The number 45 is the first integer in having this interesting property: the sum of the number with its reversed is divisible by the difference between them(absolute Value). ``...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Farmer Bob have a big farm, where he growths chickens, rabbits and cows. It is very difficult to count the number of animals for each type manually, so he diceded to buy a sys...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You're continuing to enjoy your new piano, as described in Piano Kata, Part 1. You're also continuing the exercise where you start on the very first (leftmost, lowest in pitch...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In an infinite array with two rows, the numbers in the top row are denoted `. . . , A[−2], A[−1], A[0], A[1], A[2], . . .` and the numbers in the bottom row are denoted `. ...
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 integers. Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers. If the input array ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two strings, the first being a random string and the second being the same as the first, but with three added characters somewhere in the string (three same characters),...
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 called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function should return `true` if the string is valid, ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Hi guys, welcome to introduction to DocTesting. The kata is composed of two parts; in part (1) we write three small functions, and in part (2) we write a few doc tests for th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Your Informatics teacher at school likes coming up with new ways to help you understand the material. When you started studying numeral systems, he introduced his own ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your work is to write a method that takes a value and an index, and returns the value with the bit at given index flipped. The bits are numbered from the least significant bi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Reverse every other word in a given string, then return the string. Throw away any leading or trailing whitespace, while ensuring there is exactly one space between each word....
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 solves an algebraic expression given as a string. * The expression can include only sums and products. * The numbers in the expression are in standar...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For "x", determine how many positive integers less than or equal to "x" are odd but not prime. Assume "x" is an integer between 1 and 10000. Example: 5 has three odd numbers ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Santa is coming to town and he needs your help finding out who's been naughty or nice. You will be given an entire year of JSON data following this format: Your function shou...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We have the first value of a certain sequence, we will name it ```initVal```. We define pattern list, ```patternL```, an array that has the differences between contiguous ter...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Given the birthdates of two people, find the date when the younger one is exactly half the age of the other. # Notes * The dates are given in the format YYYY-MM-DD a...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Write a function named `sumEvenNumbers`, taking a sequence of numbers as single parameter. Your function must return the sum of **the even values** of this sequence. ...
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 a list of non-negative integers and strings and returns a new list with the strings filtered out. ### Example ```python fi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a name, turn that name into a perfect square matrix (nested array with the amount of arrays equivalent to the length of each array). You will need to add periods (`.`)...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Learning to code around your full time job is taking over your life. You realise that in order to make significant steps quickly, it would help to go to a coding bootcamp in 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 takes an integer and returns an array `[A, B, C]`, where `A` is the number of multiples of 3 (but not 5) below the given integer, `B` is the number of mu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A category page displays a set number of products per page, with pagination at the bottom allowing the user to move from page to page. Given that you know the page you are on...
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 an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirel...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*Are you a file extension master? Let's find out by checking if Bill's files are images or audio files. Please use regex if available natively for your language.* You will cr...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a random string consisting of numbers, letters, symbols, you need to sum up the numbers in the string. Note: - Consecutive integers should be treated as a single numb...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The characters of Chima need your help. Their weapons got mixed up! They need you to write a program that accepts the name of a character in Chima then tells which weapon he/s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Emotional Sort ( ︶︿︶) You'll have a function called "**sortEmotions**" that will return an array of **emotions** sorted. It has two parameters, the first parameter called ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Python dictionaries are inherently unsorted. So what do you do if you need to sort the contents of a dictionary? Create a function that returns a sorted list of `(key, value)...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are making your very own boardgame. The game is played by two opposing players, featuring a 6 x 6 tile system, with the players taking turns to move their pieces (similar ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A pair of numbers has a unique LCM but a single number can be the LCM of more than one possible pairs. For example `12` is the LCM of `(1, 12), (2, 12), (3,4)` etc. For a give...
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 to determine if a string contains only unique characters. Return true if it does and false otherwise. The string may contain any of the 128 ASCII characters. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You would like to get the 'weight' of a name by getting the sum of the ascii values. However you believe that capital letters should be worth more than mere lowercase letters....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Story Due to lack of maintenance the minute-hand has fallen off Town Hall clock face. And because the local council has lost most of our tax money to a Nigerian email scam...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The integers 14 and 15, are contiguous (1 the difference between them, obvious) and have the same number of divisors. ```python 14 ----> 1, 2, 7, 14 (4 divisors) 15 ----> 1, 3...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In order to prove it's success and gain funding, the wilderness zoo needs to prove to environmentalists that it has x number of mating pairs of bears. You must check within ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You managed to send your friend to queue for tickets in your stead, but there is a catch: he will get there only if you tell him how much that is going to take. And everybody ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Valid HK Phone Number ## Overview In Hong Kong, a valid phone number has the format ```xxxx xxxx``` where ```x``` is a decimal digit (0-9). For example: ## Task Define ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Some new animals have arrived at the zoo. The zoo keeper is concerned that perhaps the animals do not have the right tails. To help her, you must correct the broken function t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task John is a programmer. He treasures his time very much. He lives on the `n` floor of a building. Every morning he will go downstairs as quickly as possible to begin his...
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 are going to determine if the count of each of the characters in a string can be equal if we remove a single character from that string. For example: ``` sol...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task A cake is sliced with `n` straight lines. Your task is to calculate the maximum number of pieces the cake can have. # Example For `n = 0`, the output should be `1`. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## A square of squares You like building blocks. You especially like building blocks that are squares. And what you even like more, is to arrange them into a square of square ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider a game, wherein the player has to guess a target word. All the player knows is the length of the target word. To help them in their goal, the game will accept guesse...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Bubblesort Algorithm ## Overview The Bubblesort Algorithm is one of many algorithms used to sort a list of similar items (e.g. all numbers or all letters) into either asce...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A special type of prime is generated by the formula `p = 2^m * 3^n + 1` where `m` and `n` can be any non-negative integer. The first `5` of these primes are `2, 3, 5, 7, 13`,...
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 list of strings and your task will be to find the strings that have the same characters and return the sum of their positions as follows: `...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.[Generala](https://en.wikipedia.org/wiki/Generala) is a dice game popular in South America. It's very similar to [Yahtzee](https://en.wikipedia.org/wiki/Yahtzee) but with a di...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the method which accepts an array of integers, and returns one of the following: * `"yes, ascending"` - if the numbers in the array are sorted in an ascending order ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Everyone knows passphrases. One can choose passphrases from poems, songs, movies names and so on but frequently they can be guessed due to common cultural references. You can...
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 named sumDigits which takes a number as input and returns the sum of the absolute value of each of the number's decimal digits. For example: ```python sum...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are asked to write a simple cypher that rotates every character (in range [a-zA-Z], special chars will be ignored by the cipher) by 13 chars. As an addition to the origina...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.To celebrate today's launch of my Hero's new book: Alan Partridge: Nomad, We have a new series of kata arranged around the great man himself. Given an array of terms, if any ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Find the greatest common divisor of two positive integers. The integers can be large, so you need to find a clever solution. The inputs `x` and `y` are always greater or equ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task Find the sum of the first `n` elements in the Recamán Sequence. Input range: ```python 1000 tests 0 <= n <= 2,500,000 ``` ___ ## Sequence The sequence is formed ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement a method that accepts 3 integer values a, b, c. The method should return true if a triangle can be built with the sides of given length and false in any other case. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider the numbers `6969` and `9116`. When you rotate them `180 degrees` (upside down), these numbers remain the same. To clarify, if we write them down on a paper and turn ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A rectangle can be split up into a grid of 1x1 squares, the amount of which being equal to the product of the two dimensions of the rectangle. Depending on the size of the rec...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In English and programming, groups can be made using symbols such as `()` and `{}` that change meaning. However, these groups must be closed in the correct order to maintain c...
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 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"] ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every day we can send from the server a certain limit of e-mails. Task: Write a function that will return the integer number of e-mails sent in the percentage of the limit. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Here's a way to construct a list containing every positive rational number: Build a binary tree where each node is a rational and the root is `1/1`, with the following rules ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Andrzej was given a task: There are n jars with pills. In every jar there is a different type of pill and the amount of pills in each jar is infinite. One type of pill makes a...
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 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 gi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You'll be given a string, and have to return the total of all the unicode characters as an int. Should be able to handle any characters sent at it. examples: uniTotal("a") ...
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 well known rules: - A number is divisible by 3 if the sum of its digits is divisible by 3. Let's call '3' a "1-sum" prime - For 37, we take numbers in ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task A range-collapse representation of an array of integers looks like this: `"1,3-6,8"`, where `3-6` denotes the range from `3-6`, i.e. `[3,4,5,6]`. Hence `"1,3-6,8"`...
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 which takes a string, and returns its hash value. Algorithm steps: * `a` := sum of the ascii values of the input characters * `b` := sum of every differ...
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 is to take a pair of parametric equations, passed in as strings, and convert them into a single rectangular equation by eliminating the parameter. Both par...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an D-dimension array, where each axis is of length N, your goal is to find the sum of every index in the array starting from 0. For Example if D=1 and N=10 then the ans...
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 intended as a small challenge for my students** All Star Code Challenge #16 Create a function called noRepeat() that takes a string argument and returns a sin...
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, return the minimal number of parenthesis reversals needed to make balanced parenthesis. For example: ```Javascript solve(")(") = 2 Because we need to reverse...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.[Langton's ant](https://en.wikipedia.org/wiki/Langton%27s_ant) is a two-dimensional Turing machine invented in the late 1980s. The ant starts out on a grid of black and white ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. Task: Write ``` smallest(n) ``` that will find the smallest positive...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.With a friend we used to play the following game on a chessboard (8, rows, 8 columns). On the first row at the *bottom* we put numbers: `1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/...
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 write an update for a lottery machine. Its current version produces a sequence of random letters and integers (passed as a string to the function). Your code m...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Changu and Mangu are great buddies. Once they found an infinite paper which had 1,2,3,4,5,6,7,8,......... till infinity, written on it. Both of them did not like the...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The goal of this Kata is to return the greatest distance of index positions between matching number values in an array or 0 if there are no matching values. Example: In an ...
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 number `n`, return a string representing it as a sum of distinct powers of three, or return `"Impossible"` if that's not possible to achieve. # Input/Output ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Background ---------- In another dimension, there exist two immortal brothers: Solomon and Goromon. As sworn loyal subjects to the time elemental, Chronixus, both Solomon and ...
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 ASCII strings, `a` and `b`. Your task is write a function to determine which one of these strings is "worth" more, and return it. A string's worth is de...
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 `isAlt()` that accepts a string as an argument and validates whether the vowels (a, e, i, o, u) and consonants are in alternate order. ```python is_alt("ama...
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, `persistence`, that takes in a positive parameter `num` and returns its multiplicative persistence, which is the number of times you must multiply the digits...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Given an array `arr` and a number `n`. Call a pair of numbers from the array a `Perfect Pair` if their sum is equal to `n`. Find all of the perfect pairs and return ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The number ```1331``` is the first positive perfect cube, higher than ```1```, having all its digits odd (its cubic root is ```11```). The next one is ```3375```. In the in...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You're fed up about changing the version of your software manually. Instead, you will create a little script that will make it for you. # Exercice Create a function `nextVer...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Remember the game 2048? The main part of this game is merging identical tiles in a row. * Implement a function that models the process of merging all of the tile values in ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Summation Of Primes The sum of the primes below or equal to 10 is **2 + 3 + 5 + 7 = 17**. Find the sum of all the primes **_below or equal to the number passed in_**. From...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You work in the best consumer electronics corporation, and your boss wants to find out which three products generate the most revenue. Given 3 lists of the same length like th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### What is simplifying a square root? If you have a number, like 80, for example, you would start by finding the greatest perfect square divisible by 80. In this case, that'...