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.Leonardo Fibonacci in a rare portrait of his younger days I assume you are all familiar with the famous Fibonacci sequence, having to get each number as the sum of the previo...
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: ```if:java...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your task in this Kata is to emulate text justify right in monospace font. You will be given a single-lined text and the expected justification width. The longest word will ne...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive fac...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Given an array `arr`, find the rank of the element at the ith position. The `rank` of the arr[i] is a value equal to the number of elements `less than or equal to` 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 method that returns true if a given parameter is a power of 4, and false if it's not. If parameter is not an Integer (eg String, Array) method should return false as w...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An eviternity number is a number which: * contains only digits 8, 5 and 3, and * the count of the digit `8` >= count of digit `5` >= count of digit `3`. The first few evite...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You'll be given a list of two strings, and each will contain exactly one colon (`":"`) in the middle (but not at beginning or end). The length of the strings, before and after...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Adding tip to a restaurant bill in a graceful way can be tricky, thats why you need make a function for it. The function will receive the restaurant bill (always a positive n...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a triangle of consecutive odd numbers: ``` 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 ... ``` find the tr...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You might know some pretty large perfect squares. But what about the NEXT one? Complete the `findNextSquare` method that finds the next integral perfect square after the one...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You do...
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 number of '2's in the factorization of a number. For example, ```python two_count(24) ``` should return 3, since the factorization of 24 is...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.#Find the missing letter Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array. You will always ge...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Cluster analysis - Unweighted pair-group average Clustering is a task of grouping a set of objects in such a way that the objects in the same class are similar to each other ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This function should test if the `factor` is a factor of `base`. Return `true` if it is a factor or `false` if it is not. ## About factors Factors are numbers you can multip...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The aim of this Kata is to write a function which will reverse the case of all consecutive duplicate letters in a string. That is, any letters that occur one after the other ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In your class, you have started lessons about "arithmetic progression". Because you are also a programmer, you have decided to write a function. This function, arithmetic_seq...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are the "computer expert" of a local Athletic Association (C.A.A.). Many teams of runners come to compete. Each time you get a string of all race results of every team wh...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If you have completed the Tribonacci sequence kata, you would know by now that mister Fibonacci has at least a bigger brother. If not, give it a quick look to get how things w...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If you like Taco Bell, you will be familiar with their signature doritos locos taco. They're very good. Why can't everything be a taco? We're going to attempt that here, tur...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are going to be given an array of integers. Your job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the in...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We need to write some code to return the original price of a product, the return type must be of type decimal and the number must be rounded to two decimal places. We will be...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). S...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## The galactic games have begun! It's the galactic games! Beings of all worlds come together to compete in several interesting sports, like nroogring, fredling and buzzing (...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This function takes two numbers as parameters, the first number being the coefficient, and the second number being the exponent. Your function should multiply the two numbers...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the method which returns the number which is most frequent in the given input array. If there is a tie for most frequent number, return the largest number among them....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A happy number is a number defined by the following process: starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the pro...
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 difference between the count of even numbers and the count of odd numbers. `0` will be considered an even number. ``` For example: solve([0,1,2,3]...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Everybody knows the classic ["half your age plus seven"](https://en.wikipedia.org/wiki/Age_disparity_in_sexual_relationships#The_.22half-your-age-plus-seven.22_rule) dating ru...
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 `alternate_sq_sum()` (JS: `alternateSqSum` ) that takes an array of integers as input and finds the sum of squares of the elements at even positions (*i.e.,* 2n...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider the string `"1 2 36 4 8"`. Lets take pairs of these numbers, concatenate each pair and determine how many of them of divisible by `k`. ```Pearl If k = 3, we get fo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write the following function: ```python def area_of_polygon_inside_circle(circle_radius, number_of_sides): ``` It should calculate the area of a regular polygon of `numberOf...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your job is to return the volume of a cup when given the diameter of the top, the diameter of the bottom and the height. You know that there is a steady gradient from the top...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This is now a little serie :) Funny Dots You will get two Integer n (width) and m (height) and your task is to draw following pattern. Each line is seperated with '\n'. Bot...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Roma is programmer and he likes memes about IT, Maxim is chemist and he likes memes about chemistry, Danik is designer and he likes memes about design, and Vlad likes al...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Description Write a function that accepts the current position of a knight in a chess board, it returns the possible positions that it will end up after 1 move. The resulte...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Find the first character that repeats in a String and return that character. ```python first_dup('tweet') => 't' first_dup('like') => None ``` *This is not the same as find...
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 reverses the bits in an integer. For example, the number `417` is `110100001` in binary. Reversing the binary is `100001011` which is `267`. You can as...
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 create a function that does four basic mathematical operations. The function should take three arguments - operation(string/char), value1(number), value2(numb...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Given an array `arr`, find the maximal value of `k` such `a[i] mod k` = `a[j] mod k` for all valid values of i and j. If it's impossible to find such number (there's a...
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 containing a list of integers separated by commas, write the function string_to_int_list(s) that takes said string and returns a new list containing all integer...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an integer, take the (mean) average of each pair of consecutive digits. Repeat this process until you have a single integer, then return that integer. e.g. Note: if the...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Given some sticks by an array `V` of positive integers, where V[i] represents the length of the sticks, find the number of ways we can choose three of them to form a tr...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# How many urinals are free? In men's public toilets with urinals, there is this unwritten rule that you leave at least one urinal free between you and the next person peeing....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### Background In classical cryptography, the Hill cipher is a polygraphic substitution cipher based on linear algebra. It was invented by Lester S. Hill in 1929. ### Task ...
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 arbitrary number of strings and interlaces them (combines them by alternating characters from each string). For example `combineStrings('abc', ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Story You and a group of friends are earning some extra money in the school holidays by re-painting the numbers on people's letterboxes for a small fee. Since there are 10...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Mike and Joe are fratboys that love beer and games that involve drinking. They play the following game: Mike chugs one beer, then Joe chugs 2 beers, then Mike chugs 3 beers, t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Make multiple functions that will return the sum, difference, modulus, product, quotient, and the exponent respectively. Please use the following function names: addition =...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You received a whatsup message from an unknown number. Could it be from that girl/boy with a foreign accent you met yesterday evening? Write a simple regex to check if the st...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Elections are in progress! Given an array of numbers representing votes given to each of the candidates, and an integer which is equal to the number of voters who hav...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# A History Lesson Soundex is an interesting phonetic algorithm developed nearly 100 years ago for indexing names as they are pronounced in English. The goal is for homophone...
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 of words, you need to find the highest scoring word. Each letter of a word scores points according to its position in the alphabet: `a = 1, b = 2, c = 3` etc. ...
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 define a function named **func** that will take a list as input. You must try and guess the pattern how we get the output number and return list - *...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### Preface You are currently working together with a local community to build a school teaching children how to code. First plans have been made and the community wants to de...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Build a function `sumNestedNumbers`/`sum_nested_numbers` that finds the sum of all numbers in a series of nested arrays raised to the power of their respective nesting levels....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# A History Lesson The Pony Express was a mail service operating in the US in 1859-60. It reduced the time for messages to travel between the Atlantic and Pacific coasts...
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 returns the number of times the search_text is found within the full_text. ```python search_substr( fullText, searchText, allowOverlap = true...
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 creates a **[radix tree](https://en.wikipedia.org/wiki/Radix_tree)** (a space-optimized trie [prefix tree]) in which each node that is the only ch...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider the number triangle below, in which each number is equal to the number above plus the number to the left. If there is no number above, assume it's a `0`. The triangl...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An AI has infected a text with a character!! This text is now **fully mutated** to this character. If the text or the character are empty, return an empty string. There w...
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 string and returns that string with the first half lowercased and the last half uppercased. eg: foobar == fooBAR If it is an odd number then '...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given 2 strings, your job is to find out if there is a substring that appears in both strings. You will return true if you find a substring that appears in both strings, or fa...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.How many days are we represented in a foreign country? My colleagues make business trips to a foreign country. We must find the number of days our company is represented in a...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.When a warrior wants to talk with another one about peace or war he uses a smartphone. In one distinct country warriors who spent all time in training kata not always have e...
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 position of a knight on the standard chessboard, find the number of different moves the knight can perform. The knight can move to a square that is two squar...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Fourier transformations are hard. Fouriest transformations are harder. This Kata is based on the SMBC Comic on fourier transformations. A fourier transformation on a numbe...
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 takes an array of words. You must concatenate the `n`th letter from each word to construct a new word which should be returned as a string, where `...
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. You have to return another string such that even-indexed and odd-indexed characters of S are grouped and groups are space-separated (see sample below) Note:...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task John won the championship of a TV show. He can get some bonuses. He needs to play a game to determine the amount of his bonus. Here are `n` rows and `m` columns of c...
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 take 2 strings, A and B, and define the similarity of the strings to be the length of the longest prefix common to both strings. For example, the similarity of strin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your team is writing a fancy new text editor and you've been tasked with implementing the line numbering. Write a function which takes a list of strings and returns each line...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Explanation It's your first day in the robot factory and your supervisor thinks that you should start with an easy task. So you are responsible for purchasing raw materials...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.```if-not:rust Your task is to write a function `toLeetSpeak` that converts a regular english sentence to Leetspeak. ``` ```if:rust Your task is to write a function `to_leet_s...
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 function that converts a word to pig latin. The rules of pig latin are: ``` If the word has more than 3 letters: 1. Take the first letter of a word and move it...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You take your son to the forest to see the monkeys. You know that there are a certain number there (n), but your son is too young to just appreciate the full number, he has to...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Laura really hates people using acronyms in her office and wants to force her colleagues to remove all acronyms before emailing her. She wants you to build a system that will ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You wrote all your unit test names in camelCase. But some of your colleagues have troubles reading these long test names. So you make a compromise to switch to underscore sepa...
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 the prime factors of a number as an array. E.g: ```[2,2,2,3,3,5,5,13]``` You need to find the number, n, to which that prime factorization belongs. It will ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.I'm sure you're familiar with factorials – that is, the product of an integer and all the integers below it. For example, `5! = 120`, as `5 * 4 * 3 * 2 * 1 = 120` Your chal...
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 #23 There is a certain multiplayer game where players are assessed at the end of the g...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given that ``` f0 = '0' f1 = '01' f2 = '010' = f1 + f0 f3 = '01001' = f2 + f1 ``` You will be given a number and your task is to return the `nth` fibonacci string. For examp...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Leaderboard climbers In this kata you will be given a leaderboard of unique names for example: ```python ['John', 'Brian', 'Jim', 'Dave', 'Fred'] ``` Then you will be...
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 determines the score of a hand in the card game [Blackjack](https://en.wikipedia.org/wiki/Blackjack) (aka 21). The function receives an array of st...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task `N` candles are placed in a row, some of them are initially lit. For each candle from the 1st to the Nth the following algorithm is applied: if the observed candle is ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider the sequence `a(1) = 7, a(n) = a(n-1) + gcd(n, a(n-1)) for n >= 2`: `7, 8, 9, 10, 15, 18, 19, 20, 21, 22, 33, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 69, 72, 73...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An element in an array is dominant if it is greater than all elements to its right. You will be given an array and your task will be to return a list of all dominant elements....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Mr. E Ven only likes even length words. Please create a translator so that he doesn't have to hear those pesky odd length words. For some reason he also hates punctuation, he ...
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 with two arguments that will return an array of the first (n) multiples of (x). Assume both the given number and the number of times to count will be posit...
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 **pandigital number** is a number that in a given base has among its significant digits each digit used in the base at least once. For example, 1234567890 is...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a function to split a string and convert it into an array of words. For example: ```python "Robin Singh" ==> ["Robin", "Singh"] "I love arrays they are my favorite" ==...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Bob is preparing to pass IQ test. The most frequent task in this test is `to find out which one of the given numbers differs from the others`. Bob observed that one number usu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Mr.Nam has `n` candies, he wants to put one candy in each cell of a table-box. The table-box has `r` rows and `c` columns. Each candy was labeled by its cell number....
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.I love Fibonacci numbers in general, but I must admit I love some more than others. I would like for you to write me a function that when given a number (n) returns the n-t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The magic sum of 3s is calculated on an array by summing up odd numbers which include the digit `3`. Write a function `magic_sum` which accepts an array of integers and return...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.#Permutation position In this kata you will have to permutate through a string of lowercase letters, each permutation will start at ```a``` and you must calculate how many it...
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 rectangular `matrix` and integers `a` and `b`, consider the union of the ath row and the bth (both 0-based) column of the `matrix`. Return sum of all elements ...
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, return the difference between the largest and smallest values. For example: `[23, 3, 19, 21, 16]` should return `20` (i.e., `23 - 3`). `[1, 434,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Error Handling is very important in coding and seems to be overlooked or not implemented properly. #Task Your task is to implement a function which takes a string as input a...