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.It's Friday night, and Chuck is bored. He's already run 1,000 miles, stopping only to eat a family sized bag of Heatwave Doritos and a large fistful of M&Ms. He just can't sto...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We have a set of consecutive numbers from ```1``` to ```n```. We want to count all the subsets that do not contain consecutive numbers. E.g. If our set ```S1``` is equal to `...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Reducing Problems - Bug Fixing #8 Oh no! Timmy's reduce is causing problems, Timmy's goal is to calculate the two teams scores and return the winner but timmy has gotten conf...
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 we have a number, `num`. Find the number of values of `n` such that: there exists `n` consecutive **positive** values that sum up to `num`. A positive number is `> 0...
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 your task will be to return the count of pairs that have consecutive numbers as follows: ```Haskell pairs([1,2,5,8,-4,-3,7,6,5]) = 3 The pairs are selected as fol...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the solution so that it takes the object (JavaScript/CoffeeScript) or hash (ruby) passed in and generates a human readable string from its key/value pairs. The form...
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 some people who are betting money, and they all start with the same amount of money (this number>0). Find out if the given end-state of amounts is possible...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this Kata you need to write the method SharedBits that returns true if 2 integers share at least two '1' bits. For simplicity assume that all numbers are positive For exam...
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 integer `n`, find the maximal number you can obtain by deleting exactly one digit of the given number. # Example For `n = 152`, the output should be `52`; ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Simple transposition is a basic and simple cryptography technique. We make 2 rows and put first a letter in the Row 1, the second in the Row 2, third in Row 1 and so on until ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a credit card number we can determine who the issuer/vendor is with a few basic knowns. ```if:python Complete the function `get_issuer()` that will use the values shown...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Check if given chord is minor or major. _____________________________________________________________ Rules: 1. Basic minor/major chord have three elements. 2. Chord is min...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Vanya gets bored one day and decides to enumerate a large pile of rocks. He first counts the rocks and finds out that he has `n` rocks in the pile, then he goes to the...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Kate likes to count words in text blocks. By words she means continuous sequences of English alphabetic characters (from a to z ). Here are examples: `Hello there, little use...
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 #18 Create a function called that accepts 2 string arguments and returns an integer of...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Kontti language is a finnish word play game. You add `-kontti` to the end of each word and then swap their characters until and including the first vowel ("aeiouy"); For ex...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The queen can be moved any number of unoccupied squares in a straight line vertically, horizontally, or diagonally, thus combining the moves of the rook and bishop. The queen ...
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, your job is to return the two distinct highest values in a list. If there're less than 2 unique values, return as many of them, as possible. The result should a...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task "AL-AHLY" and "Zamalek" are the best teams in Egypt, but "AL-AHLY" always wins the matches between them. "Zamalek" managers want to know what is the best match they've...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Make a program that filters a list of strings and returns a list with only your friends name in it. If a name has exactly 4 letters in it, you can be sure that it has to be 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 that gets a sequence and value and returns `true/false` depending on whether the variable exists in a multidimentional sequence. Example: ``` locate(['a','b'...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a board of `NxN`, distributed with tiles labeled `0` to `N² - 1`(inclusive): A solved grid will have the tiles in order of label, left to right, top to bottom. Return ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Take an integer `n (n >= 0)` and a digit `d (0 <= d <= 9)` as an integer. Square all numbers `k (0 <= k <= n)` between 0 and n. Count the numbers of digits `d` used in the wr...
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 very simple. Just write a function `isAlphabetic(s)`, which takes an input string `s` in lowercase and returns `true`/`false` depending on whether the string is i...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The objective of this Kata is to write a function that creates a dictionary of factors for a range of numbers. The key for each list in the dictionary should be the number. T...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Task ======= Make a custom esolang interpreter for the language Tick. Tick is a descendant of [Ticker](https://www.codewars.com/kata/esolang-ticker) but also very different d...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In mathematics, a matrix (plural matrices) is a rectangular array of numbers. Matrices have many applications in programming, from performing transformations in 2D space to ma...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Consider the following algorithm for constructing 26 strings S(1) .. S(26): ``` S(1) = "a"; For i in [2, 3, ..., 26]: S(i) = S(i - 1) + character(i) + S(i - 1).``` F...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task CodeBots decided to make a gift for CodeMaster's birthday. They got a pack of candies of various sizes from the store, but instead of giving the whole pack they are tr...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this Kata, you will be given a string and your task is to return the most valuable character. The value of a character is the difference between the index of its last occur...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*This kata is inspired by [Project Euler Problem #387](https://projecteuler.net/problem=387)* --- A [Harshad number](https://en.wikipedia.org/wiki/Harshad_number) (or Niven ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Description "It's the end of trick-or-treating and we have a list/array representing how much candy each child in our group has made out with. We don't want the kids to star...
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 any sentence and redistributes the spaces (and adds additional spaces if needed) so that each word starts with a vowel. The letters should all be ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given some positive integers, I wish to print the integers such that all take up the same width by adding a minimum number of leading zeroes. No leading zeroes shall be added ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this Kata, you will be given a string and your task is to determine if that string can be a palindrome if we rotate one or more characters to the left. ```Haskell solve("4...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given 2 elevators (named "left" and "right") in a building with 3 floors (numbered `0` to `2`), write a function `elevator` accepting 3 arguments (in order): - `left` - The c...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a positive integer `n`, return first n dgits of Thue-Morse sequence, as a string (see examples). Thue-Morse sequence is a binary sequence with 0 as the first element. T...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a function that replaces 'two', 'too' and 'to' with the number '2'. Even if the sound is found mid word (like in octopus) or not in lowercase grandma still thinks that s...
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 `close_compare` that accepts 3 parameters: `a`, `b`, and an optional `margin`. The function should return whether `a` is lower than, close to, or higher than...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: 2332 110011 5432234...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A **bouncy number** is a positive integer whose digits neither increase nor decrease. For example, `1235` is an increasing number, `5321` is a decreasing number, and `2351` is...
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 magic square is an arrangement of distinct numbers (i.e., each number is used once), usually integers, in a square grid, where the numbers in ea...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have an award-winning garden and everyday the plants need exactly 40mm of water. You created a great piece of JavaScript to calculate the amount of water your plants will ...
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 to find the count of the most frequent item of an array. You can assume that input is an array of integers. For an empty array return `0` ## Example ```...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: 2332 110011 54322...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Story Jumbo Juice makes a fresh juice out of fruits of your choice.Jumbo Juice charges $5 for regular fruits and $7 for special ones. Regular fruits are Banana, Orange, Apple,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We like parsed SQL or PL/SQL blocks... You need to write function that return list of literals indices from source block, excluding "in" comments, OR return empty list if no ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Bob needs a fast way to calculate the volume of a cuboid with three values: `length`, `width` and the `height` of the cuboid. Write a function to help Bob with this calculatio...
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 play around with the provided string (s). Move consonants forward 9 places through the alphabet. If they pass 'z', start again at 'a'. Move vowels back 5 places ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your start-up's BA has told marketing that your website has a large audience in Scandinavia and surrounding countries. Marketing thinks it would be great to welcome visitors t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a list of integers values, your job is to return the sum of the values; however, if the same integer value appears multiple times in the list, you can only count it once...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Define a function that takes in two non-negative integers `$a$` and `$b$` and returns the last decimal digit of `$a^b$`. Note that `$a$` and `$b$` may be very large! For exam...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Well, those numbers were right and we're going to feed their ego. Write a function, isNarcissistic, that takes in any amount of numbers and returns true if all the numbers ar...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An `non decreasing` number is one containing no two consecutive digits (left to right), whose the first is higer than the second. For example, 1235 is an non decreasing number...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### Task Each day a plant is growing by `upSpeed` meters. Each night that plant's height decreases by `downSpeed` meters due to the lack of sun heat. Initially, plant is 0 me...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Array inversion indicates how far the array is from being sorted. Inversions are pairs of elements in array that are out of order. ## Examples ``` [1, 2, 3, 4] => 0 inver...
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 directions and your task will be to find your way back. ```Perl solve(["Begin on Road A","Right on Road B","Right on Road C","Left on Road D"]...
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 return ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Consider an array of integers `a`. Let `min(a)` be its minimal element, and let `avg(a)` be its mean. Define the center of the array `a` as array `b` such that: ``` -...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a certain integer ```n```, we need a function ```big_primefac_div()```, that give an array with the highest prime factor and the highest divisor (not equal to n). Let's...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Don Drumphet lives in a nice neighborhood, but one of his neighbors has started to let his house go. Don Drumphet wants to build a wall between his house and his neighbor’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 create a function to check a non-negative input to see if it is a prime number. The function will take in a number and will return True if it is a prime...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Most of this problem is by the original author of [the harder kata](https://www.codewars.com/kata/556206664efbe6376700005c), I just made it simpler. I read a book recently, t...
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 takes two or more objects and returns a new object which combines all the input objects. All input object properties will have only num...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.#Unflatten a list (Easy) There are several katas like "Flatten a list". These katas are done by so many warriors, that the count of available list to flattin goes down! So y...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You will be given a string and you task is to check if it is possible to convert that string into a palindrome by removing a single character. If the string is already a palin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An NBA game runs 48 minutes (Four 12 minute quarters). Players do not typically play the full game, subbing in and out as necessary. Your job is to extrapolate a player's poin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Find the 2nd largest integer in array If the array has no 2nd largest integer then return nil. Reject all non integers elements and then find the 2nd largest integer in array ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The local transport authority is organizing an online picture contest. Participants must take pictures of transport means in an original way, and then post the picture on Inst...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have to rebuild a string from an enumerated list. For this task, you have to check if input is correct beforehand. * Input must be a list of tuples * Each tuple has two e...
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 `insertDash(num)`/`InsertDash(int num)` that will insert dashes ('-') between each two odd numbers in num. For example: if num is 454793 the output should be ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Sum all the numbers of the array (in F# and Haskell you get a list) except the highest and the lowest element (the value, not the index!). (The highest/lowest element is respe...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You like the way the Python `+` operator easily handles adding different numeric types, but you need a tool to do that kind of addition without killing your program with a `Ty...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This problem takes its name by arguably the most important event in the life of the ancient historian Josephus: according to his tale, he and his 40 soldiers were trapped in a...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Comprised of a team of five incredibly brilliant women, "The ladies of ENIAC" were the first “computors” working at the University of Pennsylvania’s Moore School of Engineerin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The `depth` of an integer `n` is defined to be how many multiples of `n` it is necessary to compute before all `10` digits have appeared at least once in some multiple. exam...
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 kata, Connect Four.](https://www.codewars.com/kata/connect-four-1) In this kata we play a modified game of connect four. It's connect X, and there can be multi...
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 two ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Remove Duplicates You are to write a function called `unique` that takes an array of integers and returns the array with duplicates removed. It must return the values in th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Santa puts all the presents into the huge sack. In order to let his reindeers rest a bit, he only takes as many reindeers with him as he is required to do. The others may take...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If you can't sleep, just count sheep!! ## Task: Given a non-negative integer, `3` for example, return a string with a murmur: `"1 sheep...2 sheep...3 sheep..."`. Input will ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have a set of four (4) balls labeled with different numbers: ball_1 (1), ball_2 (2), ball_3 (3) and ball(4) and we have 3 equal boxes for distribute them. The possible com...
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 return multiplication table for ```number``` that is always an integer from 1 to 10. For example, a multiplication table (string) for ```number == 5``` looks ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Each number should be formatted that it is rounded to two decimal places. You don't need to check whether the input is a valid number because only valid numbers are used in th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Format any integer provided into a string with "," (commas) in the correct places. **Example:** ``` csharp Kata.NumberFormat(100000); // return "100,000" Kata.NumberFormat(56...
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 `arr` that representing coordinates of obstacles situated on a straight line. Assume that you are jumping from the point with coor...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There are some candies that need to be distributed to some children as fairly as possible (i.e. the variance of result needs to be as small as possible), but I don't know how ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A variation of determining leap years, assuming only integers are used and years can be negative and positive. Write a function which will return the days in the year and the...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a square matrix (i.e. an array of subarrays), find the sum of values from the first value of the first array, the second value of the second array, the third value of th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There are several (or no) spiders, butterflies, and dragonflies. In this kata, a spider has eight legs. A dragonfly or a butterfly has six legs. A __dragonfly__ has __two__ ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The vowel substrings in the word `codewarriors` are `o,e,a,io`. The longest of these has a length of 2. Given a lowercase string that has alphabetic characters only (both vowe...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.###Lucky number Write a function to find if a number is lucky or not. If the sum of all digits is 0 or multiple of 9 then the number is lucky. `1892376 => 1+8+9+2+3+7+6 = 36...
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 desired number of rows. * Note:`Returnin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.So you've found a meeting room - phew! You arrive there ready to present, and find that someone has taken one or more of the chairs!! You need to find some quick.... check all...
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 integers whose elements have both a negative and a positive value, except for one integer that is either only negative or only posi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Consider a `bishop`, a `knight` and a `rook` on an `n × m` chessboard. They are said to form a `triangle` if each piece attacks exactly one other piece and is attacked...
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 the count of characters that have to be removed in order to get a string with no consecutive repeats. *Note:* This includes any 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 method named `getExponent(n,p)` that returns the largest integer exponent `x` such that p^(x) evenly divides `n`. if `p<=1` the method should return `null`/`None` (thr...
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 `n` (`n > 0`) and your task will be to return the smallest square number `N` (`N > 0`) such that `n + N` is also a perfect square. If ...