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.```if-not:sql Implement a function that receives two IPv4 addresses, and returns the number of addresses between them (including the first one, excluding the last one). ``` `...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your goal is to create a function to format a number given a template; if the number is not present, use the digits `1234567890` to fill in the spaces. A few rules: * the te...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Story Your company migrated the last 20 years of it's *very important data* to a new platform, in multiple phases. However, something went wrong: some of the essential tim...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You're on your way to the market when you hear beautiful music coming from a nearby street performer. The notes come together like you wouln't believe as the musician puts tog...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The prime number sequence starts with: `2,3,5,7,11,13,17,19...`. Notice that `2` is in position `one`. `3` occupies position `two`, which is a prime-numbered position. Simil...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.###BACKGROUND: Jacob recently decided to get healthy and lose some weight. He did a lot of reading and research and after focusing on steady exercise and a healthy diet for se...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Unscramble the eggs. The string given to your function has had an "egg" inserted directly after each consonant. You need to return the string before it became eggcoded. ## ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.```if-not:swift Create a method that takes an array/list as an input, and outputs the index at which the sole odd number is located. This method should work with arrays with ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# The President's phone is broken He is not very happy. The only letters still working are uppercase ```E```, ```F```, ```I```, ```R```, ```U```, ```Y```. An angry tweet is...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your back at your newly acquired decrypting job for the secret organization when a new assignment comes in. Apparently the enemy has been communicating using a device they c...
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 playing a RPG game. The initial attack value of the player is `x`. The player will face a crowd of monsters. Each monster has different defense value. If the ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Take the following IPv4 address: `128.32.10.1` This address has 4 octets where each octet is a single byte (or 8 bits). * 1st octet `128` has the binary representation: `100...
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 focusing on the Numpy python package. You must write a function called `looper` which takes three integers `start, stop and number` as input and returns a ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Three candidates take part in a TV show. In order to decide who will take part in the final game and probably become rich, they have to roll the Wheel of Fortune! The Wheel ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Our fruit guy has a bag of fruit (represented as an array of strings) where some fruits are rotten. He wants to replace all the rotten pieces of fruit with fresh ones. For exa...
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 (ints) of n integers, find three integers in arr such that the sum is closest to a given number (num), target. Return the sum of the three integers. You may a...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Below we will define what and n-interesting polygon is and your task is to find its area for a given n. A 1-interesting polygon is just a square with a side of lengt...
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 reverse a string while maintaining the spaces (if any) in their original place. For example: ``` solve("our code") = "edo cruo" -- Normal revers...
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 binary number, we are about to do some operations on the number. Two types of operations can be here: * ['I', i, j] : Which means invert the bit from i to j (...
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 parameters, i) a string (containing a list of words) and ii) an integer (n). The function should alphabetize the list based on the nth lette...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Related to MrZizoScream's Product Array kata. You might want to solve that one first :) ```if:javascript **Note:** Node 10 has now been enabled, and you can now use its BigIn...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.#Sorting on planet Twisted-3-7 There is a planet... in a galaxy far far away. It is exactly like our planet, but it has one difference: #The values of the digits 3 and 7 are ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# # Task: * #### Complete the pattern, using the special character ```■ □``` * #### In this kata, we draw some histogram of the sound performance of ups and downs. # # ...
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 function ```findSum```. Upto and including ```n```, this function will return the sum of all multiples of 3 and 5. For example: ```findSum(5)``` shoul...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The T9 typing predictor helps with suggestions for possible word combinations on an old-style numeric keypad phone. Each digit in the keypad (2-9) represents a group of 3-4 le...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Adapted from here, with less terrible instructions and a couple tweaks. Two kangaroos are jumping on a line. They start out at different points on the line, and jump in the s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You love coffee and want to know what beans you can afford to buy it. The first argument to your search function will be a number which represents your budget. The second ar...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The concept of "[smooth number](https://en.wikipedia.org/wiki/Smooth_number)" is applied to all those numbers whose prime factors are lesser than or equal to `7`: `60` is a sm...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The central dogma of molecular biology is that DNA is transcribed into RNA, which is then tranlsated into protein. RNA, like DNA, is a long strand of nucleic acids held togeth...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Sort an array by value and index Your task is to sort an array of integer numbers by the product of the value and the index of the positions. For sorting the index starts ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If we alternate the vowels and consonants in the string `"have"`, we get the following list, arranged alphabetically: `['ahev', 'aveh', 'ehav', 'evah', 'vahe', 'veha']`. These...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# RegExp Fun #1 - When I miss few days of gym ## Disclaimer The background story of this Kata is 100% fiction. Any resemblance to real people or real events is **nothing mo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The palindromic number `595` is interesting because it can be written as the sum of consecutive squares: `6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2 = 595`. There are exactly...
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 array and your task is to return the sum of elements occupying prime-numbered indices. ~~~if-not:fortran The first element of the ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.< PREVIOUS KATA NEXT KATA > ###Task: You have to write a function `pattern` which returns the following Pattern(See Examples) upto (3n-2) rows, where n is parameter. * Not...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Note : Issues Fixed with python 2.7.6 , Use any one you like :D , ( Thanks to Time , time , time . Your task is to write a function that will return the degrees on a analog ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You've got a bunch of textual data with embedded phone numbers. Write a function `area_code()` that finds and returns just the area code portion of the phone number. ```python...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Let's say that in a hypothetical platform that resembles Codewars there is a clan with 2 warriors. The 2nd one in ranking (lets call him **D**) wants to at least reach the hon...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The new £5 notes have been recently released in the UK and they've certainly became a sensation! Even those of us who haven't been carrying any cash around for a while, having...
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 takes a number as an argument and returns a grade based on that number. Score | Grade ------------------------------...
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 named `divisors`/`Divisors` that takes an integer `n > 1` and returns an array with all of the integer's divisors(except for 1 and the number itself), from s...
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 that may have mixed uppercase and lowercase letters and your task is to convert that string to either lowercase only or uppercase only...
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 receives two strings and returns n, where n is equal to the number of characters we should shift the first string forward to match the second. For insta...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Finish the solution so that it returns the s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Jack and Jill are playing a game. They have balls numbered from `0` to `n - 1`. Jack looks the other way and asks Jill to reverse the position of the balls, for instance, to c...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your Goal is to create a function that takes two strings, a guess and a phone number. Based on the guess, the function should display a portion of the phone number: gu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A **Seven Segment Display** is an electronic display device, used to display decimal or hexadecimal numerals. It involves seven led segments that are lit in specific combinati...
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 ```number```, two indexes (```index1``` and ```index2```) and a ```digit``` to look for. Your task will be to check if the ```digit``` exists...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The purpose of this kata is to work out just how many bottles of duty free whiskey you would have to buy such that the saving over the normal high street price would effective...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In Russia, there is an army-purposed station named UVB-76 or "Buzzer" (see also https://en.wikipedia.org/wiki/UVB-76). Most of time specific "buzz" noise is being broadcasted,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Same as [the original](https://www.codewars.com/kata/simple-fun-number-258-is-divisible-by-6) (same rules, really, go there for example and I strongly recommend completing it ...
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 of numbers in sequence and your task will be to return the missing number. If there is no number missing or there is an error in the s...
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 array/list of numbers and returns a number such that Explanation total([1,2,3,4,5]) => 48 1+2=3--\ 3+5 => 8 \ 2+3=5--/ \ == 8...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We need you to implement a method of receiving commands over a network, processing the information and responding. Our device will send a single packet to you containing data...
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 sort elements in an array by decreasing frequency of elements. If two elements have the same frequency, sort them by increasing value. More examples ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In recreational mathematics, a [Keith number](https://en.wikipedia.org/wiki/Keith_number) or repfigit number (short for repetitive Fibonacci-like digit) is a number in the fol...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An expression is formed by taking the digits 1 to 9 in numerical order and then inserting into each gap between the numbers either a plus sign or a minus sign or neither. You...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.I always thought that my old friend John was rather richer than he looked, but I never knew exactly how much money he actually had. One day (as I was plying him with questions...
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 integers, add all the elements and return the binary equivalent of that sum. If the array contains any non-integer element (e.g. an object, a f...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given the current exchange rate between the USD and the EUR is 1.1363636 write a function that will accept the Curency type to be returned and a list of the amounts that need ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A zero-indexed array ```arr``` consisting of n integers is given. The dominator of array ```arr``` is the value that occurs in more than half of the elements of ```arr```. For...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In elementary arithmetic a "carry" is a digit that is transferred from one column of digits to another column of more significant digits during a calculation algorithm. This ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your goal is to implement the method **meanVsMedian** which accepts an *odd-length* array of integers and returns one of the following: * 'mean' - in case **mean** value is *...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Back-Story Every day I travel on the freeway. When I am more bored than usual I sometimes like to play the following counting game I made up: * As I join the freeway my c...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task A noob programmer was given two simple tasks: sum and sort the elements of the given array `arr` = [a1, a2, ..., an]. He started with summing and did it easily, bu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task The `hamming distance` between a pair of numbers is the number of binary bits that differ in their binary notation. # Example For `a = 25, b= 87`, the result shou...
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 a lonely frog. You live on an integer array. The meaning of your life is to jump and jump.. Now, here comes your new task. You are given an integer array...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Your Task You have a Petri dish with bacteria, and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any microscope nearby, so you can...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the function that accepts a string parameter, and reverses each word in the string. **All** spaces in the string should be retained. ## Examples ``` "This is an exam...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task John and Alice have an appointment today. In the morning, John starts from (`0,0`) and goes to the place (`a,b`) where he is dating. Unfortunately, John had no sense...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.While surfing in web I found interesting math problem called "Always perfect". That means if you add 1 to the product of four consecutive numbers the answer is ALWAYS a perfec...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Some numbers have funny properties. For example: > 89 --> 8¹ + 9² = 89 * 1 > 695 --> 6² + 9³ + 5⁴= 1390 = 695 * 2 > 46288 --> 4³ + 6⁴+ 2⁵ + 8⁶ + 8⁷ = 2360688 = 46288 * 51 ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You can print your name on a billboard ad. Find out how much it will cost you. Each letter has a default price of £30, but that can be different if you are given 2 parameters ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You need to write a function that reverses the words in a given string. A word can also fit an empty string. If this is not clear enough, here are some examples: As the input...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You start with a value in dollar form, e.g. $5.00. You must convert this value to a string in which the value is said, like '5 dollars' for example. This should account for on...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Letterss of Natac In a game I just made up that doesn’t have anything to do with any other game that you may or may not have played, you collect resources on each turn and t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Story&Task The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all houses in the city were built in one row. L...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Welcome to the Codewars Bar! Codewars Bar recommends you drink 1 glass of water per standard drink so you're not hungover tomorrow morning. Your fellow coders have bought ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.`{a, e, i, o, u, A, E, I, O, U}` Natural Language Understanding is the subdomain of Natural Language Processing where people used to design AI based applications have ability...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# History This kata is a sequel of my [Mixbonacci](https://www.codewars.com/kata/mixbonacci/python) kata. Zozonacci is a special integer sequence named after [**ZozoFouchtra*...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We want to find the numbers higher or equal than 1000 that the sum of every four consecutives digits cannot be higher than a certain given value. If the number is ``` num = d1...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Assume you are creating a webshop and you would like to help the user in the search. You have products with brands, prices and name. You have the history of opened products (t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Christmas is coming, and Santa has a long list to go through, to find who deserves presents for the big day. Go through a list of children, and return a list containing every ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.FizzBuzz is often one of the first programming puzzles people learn. Now undo it with reverse FizzBuzz! Write a function that accepts a string, which will always be a valid s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There is enough money available on ATM in nominal value 10, 20, 50, 100, 200 and 500 dollars. You are given money in nominal value of `n` with `1<=n<=1500`. Try to find mini...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task: Based on the received dimensions, `a` and `b`, of an ellipse, calculare its area and perimeter. ## Example: ```python Input: ellipse(5,2) Output: "Area: 31.4, perim...
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 return the sum of Triangular Numbers up-to-and-including the `nth` Triangular Number. Triangular Number: "any of the series of numbers (1, 3, 6, 10, 15, etc.)...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Student A and student B are giving each other test answers during a test. They don't want to be caught so they are sending each other coded messages. Student A is sending s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your friend Rick is trying to send you a message, but he is concerned that it would get intercepted by his partner. He came up with a solution: 1) Add digits in random places...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Welcome. In this kata, you are asked to square every digit of a number and concatenate them. For example, if we run 9119 through the function, 811181 will come out, because 9...
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, return the reversed version of the array (a different kind of reverse though), you reverse portions of the array, you'll be given a length argument which repre...
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, which calculates how much you need to tip based on the total amount of the bill and the service. You need to consider the following ratings: - Terrib...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We are interested in obtaining two scores from a given integer: **First score**: The sum of all the integers obtained from the power set of the digits of the given integer th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### Count the number of Duplicates Write a function that will return the count of **distinct case-insensitive** alphabetic characters and numeric digits that occur more than ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The [half-life](https://en.wikipedia.org/wiki/Half-life) of a radioactive substance is the time it takes (on average) for one-half of its atoms to undergo radioactive decay. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.#Detail [Countdown](https://en.wikipedia.org/wiki/Countdown_(game_show) is a British game show with number and word puzzles. The letters round consists of the contestant pick...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task A lock has `n` buttons in it, numbered from `1 to n`. To open the lock, you have to press all buttons in some order, i.e. a key to the lock is a permutation of the fir...
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 which outputs the positions of matching bracket pairs. The output should be a dictionary with keys the positions of the open brackets '(' and values the corre...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Your task is to sort the characters in a string according to the following rules: ``` - Rule1: English alphabets are arranged from A to Z, case insensitive. ie. "Typ...
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 behaves like the 'uniq -c' command in UNIX. It takes as input a sequence and returns a sequence in which all duplicate elements following each oth...