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.A faro shuffle of a deck of playing cards is a shuffle in which the deck is split exactly in half and then the cards in the two halves are perfectly interwoven, such that the ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In his publication Liber Abaci Leonardo Bonacci, aka Fibonacci, posed a problem involving a population of idealized rabbits. These rabbits bred at a fixed rate, matured over t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Chingel is practicing for a rowing competition to be held on this saturday. He is trying his best to win this tournament for which he needs to figure out how much time it take...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Grade book Complete the function so that it finds the mean of the three scores passed to it and returns the letter value associated with that grade. Numerical Score | ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Here we have a function that help us spam our hearty laughter. But is not working! I need you to find out why... Expected results: ```python spam(1) ==> "hue" spam(6) ==> ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Let's define a `parameter` of number `n` as the least common multiple (LCM) of the sum of its digits and their product. Calculate the parameter of the given number `n`...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If I give you a date, can you tell me what day that date is? For example, december 8th, 2015 is a tuesday. Your job is to write the function ```day(d)``` which takes a string...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You're familiar with [list slicing](https://docs.python.org/3/library/functions.html#slice) in Python and know, for example, that: ```python >>> ages = [12, 14, 63, 72, 55, 2...
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 returns a sequence (index begins with 1) of all the even characters from a string. If the string is smaller than two characters or longer than 100 charac...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write function bmi that calculates body mass index (bmi = weight / height ^ 2). if bmi <= 18.5 return "Underweight" if bmi <= 25.0 return "Normal" if bmi <= 30.0 return "O...
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 strings and your task is to remove all consecutive duplicate letters from each string in the array. For example: * `dup(["abra...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Trigrams are a special case of the n-gram, where n is 3. One trigram is a continious sequence of 3 chars in phrase. [Wikipedia](https://en.wikipedia.org/wiki/Trigram) - retu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The citizens of Codeland read each word from right to left, meaning that lexicographical comparison works differently in their language. Namely, string ```a``` is lexicographi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Your Task The city of Darkishland has a strange hotel with infinite rooms. The groups that come to this hotel follow the following rules: * At the same time only members of...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Philip's just turned four and he wants to know how old he will be in various years in the future such as 2090 or 3044. His parents can't keep up calculating this so they've be...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The cockroach is one of the fastest insects. Write a function which takes its speed in km per hour and returns it in cm per second, rounded down to the integer (= floored). F...
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 which answers the question "Are you playing banjo?". If your name starts with the letter "R" or lower case "r", you are playing banjo! The function takes ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Mobile Display Keystrokes Do you remember the old mobile display keyboards? Do you also remember how inconvenient it was to write on it? Well, here you have to calculate how ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# altERnaTIng cAsE <=> ALTerNAtiNG CaSe Define `String.prototype.toAlternatingCase` (or a similar function/method *such as* `to_alternating_case`/`toAlternatingCase`/`ToAlter...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You're in ancient Greece and giving Philoctetes a hand in preparing a training exercise for Hercules! You've filled a pit with two different ferocious mythical creatures for H...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Two fishing vessels are sailing the open ocean, both on a joint ops fishing mission. On a high stakes, high reward expidition - the ships have adopted the strategy of hanging...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*Based on this Numberphile video: https://www.youtube.com/watch?v=Wim9WJeDTHQ* --- Multiply all the digits of a nonnegative integer `n` by each other, repeating with the pro...
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 consisting of `"D", "P" and "C"`. A positive integer N is called DPC of this string if it satisfies the following properties: ``` For each ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Christmas is coming, and your task is to build a custom Christmas tree with the specified characters and the specified height. # Inputs: - `chars`: the specified char...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The Fibonacci numbers are the numbers in the following integer sequence (Fn): >0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ... such as >F(n) = F(n-1) + F(n-2) with F(...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Imagine a standard chess board with only two white and two black knights placed in their standard starting positions: the white knights on b1 and g1; the black knights...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Convert number to reversed array of digits Given a random non-negative number, you have to return the digits of this number within an array in reverse order. ## Example: ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider the word `"abode"`. We can see that the letter `a` is in position `1` and `b` is in position `2`. In the alphabet, `a` and `b` are also in positions `1` and `2`. Noti...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Binary with 0 and 1 is good, but binary with only 0 is even better! Originally, this is a concept designed by Chuck Norris to send so called unary messages. Can you write a p...
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 to write a function **pattern** which creates the following pattern upto n number of rows. * If the Argument is 0 or a Negative Integer then it should retu...
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 numbers (in string format), you must return a string. The numbers correspond to the letters of the alphabet in reverse order: a=26, z=1 etc. You should also ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Triangular number is the amount of points that can fill equilateral triangle. Example: the number 6 is a triangular number because all sides of a triangle has the same amoun...
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 make a program takes in a sentence (without puncuation), adds all words to a list and returns the sentence as a string which is the positions of the word in 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 will do addition and subtraction on a given string. The return value must be also a string. **Note:** the input will not be empty. ## Examples ``` "1plus2...
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 exercise is to convert a string to a new string where each character in the new string is `"("` if that character appears only once in the original string, or...
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 part of the collection [Mary's Puzzle Books](https://www.codewars.com/collections/marys-puzzle-books). Mary brought home a "spot the differences" book. The book ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Today was a sad day. Having bought a new beard trimmer, I set it to the max setting and shaved away at my joyous beard. Stupidly, I hadnt checked just how long the max setting...
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'll be given an integer of range `0 <= x <= 99` and have to return that number spelt out in English. A few examples: ```python name_that_number(4) # return...
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, find the duplicates in that array, and return a new array of those duplicates. The elements of the returned array should appear in the order when they first ap...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*This is the second Kata in the Ciphers series. This series is meant to test our coding knowledge.* ## Ciphers #2 - The reversed Cipher This is a lame method I use to write t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A Magic Square contains the integers 1 to n^(2), arranged in an n by n array such that the columns, rows and both main diagonals add up to the same number.For doubly even posi...
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 when given a number >= 0, returns an Array of ascending length subarrays. ``` pyramid(0) => [ ] pyramid(1) => [ [1] ] pyramid(2) => [ [1], [1, 1] ] pyra...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A [Power Law](https://en.wikipedia.org/wiki/Power_law) distribution occurs whenever "a relative change in one quantity results in a proportional relative change in the other q...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# SpeedCode #2 - Array Madness ## Objective Given two **integer arrays** ```a, b```, both of ```length >= 1```, create a program that returns ```true``` if the **sum of the ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Simple enough this one - you will be given an array. The values in the array will either be numbers or strings, or a mix of both. You will not get an empty array, nor a sparse...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a sequence of numbers, find the largest pair sum in the sequence. For example ``` [10, 14, 2, 23, 19] --> 42 (= 23 + 19) [99, 2, 2, 23, 19] --> 122 (= 99 + 23) ``` I...
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 `a` of positive integers a. You may choose some integer `X` and update `a` several times, where to update means to perform the following operati...
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 are given an array to sort but you're expected to start sorting from a specific position of the array (in ascending order) and optionally you're given the num...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution."Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a mid-point, Q has a corresponding point, P1, whi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider a sequence made up of the consecutive prime numbers. This infinite sequence would start with: ```python "2357111317192329313741434753596167717379..." ``` You will b...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Cheesy Cheeseman just got a new monitor! He is happy with it, but he just discovered that his old desktop wallpaper no longer fits. He wants to find a new wallpaper, but does ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Peter can see a clock in the mirror from the place he sits in the office. When he saw the clock shows 12:22 1 2 3 4 5 6 7 8 9 10 11 12 He knows that the time is 11:38 ...
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, you progressively need to concatenate the first letter from the left and the first letter to the right and "1", then the second letter from the left and the se...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You know how sometimes you write the the same word twice in a sentence, but then don't notice that it happened? For example, you've been distracted for a second. Did you notic...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task An `ATM` ran out of 10 dollar bills and only has `100, 50 and 20` dollar bills. Given an amount between `40 and 10000 dollars (inclusive)` and assuming that the AT...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Construct a function 'coordinates', that will return the distance between two points on a cartesian plane, given the x and y coordinates of each point. There are two paramete...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You're about to go on a trip around the world! On this trip you're bringing your trusted backpack, that anything fits into. The bad news is that the airline has informed you, ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are provided with array of positive non-zero ints and int n representing n-th power (n >= 2). For the given array, calculate the sum of each value to the n-th power. Then...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You just took a contract with the Jedi council. They need you to write a function, `greet_jedi()`, which takes two arguments (a first name and a last name), works out the corr...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider the array `[3,6,9,12]`. If we generate all the combinations with repetition that sum to `12`, we get `5` combinations: `[12], [6,6], [3,9], [3,3,6], [3,3,3,3]`. The l...
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 ints, return the index such that the sum of the elements to the right of that index equals the sum of the elements to the left of that index. If there is no ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Gordon Ramsay shouts. He shouts and swears. There may be something wrong with him. Anyway, you will be given a string of four words. Your job is to turn them in to Gordon lan...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Oh no! Ghosts have reportedly swarmed the city. It's your job to get rid of them and save the day! In this kata, strings represent buildings while whitespaces within those st...
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: Given a st...
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 remove the left-most duplicates from a list of integers and return the result. ```python # Remove the 3's at indices 0 and 3 # followed by removing a 4...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### Happy Holidays fellow Code Warriors! Now, Dasher! Now, Dancer! Now, Prancer, and Vixen! On, Comet! On, Cupid! On, Donder and Blitzen! That's the order Santa wanted his re...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The number 81 has a special property, a certain power of the sum of its digits is equal to 81 (nine squared). Eighty one (81), is the first number in having this property (not...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A binary gap within a positive number ```num``` is any sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of ```num```. F...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Miss X has only two combs in her possession, both of which are old and miss a tooth or two. She also has many purses of different length, in which she carries the comb...
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 numbers, calculate the largest sum of all possible blocks of consecutive elements within the array. The numbers will be a mix of positive and negative values...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Two strings ```a``` and b are called isomorphic if there is a one to one mapping possible for every character of ```a``` to every character of ```b```. And all occurrences of ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For a given 2D vector described by cartesian coordinates of its initial point and terminal point in the following format: ```python [[x1, y1], [x2, y2]] ``` Your function mu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.```if:python Note: Python may currently have some performance issues. If you find them, please let me know and provide suggestions to improve the Python version! It's my weak...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Alan's child can be annoying at times. When Alan comes home and tells his kid what he has accomplished today, his kid never believes him. Be that kid. Your function 'AlanA...
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 two sorted arrays `a` and `b`, merge them to form new array of unique items. If an item is present in both arrays, it should be part of the resulting array ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Mobius function - an important function in number theory. For each given n, it only has 3 values: ``` 0 -- if n divisible by square of a prime. Such as: 4, 8, 9 1 --...
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. Your task is to determine the minimum number of its elements that need to be changed so that elements of the array will form an ari...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A `Nice array` is defined to be an array where for every value `n` in the array, there is also an element `n-1` or `n+1` in the array. example: ``` [2,10,9,3] is Nice 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 arrays, the purpose of this Kata is to check if these two arrays are the same. "The same" in this Kata means the two arrays contains arrays of 2 numbers which are sa...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Challenge: Given two null-terminated strings in the arguments "string" and "prefix", determine if "string" starts with the "prefix" string. Return 1 (or any other "truthy" val...
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 **integer n**, which is the number of times that is thown a coin. You will have to return an array of string for all the possibilities (heads...
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 have to correctly return who is the "survivor", ie: the last element of a Josephus permutation. Basically you have to assume that n people are put into a cir...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.JavaScript provides a built-in parseInt method. It can be used like this: - `parseInt("10")` returns `10` - `parseInt("10 apples")` also returns `10` We would like it to re...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are standing on top of an amazing Himalayan mountain. The view is absolutely breathtaking! you want to take a picture on your phone, but... your memory is full again! ok, ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*** No Loops Allowed *** You will be given an array (a) and a value (x). All you need to do is check whether the provided array contains the value, without using a loop. Arr...
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 `a` and integers `t` and `x`, count how many elements in the array you can make equal to `t` by **increasing** / **decreasing** it by `x` (or doing ...
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 `S` and a character `C`, return an array of integers representing the shortest distance from the current character in `S` to `C`. ### Notes * All letters will...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A number m of the form 10x + y is divisible by 7 if and only if x − 2y is divisible by 7. In other words, subtract twice the last digit from the number formed by the remainin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Imagine a triangle of numbers which follows this pattern: * Starting with the number "1", "1" is positioned at the top of the triangle. As this is the 1st row, it can only s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.##Overview Write a helper function that takes in a Time object and converts it to a more human-readable format. You need only go up to '_ weeks ago'. ```python to_pretty(0) =...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Convert a linked list to a string ## Related Kata Although this Kata is not part of an official Series, you may also want to try out [Parse a linked list from a string](ht...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Ho ho! So you think you know integers, do you? Well then, young wizard, tell us what the Nth digit of the [Champernowne constant](https://en.wikipedia.org/wiki/Champernowne_co...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Description: Find the longest successive exclamation marks and question marks combination in the string. A successive exclamation marks and question marks combination must...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Description: Remove all exclamation marks from the end of words. Words are separated by spaces in the sentence. ### Examples ``` remove("Hi!") === "Hi" remove("Hi!!!") ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Bob has ladder. He wants to climb this ladder, but being a precocious child, he wonders about exactly how many ways he could to climb this `n` size ladder using jumps of up to...
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, `multiples(m, n)`, which returns an array of the first `m` multiples of the real number `n`. Assume that `m` is a positive integer. Ex. ``` multiples(3,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Introduction Digital Cypher assigns a unique number to each letter of the alphabet: ``` a b c d e f g h i j k l m n o p q r s t u v w x y z 1 ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We’ve all seen katas that ask for conversion from snake-case to camel-case, from camel-case to snake-case, or from camel-case to kebab-case — the possibilities are endless. B...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Lonerz got some crazy growing plants and he wants to grow them nice and well. Initially, the garden is completely barren. Each morning, Lonerz can put any numbe...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Triple Trouble Create a function that will return a string that combines all of the letters of the three inputed strings in groups. Taking the first letter of all of the i...