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.# Task Given a string `s`, find out if its characters can be rearranged to form a palindrome. # Example For `s = "aabb"`, the output should be `true`. We can rearrange `...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You should write a function that takes a string and a positive integer `n`, splits the string into parts of length `n` and returns them in an array. It is ok for the last elem...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task A media access control address (MAC address) is a unique identifier assigned to network interfaces for communications on the physical network segment. The standard (...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A trick I learned in elementary school to determine whether or not a number was divisible by three is to add all of the integers in the number together and to divide the resul...
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 build a function to return either `true/True` or `false/False` if a string can be seen as the repetition of a simpler/shorter subpattern or not. For ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Let's call `product(x)` the product of x's digits. Given an array of integers a, calculate `product(x)` for each x in a, and return the number of distinct results you ...
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 ```python alternate_sort(l) ``` that combines the elements of an array by sorting the elements ascending by their **absolute value** and outputs negative and ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### Vaccinations for children under 5 You have been put in charge of administrating vaccinations for children in your local area. Write a function that will generate 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.Given a string, determine if it's a valid identifier. ## Here is the syntax for valid identifiers: * Each identifier must have at least one character. * The first character m...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Two moving objects A and B are moving accross the same orbit (those can be anything: two planets, two satellites, two spaceships,two flying saucers, or spiderman with batman i...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.- Kids drink toddy. - Teens drink coke. - Young adults drink beer. - Adults drink whisky. Make a function that receive age, and return what they drink. **Rules:** - Childre...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For every positive integer N, there exists a unique sequence starting with 1 and ending with N and such that every number in the sequence is either the double of the preceedin...
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 from check py.checkio.org You are given an array with positive numbers and a number N. You should find the N-th power of the element in the array with the index ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Math geeks and computer nerds love to anthropomorphize numbers and assign emotions and personalities to them. Thus there is defined the concept of a "happy" number. A happy nu...
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 an orchard worker. There are `n` piles of fruits waiting to be transported. Each pile of fruit has a corresponding weight. John's job is to combine the fruits...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Hey You ! Sort these integers for me ... By name ... Do it now ! --- ## Input * Range is ```0```-```999``` * There may be duplicates * The array may be empty ## Ex...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Pair of gloves ============= Winter is coming, you must prepare your ski holidays. The objective of this kata is to determine the number of pair of gloves you can constitute ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Make a function that will return a greeting statement that uses an input; your program should return, `"Hello, how are you doing today?"`. SQL: return results in a column na...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Unicode Transformation Format – 8-bit As the name suggests UTF-8 was designed to encode data in a stream of bytes. It works by splitting the bits up in multiples of eight. Th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*This is the advanced version of the [Total Primes](https://www.codewars.com/kata/total-primes/) kata.* --- The number `23` is the smallest prime that can be "cut" into **mu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Story John found a path to a treasure, and while searching for its precise location he wrote a list of directions using symbols `"^"`, `"v"`, `"<"`, `">"` which mean `north...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The sports centre needs repair. Vandals have been kicking balls so hard into the roof that some of the tiles have started sticking up. The roof is represented by r. As a quic...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task Implement a function which finds the numbers less than `2`, and the indices of numbers greater than `1` in the given sequence, and returns them as a pair of sequences...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your task is to return the number of visible dots on a die after it has been rolled(that means the total count of dots that would not be touching the table when rolled) 6, 8,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task: This kata asks you to make a custom esolang interpreter for the language [MiniBitMove](https://esolangs.org/wiki/MiniBitMove). MiniBitMove has only two commands and op...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Let's imagine we have a popular online RPG. A player begins with a score of 0 in class E5. A1 is the highest level a player can achieve. Now let's say the players wants to ra...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An array of size N x M represents pixels of an image. Each cell of this array contains an array of size 3 with the pixel's color information: `[R,G,B]` Convert the color imag...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Mr. Square is going on a holiday. He wants to bring 2 of his favorite squares with him, so he put them in his rectangle suitcase. Write a function that, given the size of the...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The integer ```64``` is the first integer that has all of its digits even and furthermore, is a perfect square. The second one is ```400``` and the third one ```484```. Give...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Number of people in the bus There is a bus moving in the city, and it takes and drop some people in each bus stop. You are provided with a list (or array) of integer array...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A very passive-aggressive co-worker of yours was just fired. While he was gathering his things, he quickly inserted a bug into your system which renamed everything to what loo...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An array is defined to be `odd-heavy` if it contains at least one odd element and every element whose value is `odd` is greater than every even-valued element. eg. ``` Arra...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Debug the functions Should be easy, begin by looking at the code. Debug the code and the functions should work. There are three functions: ```Multiplication (x)``` ```Addition...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution._A mad sociopath scientist just came out with a brilliant invention! He extracted his own memories to forget all the people he hates! Now there's a lot of information in there...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Compare two strings by comparing the sum of their values (ASCII character code). * For comparing treat all letters as UpperCase * `null/NULL/Nil/None` should be treated as em...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task `Triangular numbers` are defined by the formula `n * (n + 1) / 2` with `n` starting from 1. They count the number of objects that can form an equilateral triangle as sh...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Finish the solution so that it takes an input `n` (integer) and returns a string that is the decimal representation of the number grouped by commas after every 3 digits. Assu...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Suppose there are `n` people standing in a circle and they are numbered 1 through n in order. Person 1 starts off with a sword and kills person 2. He then passes t...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The objective is to return all pairs of integers from a given array of integers that have a difference of 2. The result array should be sorted in ascending order of values. ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Pirates have notorious difficulty with enunciating. They tend to blur all the letters together and scream at people. At long last, we need a way to unscramble what these pira...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We have the following sequence: ```python f(0) = 0 f(1) = 1 f(2) = 1 f(3) = 2 f(4) = 4; f(n) = f(n-1) + f(n-2) + f(n-3) + f(n-4) + f(n-5); ``` Your task is to give the number...
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 `longer` that accepts a string and sorts the words in it based on their respective lengths in an ascending order. If there are two words of the same lengths,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are stacking some boxes containing gold weights on top of each other. If a box contains more weight than the box below it, it will crash downwards and combine their weight...
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 calculates the derivative of a polynomial. A polynomial is an expression like: 3x^(4) - 2x^(2) + x - 10 ### How to calculate the derivative: * Tak...
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 ```javascript tripledouble(num1,num2) ``` ```python triple_double(num1, num2) ``` which takes numbers `num1` and `num2` and returns `1` if there is a straig...
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.# Task You are given three integers `l, d and x`. Your task is: ``` • determine the minimal integer n such that l ≤ n ≤ d, and the sum of its digits equals x. • determin...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Bleatrix Trotter the sheep has devised a strategy that helps her fall asleep faster. First, she picks a number N. Then she starts naming N, 2 × N, 3 × N, and so on. Whenever s...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## If/else syntax debug While making a game, your partner, Greg, decided to create a function to check if the user is still alive called `checkAlive`/`CheckAlive`/`check_aliv...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Looking at consecutive powers of `2`, starting with `2^1`: `2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, ...` Note that out of all the digits `0...
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 [InfiniTick](https://esolangs.org/wiki/InfiniTick). InfiniTick is a descendant of [Tick](https://esolangs.org/w...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Sam has opened a new sushi train restaurant - a restaurant where sushi is served on plates that travel around the bar on a conveyor belt and customers take the plate that they...
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 mission is to rotate matrix counter - clockwise N-times. So, you will have 2 inputs: 1)matrix 2)a number, how many times to turn it And an output...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task Your task is to find the similarity of given sorted arrays `a` and `b`, which is defined as follows: you take the number of elements which are present in both arra...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Base reduction ## Input A positive integer: ``` 0 < n < 1000000000 ``` ## Output The end result of the base reduction. If it cannot be fully reduced (reduced down to a ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The Story: Aliens from Kepler 27b have immigrated to Earth! They have learned English and go to our stores, eat our food, dress like us, ride Ubers, use Google, etc. However, ...
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 `1176` and its square (`1176 * 1176) = 1382976`. Notice that: * the first two digits of `1176` form a prime. * the first two digits of the square `1382976...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Introduction Digital Cypher assigns to each letter of the alphabet unique number. For example: ``` a b c d e f g h i j k l m 1 2 3 4 5 6 7 8 9 10 11...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Raj was to move up through a pattern of stairs of a given number **(n)**. Help him to get to the top using the function **stairs**. ##Keep in mind : * If **n<1** then re...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In case you might be unlucky enough not to know the best dark fantasy franchise ever, Berserk tells the story of a man that, hating gratuitous violence, decided to become a me...
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 checks the braces status in a string, and return `True` if all braces are properly closed, or `False` otherwise. Available types of brackets: `()`, `[]`,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Triangular numbers count the number of objects that can form an equilateral triangle. The nth triangular number forms an equilateral triangle with n dots on each side (includi...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In Spanish, the conjugated verb changes by adding suffixes and according to the person we're talking about. There's something similar in English when we talk about "She", "He"...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The first input array is the key to the correct answers to an exam, like ["a", "a", "b", "d"]. The second one contains a student's submitted answers. The two arrays are not ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Say hello! Write a function to greet a person. Function will take name as input and greet the person by saying hello. Return null/nil/None if input is empty string or null/ni...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.When you divide the successive powers of `10` by `13` you get the following remainders of the integer divisions: `1, 10, 9, 12, 3, 4`. Then the whole pattern repeats. He...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a regex to validate a 24 hours time string. See examples to figure out what you should check for: Accepted: 01:00 - 1:00 Not accepted: 24:00 You should check for c...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Personalized greeting Create a function that gives a personalized greeting. This function takes two parameters: `name` and `owner`. Use conditionals to return the proper m...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Let's play Psychic A box contains green, red, and blue balls. The total number of balls is given by `n` (`0 < n < 50`). Each ball has a mass that depends on the ball colo...
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 checks if a number `n` is divisible by two numbers `x` **AND** `y`. All inputs are positive, non-zero digits. ```JS Examples: 1) n = 3, x = 1, y = 3 ...
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 as its parameters *one or more numbers which are the diameters of circles.* The function should return the *total area of all the circles*, round...
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 reverses all of the words within the string passed in. Example: ```python reverseWords("The greatest victory is that which requires no batt...
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 queue for the self-checkout tills at the supermarket. Your task is write a function to calculate the total time required for all the customers to check out! ### in...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Problem In China,there is an ancient mathematical book, called "The Mathematical Classic of Sun Zi"(《孙子算经》). In the book, there is a classic math problem: “今有物不知其数,三三数之剩二,五...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You receive the name of a city as a string, and you need to return a string that shows how many times each letter shows up in the string by using an asterisk (`*`). For examp...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# It's too hot, and they can't even… One hot summer day Pete and his friend Billy decided to buy watermelons. They chose the biggest crate. They rushed home, dying of thirst,...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The marketing team is spending way too much time typing in hashtags. Let's help them with our own Hashtag Generator! Here's the deal: - It must start with a hashtag (`#`)...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Beaches are filled with sand, water, fish, and sun. Given a string, calculate how many times the words `"Sand"`, `"Water"`, `"Fish"`, and `"Sun"` appear without overlapping (r...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Create a function which accepts one arbitrary string as an argument, and return a string of length 26. The objective is to set each of the 26 characters of the output string ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Number pyramid Number pyramid is a recursive structure where each next row is constructed by adding adjacent values of the current row. For example: ``` Row 1 [1 ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.My friend John likes to go to the cinema. He can choose between system A and system B. ``` System A : he buys a ticket (15 dollars) every time System B : he buys a card (500 d...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You will have a list of rationals in the form ``` lst = [ [numer_1, denom_1] , ... , [numer_n, denom_n] ] ``` or ``` lst = [ (numer_1, denom_1) , ... , (numer_n, denom_n) ] `...
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 th...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We are interested in collecting the sets of six prime numbers, that having a starting prime p, the following values are also primes forming the sextuplet ```[p, p + 4, p + 6, ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The sum of divisors of `6` is `12` and the sum of divisors of `28` is `56`. You will notice that `12/6 = 2` and `56/28 = 2`. We shall say that `(6,28)` is a pair with a ratio ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two integers `a` and `b`, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal retur...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given two numbers (m and n) : - convert all numbers from m to n to binary - sum them as if they were in base 10 - convert the result to binary - return as string Eg: with t...
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 (a list in Python) of integers and an integer `n`, find all occurrences of `n` in the given array and return another array containing all the index positions of...
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 of strings complete the function landPerimeter by calculating the total perimeter of all the islands. Each piece of land will be marked with 'X' while...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write ```python word_pattern(pattern, string) ``` that given a ```pattern``` and a string ```str```, find if ```str``` follows the same sequence as ```pattern```. For exampl...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Wilson primes satisfy the following condition. Let ```P``` represent a prime number. Then ```((P-1)! + 1) / (P * P)``` should give a whole number. Your task is to create a ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You're a programmer in a SEO company. The SEO specialist of your company gets the list of all project keywords everyday, then he looks for the longest keys to analyze them. Y...
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 initial string `s`, switch case of the minimal possible number of letters to make the whole string written in the upper case or in the lower case. # Input/Out...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.As part of this Kata, you need to find the length of the sequence in an array, between the first and the second occurrence of a specified number. For example, for a given arr...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task We have a N×N `matrix` (N<10) and a robot. We wrote in each point of matrix x and y coordinates of a point of matrix. When robot goes to a point of matrix, rea...
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 certain array of length ```n```, such that ```n > 4```, having positive and negative integers but there will be no zeroes and all the elements will occur o...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.```if-not:sql Create a function (or write a script in Shell) that takes an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers. ``` ```if:sql ...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Hey CodeWarrior, we've got a lot to code today! I hope you know the basic string manipulation methods, because this kata will be all about them. Here we go... ## Backgroun...
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task A newspaper is published in Walrusland. Its heading is `s1` , it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cu...
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 array `arr`. Your task is to remove one element, maximize the product of elements. The result is the element which should be removed. If more than on...