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.Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index `0` will be considered even. For example, `capita...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This is simple version of harder [Square Sums](/kata/square-sums). # Square sums Write function `square_sums_row` (or `squareSumsRow`/`SquareSumsRow` depending on language r...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A Madhav array has the following property: ```a[0] = a[1] + a[2] = a[3] + a[4] + a[5] = a[6] + a[7] + a[8] + a[9] = ...``` Complete the function/method that returns `true` i...
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](https://en.wikipedia.org/wiki/Arithmetic_progression). Since you are also a programmer, you have decided...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You will get an array of numbers. Every preceding number is smaller than the one following it. Some numbers will be missing, for instance: ``` [-3,-2,1,5] //missing numbers...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your task is to make two functions, ```max``` and ```min``` (`maximum` and `minimum` in PHP and Python) that take a(n) array/vector of integers ```list``` as input and outputs...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.**Steps** 1. Square the numbers that are greater than zero. 2. Multiply by 3 every third number. 3. Multiply by -1 every fifth number. 4. Return the sum of the sequence. **Ex...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task In the city, a bus named Fibonacci runs on the road every day. There are `n` stations on the route. The Bus runs from station1 to stationn. At the departure station(...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.###Instructions A time period starting from ```'hh:mm'``` lasting until ```'hh:mm'``` is stored in an array: ``` ['08:14', '11:34'] ``` A set of different time periods is the...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Calculate the number of items in a vector that appear at the same index in each vector, with the same value. ```python vector_affinity([1, 2, 3, 4, 5], [1, 2, 2, 4, 3]) #...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You probably know that the "mode" of a set of data is the data point that appears most frequently. Looking at the characters that make up the string `"sarsaparilla"` we can se...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A grid is a perfect starting point for many games (Chess, battleships, Candy Crush!). Making a digital chessboard I think is an interesting way of visualising how loops can w...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Integral numbers can be even or odd. Even numbers satisfy `n = 2m` ( with `m` also integral ) and we will ( completely arbitrarily ) think of odd numbers as `n = 2m + 1`. N...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Introduction The Condi (Consecutive Digraphs) cipher was introduced by G4EGG (Wilfred Higginson) in 2011. The cipher preserves word divisions, and is simple to describe and...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There were and still are many problem in CW about palindrome numbers and palindrome strings. We suposse that you know which kind of numbers they are. If not, you may search ab...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement `String#ipv4_address?`, which should return true if given object is an IPv4 address - four numbers (0-255) separated by dots. It should only accept addresses in can...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task A common way for prisoners to communicate secret messages with each other is to encrypt them. One such encryption algorithm goes as follows. You take the message and...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Write Number in Expanded Form You will be given a number and you will need to return it as a string in [Expanded Form](https://www.mathplacementreview.com/arithmetic/whole-...
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 Write simple .camelCase method (`camel_case` function in PHP, `CamelCase` in C# or `camelCase` in Java) for strings. All words must have their first letter cap...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task We know that some numbers can be split into two primes. ie. `5 = 2 + 3, 10 = 3 + 7`. But some numbers are not. ie. `17, 27, 35`, etc.. Given a positive integer `n`. D...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Sort the given strings in alphabetical order, case **insensitive**. For example: ``` ["Hello", "there", "I'm", "fine"] --> ["fine", "Hello", "I'm", "there"] ["C", "d", "a", ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.German mathematician Christian Goldbach (1690-1764) [conjectured](https://en.wikipedia.org/wiki/Goldbach%27s_conjecture) that every even number greater than 2 can be represent...
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 an array, with each member of input array rounded to a nearest number, divisible by 5. For example: ``` roundToFive([34.5, 56.2, 11, 13]); `...
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 an array of strings. The words in the array should mesh together where one or more letters at the end of one word will have the same letters (in the same ord...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Scheduling is how the processor decides which jobs (processes) get to use the processor and for how long. This can cause a lot of problems. Like a really long process taking t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Mirko has been moving up in the world of basketball. He started as a mere spectator, but has already reached the coveted position of the national team coach! Mirco i...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### Task: You have to write a function `pattern` which creates the following pattern (See Examples) upto desired number of rows. If the Argument is `0` or a Negative Integer...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers. Your function will accept three ar...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.When multiple master devices are connected to a single bus (https://en.wikipedia.org/wiki/System_bus), there needs to be an arbitration in order to choose which of them can ha...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Algorithmic predicament - Bug Fixing #9 Oh no! Timmy's algorithim has gone wrong! help Timmy fix his algorithim! Task Your task is to fix timmy's algorithim so it returns t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.~~~if-not:java You have to code a function **getAllPrimeFactors** wich take an integer as parameter and return an array containing its prime decomposition by ascending factors...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# RoboScript #2 - Implement the RS1 Specification ## Disclaimer The story presented in this Kata Series is purely fictional; any resemblance to actual programming languages,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Hello! Your are given x and y and 2D array size tuple (width, height) and you have to: Calculate the according index in 1D space (zero-based). Do reverse operation. Implemen...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Congratulations! That Special Someone has given you their phone number. But WAIT, is it a valid number? Your task is to write a function that verifies whether a given strin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Now we will confect a reagent. There are eight materials to choose from, numbered 1,2,..., 8 respectively. We know the rules of confect: ``` material1 and material2 cannot be...
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 one integer argument and returns logical value `true` or `false` depending on if the integer is a prime. Per Wikipedia, a prime number (or a prim...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Determine the total number of digits in the integer (`n>=0`) given as input to the function. For example, 9 is a single digit, 66 has 2 digits and 128685 has 6 digits. Be care...
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 points(array `A`) on the same line, determine the minimum number of line segments with length `L` needed to cover all of the given points. A point is covere...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given an array of integers your solution should find the smallest integer. For example: - Given `[34, 15, 88, 2]` your solution will return `2` - Given `[34, -345, -1, 100]...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Clock shows 'h' hours, 'm' minutes and 's' seconds after midnight. Your task is to make 'Past' function which returns time converted to milliseconds. ## Example: ```python ...
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 and an Example-Array to sort to, write a function that sorts the Array following the Example-Array. Assume Example Array catalogs all elements possibly seen in...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You should have done Product Partitions I to do this second part. If you solved it, you should have notice that we try to obtain the multiplicative partitions with ```n ≤ 100 ...
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 with exactly 5 strings `"a"`, `"b"` or `"c"` (`char`s in Java, `character`s in Fortran), check if the array contains three and two of the same values. ## Examp...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.``` ************************* * Create a frame! * * __ __ * * / \~~~/ \ * * ,----( .. ) * * / \__ __/ * * /| (...
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 a string made up of four parts: a) a four character 'word', made up of the characters derived from the first two and last two numbers in the...
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 returns an array containing the first `l` digits from the `n`th diagonal of [Pascal's triangle](https://en.wikipedia.org/wiki/Pascal's_triangle). `n = ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Do you ever wish you could talk like Siegfried of KAOS ? ## YES, of course you do! https://en.wikipedia.org/wiki/Get_Smart # Task Write the function ```siegfried``` to...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Many people choose to obfuscate their email address when displaying it on the Web. One common way of doing this is by substituting the `@` and `.` characters for their literal...
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 three functions namely - `PNum, GPNum and SPNum` (JS, Coffee), `p_num, g_p_num and s_p_num` (Python and Ruby), `pNum, gpNum and spNum` (Java, C#), `...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You've just recently been hired to calculate scores for a Dart Board game! Scoring specifications: * 0 points - radius above 10 * 5 points - radius between 5 and 10 inclusi...
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 arrays and your task will be to return the number of unique arrays that can be formed by picking exactly one element from each suba...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task You are given a `moment` in time and space. What you must do is break it down into time and space, to determine if that moment is from the past, present or future. `...
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, return the nth smallest integer in the list. **Only distinct elements should be considered** when calculating the answer. `n` will always be positive...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.It started as a discussion with a friend, who didn't fully grasp some way of setting defaults, but I thought the idea was cool enough for a beginner kata: binary `OR` each mat...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution."The Shell Game" involves cups upturned on a playing surface, with a ball placed underneath one of them. The index of the cups are swapped around multiple times. After that t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Pero has been into robotics recently, so he decided to make a robot that checks whether a deck of poker cards is complete. He’s already done a fair share of work - h...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You've came to visit your grandma and she straight away found you a job - her Christmas tree needs decorating! She first shows you a tree with an identified number of branche...
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 new to spreadsheets. He is well aware of rows and columns, but he is not comfortable with spreadsheets numbering system. ``` Spreadsheet Row Column...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If `a = 1, b = 2, c = 3 ... z = 26` Then `l + o + v + e = 54` and `f + r + i + e + n + d + s + h + i + p = 108` So `friendship` is twice stronger than `love` :-) The input...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Alex just got a new hula hoop, he loves it but feels discouraged because his little brother is better than him Write a program where Alex can input (n) how many times the hoo...
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 an array which lists the current inventory of stock in your store and another array which lists the new inventory being delivered to your store today. Your ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task: We define the "self reversed power sequence" as one shown below: Implement a function that takes 2 arguments (`ord max` and `num dig`), and finds the smallest term...
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 an array of non-negative integers and positive integer bin width. Your task is to create the Histogram method that will return histogram data corresponding...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write ```python smaller(arr) ``` that given an array ```arr```, you have to return the amount of numbers that are smaller than ```arr[i]``` to the right. For example: ```pyth...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Remember the movie with David Bowie: 'The Labyrinth'? You can remember your childhood here: https://www.youtube.com/watch?v=2dgmgub8mHw In this scene the girl is faced with ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Cara is applying for several different jobs. The online application forms ask her to respond within a specific character count. Cara needs to check that her answers fit into t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the `greatestProduct` method so that it'll find the greatest product of five consecutive digits in the given string of digits. For example: The input string always ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This kata is part of the collection [Mary's Puzzle Books](https://www.codewars.com/collections/marys-puzzle-books). # Zero Terminated Sum Mary has another puzzle book, and i...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Make your strings more nerdy: Replace all 'a'/'A' with 4, 'e'/'E' with 3 and 'l' with 1 e.g. "Fundamentals" --> "Fund4m3nt41s" ```if:csharp Documentation: Kata.Nerdify Metho...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a time in AM/PM format as a string, convert it to military (24-hour) time as a string. Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Two integers are coprimes if the their only greatest common divisor is 1. ## Task In this kata you'll be given a number ```n >= 2``` and output a list with all positive integ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Most languages have a `split` function that lets you turn a string like `“hello world”` into an array like`[“hello”, “world”]`. But what if we don't want to lose the separator...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Convert Improper Fraction to Mixed Number You will need to convert an [improper fraction](https://www.mathplacementreview.com/arithmetic/fractions.php#improper-fractions) t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Sentence Smash Write a function that takes an array of words and smashes them together into a sentence and returns the sentence. You can ignore any need to sanitize words o...
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 takes one parameter representing the dimensions of a checkered board. The board will always be square, so 5 means you will need a 5x5 board. The dark s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The [Chinese zodiac](https://en.wikipedia.org/wiki/Chinese_zodiac) is a repeating cycle of 12 years, with each year being represented by an animal and its reputed attributes. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For a given array whose element values are randomly picked from single-digit integers `0` to `9`, return an array with the same digit order but all `0`'s paired. Paring two `0...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.```if:javascript `Array.prototype.length` will give you the number of top-level elements in an array. ``` ```if:ruby `Array#length` will give you the number of top-level eleme...
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, n > 0```and a number of partitions, ```k, k > 0```; we want to know the partition which has the maximum or minimum product of its terms. The f...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Let be `n` an integer prime with `10` e.g. `7`. `1/7 = 0.142857 142857 142857 ...`. We see that the decimal part has a cycle: `142857`. The length of this cycle is `6`. In ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Below is a right-angled triangle: ``` |\ | \ | \ | \ o | \ h | \ | θ \ |_______\ a ``` Your challange is to write a function (```missingAn...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task To charge your mobile phone battery, do you know how much time it takes from 0% to 100%? It depends on your cell phone battery capacity and the power of the charger. A...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# The Invitation Most of us played with toy blocks growing up. It was fun and you learned stuff. So what else can you do but rise to the challenge when a 3-year old exclaims,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every natural number, ```n```, may have a prime factorization like: We define the arithmetic derivative of ```n```, ```n'``` the value of the expression: Let's do the ca...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We have an array of unique elements. A special kind of permutation is the one that has all of its elements in a different position than the original. Let's see how many of th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Take 2 strings `s1` and `s2` including only letters from `a`to `z`. Return a new **sorted** string, the longest possible, containing distinct letters, - each taken only once -...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Four-digit palindromes start with `[1001,1111,1221,1331,1441,1551,1551,...]` and the number at position `2` is `1111`. You will be given two numbers `a` and `b`. Your task ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your friend Cody has to sell a lot of jam, so he applied a good 25% discount to all his merchandise. Trouble is that he mixed all the prices (initial and discounted), so now ...
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 and finds the factors of it, listing them in **descending** order in an **array**. If the parameter is not an integer or less than 1, re...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.If this challenge is too easy for you, check out: https://www.codewars.com/kata/5cc89c182777b00001b3e6a2 ___ Upside-Down Pyramid Addition is the process of taking a list of...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There is a house with 4 levels. In that house there is an elevator. You can program this elevator to go up or down, depending on what button the user touches inside the elevat...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A new school year is approaching, which also means students will be taking tests. The tests in this kata are to be graded in different ways. A certain number of points will ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## **Task** You are given a positive integer (`n`), and your task is to find the largest number **less than** `n`, which can be written in the form `a**b`, where `a` can be 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 hash of letters and the number of times they occur, recreate all of the possible anagram combinations that could be created using all of the letters, sorted alphabetic...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For encrypting strings this region of chars is given (in this order!): * all letters (ascending, first all UpperCase, then all LowerCase) * all digits (ascending) * the follo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Calculate the product of all elements in an array. ```if:csharp If the array is *null*, you should throw `ArgumentNullException` and if the array is empty, you should throw `I...
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 based on [Project Euler Problem 546](https://projecteuler.net/problem=546)_ # Objective Given the recursive sequence fk(n) = ∑ i = 0 n fk(floor(i / k...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You were given a string of integer temperature values. Create a function `close_to_zero(t)` and return the closest value to 0 or `0` if the string is empty. If two numbers are...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Simple interest on a loan is calculated by simply taking the initial amount (the principal, p) and multiplying it by a rate of interest (r) and the number of time periods (n)....