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.# Introduction
Ka ka ka cypher is a cypher used by small children in some country. When a girl wants to pass something to the other girls and there are some boys nearby, she... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A carpet shop sells carpets in different varieties. Each carpet can come in a different roll width and can have a different price per square meter.
Write a function `cost_of... |
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 `n` return `"odd"` if the number of its divisors is odd. Otherwise return `"even"`.
**Note**: big inputs will be tested.
## Examples:
All prime numbers hav... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given two arrays `arr1` and `arr2`, where `arr2` always contains integers.
Write the function `find_array(arr1, arr2)` such that:
For `arr1 = ['a', 'a', 'a', 'a', 'a... |
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 binary string (a string consisting of only '1' and '0'). The only operation that can be performed on it is a Flip operation.
It flips any binary ch... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Very simple, given a number, find its opposite.
Examples:
```
1: -1
14: -14
-34: 34
```
~~~if:sql
You will be given a table: `opposite`, with a column: `number`. Return a ta... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Find the volume of a cone whose radius and height are provided as parameters to the function `volume`. Use the value of PI provided by your language (for example: `Math.PI` in... |
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 taking in a string like `WOW this is REALLY amazing` and returning `Wow this is really amazing`. String should be capitalized and properly spaced. Us... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Nickname Generator
Write a function, `nicknameGenerator` that takes a string name as an argument and returns the first 3 or 4 letters as a nickname.
If the 3rd letter is a c... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.At the start of each season, every player in a football team is assigned their own unique squad number. Due to superstition or their history certain numbers are more desirable... |
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 an extension of "Combinations in a Set Using Boxes":https://www.codewars.com/kata/5b5f7f7607a266914200007c
The goal for this kata is to get all the possible comb... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.###Story
Sometimes we are faced with problems when we have a big nested dictionary with which it's hard to work. Now, we need to solve this problem by writing a function that ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Theory
This section does not need to be read and can be skipped, but it does provide some clarity into the inspiration behind the problem.
In music theory, a major scale cons... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*** No Loops Allowed ***
You will be given an array (a) and a limit value (limit). You must check that all values in the array are below or equal to the limit value. If they ... |
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 `count_vowels` to count the number of vowels in a given string.
### Notes:
- Return `nil` or `None` for non-string inputs.
- Return `0` if the parameter is ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this simple exercise, you will build a program that takes a value, `integer `, and returns a list of its multiples up to another value, `limit `. If `limit` is a multiple o... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This will probably be a little series :)
X-Shape
You will get an odd Integer n (>= 3) and your task is to draw a X. Each line is separated with '\n'.
Use the following char... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result.
It should remove all values from list `a`, which a... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# The Problem
Dan, president of a Large company could use your help. He wants to implement a system that will switch all his devices into offline mode depending on his meetin... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The purpose of this series is developing understanding of stastical problems in AS and A level maths. Let's get started with a simple concept in statistics: Mutually exclusive... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task
The year of `2013` is the first year after the old `1987` with only distinct digits.
Now your task is to solve the following problem: given a `year` number, find the... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Let us begin with an example:
A man has a rather old car being worth $2000.
He saw a secondhand car being worth $8000. He wants to keep his old car until he can buy the seco... |
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.##Task:
You have to write a function **pattern** which creates the following pattern upto n number of rows. *If the Argument is 0 or a Negative Integer then it should return ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have stumbled across the divine pleasure that is owning a dog and a garden. Now time to pick up all the cr@p! :D
Given a 2D array to represent your garden, you must find ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your dad doesn't really *get* punctuation, and he's always putting extra commas in when he posts. You can tolerate the run-on sentences, as he does actually talk like that, bu... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a program to determine if two numbers are coprime. A pair of numbers are coprime if their greatest shared factor is 1. For example:
```
20 and 27
Factors of 20: 1, 2, 4,... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Jack really likes his number five: the trick here is that you have to multiply each number by 5 raised to the number of digits of each numbers, so, for example:
```python
mult... |
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 of strings, reverse them and their order in such way that their length stays the same as the length of the original inputs.
### Example:
```
Input: {... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.I'm afraid you're in a rather unfortunate situation. You've injured your leg, and are unable to walk, and a number of zombies are shuffling towards you, intent on eating your ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Introduction
There is a war and nobody knows - the alphabet war!
There are two groups of hostile letters. The tension between left side letters and right side letters was... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.#### Task:
Your job here is to implement a function `factors`, which takes a number `n`, and outputs an array of arrays comprised of two
parts, `sq` and `cb`. The part `sq` w... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Summation
Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0.
For example:
```if-not:racke... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Colour plays an important role in our lifes. Most of us like this colour better then another. User experience specialists believe that certain colours have certain psychologic... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This is a problem that involves adding numbers to items in a list.
In a list you will have to add the item's remainder when divided by a given divisor to each item.
For examp... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters of the alphabet except... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A high school has a strange principal. On the first day, he has his students perform an odd opening day ceremony:
There are number of lockers "n" and number of students "n" i... |
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 two integers (`a, b`, where `a < b`) and return an array of all integers between the input parameters, **including** them.
For example:
```
a... |
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 n(parameter) number of rows.
####Rules/Note:
* If the Argument is 0 ... |
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
```python
has_two_cube_sums(n)
```
which checks if a given number `n` can be written as the sum of two cubes in two different ways: `n = a³+b³ = c³+d³`.
Al... |
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 numbers in which two numbers occur once and the rest occur only twice. Your task will be to return the sum of the numbers that occu... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.__Definition:__ According to Wikipedia, a [complete binary tree](https://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees) is a binary tree _"where every level, except ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Introduction
Each chemical element in its neutral state has a specific number of electrons associated with it. This is represented by the **atomic number** which is noted... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.John has some amount of money of which he wants to deposit a part `f0` to the bank at the beginning
of year `1`. He wants to withdraw each year for his living an amount `c0`.
... |
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 #29
Your friend Nhoj has dislexia, but can easily read messages if the words are writt... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task
Round the given number `n` to the nearest multiple of `m`.
If `n` is exactly in the middle of 2 multiples of m, return `n` instead.
# Example
For `n = 20, m = 3`,... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For an integer ```k``` rearrange all the elements of the given array in such way, that:
all elements that are less than ```k``` are placed before elements that are not less t... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*Inspired by the [Fold an Array](https://www.codewars.com/kata/fold-an-array) kata. This one is sort of similar but a little different.*
---
## Task
You will receive an arra... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this Kata, you will be given an array of integers and your task is to return the number of arithmetic progressions of size `3` that are possible from that list. In each pro... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.I found this interesting interview question just today:
> *8 coins are given where all the coins have equal weight, except one. The odd one weights less than the others, not ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A forest fire has been spotted at *fire*, a simple 2 element array with x, y coordinates.
The forest service has decided to send smoke jumpers in by plane and drop them in th... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an input string.
For each symbol in the string if it's the first character occurrence, replace it with a '1', else replace it with the amount of times you've al... |
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.Some integral numbers are odd. All are more odd, or less odd, than others.
Even numbers satisfy `n = 2m` ( with `m` also integral ) and we will ( completely arbitrarily ) thi... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.*Translations appreciated*
## Background information
The Hamming Code is used to correct errors, so-called bit flips, in data transmissions. Later in the description follows... |
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 `getDrinkByProfession`/`get_drink_by_profession()` that receives as input parameter a string, and produces outputs according to the following table:
Input... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Your Task
You have a cuboid with dimensions x,y,z ∈ ℕ. A subcuboid of this cuboid has dimensions length, width, height ∈ ℕ where 1≤length≤x, 1≤width≤y, 1≤height≤z. If two su... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Coffee Vending Machine Problems [Part 1]
You have a vending machine, but it can not give the change back. You decide to implement this functionality. First of all, you need t... |
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 create a function that takes a 2D array/list of non-negative integer pairs and returns the sum of all the "saving" that you can have getting the [LCM]... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given an array of non-negative integers, your task is to complete the series from 0 to the highest number in the array.
If the numbers in the sequence provided are no... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of `numbers` and the second is the... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a string, swap the case for each of the letters.
e.g. CodEwArs --> cODeWaRS
### Examples
```
"" -> ""
"CodeWars" -> "cODEwARS"
"abc" -> "ABC"... |
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 the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or non-positive integers will be passed.
Fo... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We have 3 equations with 3 unknowns x, y, and z and we are to solve for these unknowns.
Equations 4x -3y +z = -10, 2x +y +3z = 0, and -x +2y -5z = 17 will be passed in as an 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 of words and numbers. Extract the expression including:
1. the operator: either addition or subtraction
2. the two numbers that we are operating on
Return the... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Define two functions: `hex_to_bin` and `bin_to_hex` (or `hexToBin` and `binToHex`)
# hex_to_bin
Takes a hexadecimal string as an argument .
**Note:** This string can conta... |
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 a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is eve... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Laura Bassi was the first female professor at a European university.
Despite her immense intellect, she was not always allowed to lecture publicly.
One day a professor with... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a natural number n, we want to know in how many ways we may express these numbers as product of other numbers.
For example the number
```python
18 = 2 x 9 = 3 x 6 = 2 ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have to build a pyramid.
This pyramid should be built from characters from a given string.
You have to create the code for these four methods:
```python
watch_pyramid_fr... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your task is to write function which takes string and list of delimiters as an input and returns list of strings/characters after splitting given string.
Example:
```python
m... |
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 of 2^(k) integers (for some integer `k`), perform the following operations until the array contains only one element:
```
On the 1st, 3rd, 5th, etc.
it... |
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 calculates the original product price, without VAT.
## Example
If a product price is `200.00` and VAT is `15%`, then the final product price (with VAT) ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dub... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.This time no story, no theory. The examples below show you how to write function `accum`:
**Examples:**
```
accum("abcd") -> "A-Bb-Ccc-Dddd"
accum("RqaEzty") -> "R-Qq-Aaa-Eee... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The numbers 12, 63 and 119 have something in common related with their divisors and their prime factors, let's see it.
```
Numbers PrimeFactorsSum(pfs) DivisorsSum(ds) ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We need a function ```count_sel()``` that receives an array or list of integers (positive and negative) and may give us the following information in the order and structure p... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Ask a small girl - "How old are you?". She always says strange things... Lets help her!
For correct answer program should return int from 0 to 9.
Assume test input string a... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The number ```12``` is the first number in having six divisors, they are: ```1, 2, 3, 4, 6 and 12.```
Your challenge for this kata is to find the minimum number that has a cer... |
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 write function last_digits(n,d) which return the last `d` digits of an integer `n` as a list.
`n` will be from 0 to 10^10
Examples:
`last_digits(1,1) --> ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Here you will create the classic [Pascal's triangle](https://en.wikipedia.org/wiki/Pascal%27s_triangle).
Your function will be passed the depth of the triangle and you code ha... |
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, the number 0 is infected. You are given a list. Every turn, any item in the list that is adjacent to a 0 becomes infected and transforms into a 0. How many turns... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## **Task**
Four mirrors are placed in a way that they form a rectangle with corners at coordinates `(0, 0)`, `(max_x, 0)`, `(0, max_y)`, and `(max_x, max_y)`. A light ray en... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are given a set of `n` segments on the axis `Ox`, each segment has integer endpoints between `0` and `m` inclusive.
Segments may intersect, overlap or even coincide with ... |
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 function```isDivideBy``` (or ```is_divide_by```) to check if an integer number is divisible by each out of two arguments.
A few cases:
```
(-12, 2, -... |
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 ___Reverse and Combine Words___. It's not too difficult, but there are some things you have to consider...
### So what to do?
Input: String containing diffe... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The odd and even numbers are fighting against each other!
You are given a list of positive integers. The odd numbers from the list will fight using their `1` bits from their ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The Monty Hall problem is a probability puzzle base on the American TV show "Let's Make A Deal".
In this show, you would be presented with 3 doors: One with a prize behind it... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task
You are a magician. You're going to perform a trick.
You have `b` black marbles and `w` white marbles in your magic hat, and an infinite supply of black and white ma... |
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 made up of letters a, b, and/or c, switch the position of letters a and b (change a to b and vice versa). Leave any incidence of c untouched.
Example:
'acb' -... |
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 two numbers as input, ```num``` and ```nth``` and return the `nth` digit of `num` (counting from right to left).
## Note
- If ```num``` is ne... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Your Job
Find the sum of all multiples of `n` below `m`
## Keep in Mind
* `n` and `m` are natural numbers (positive integers)
* `m` is **excluded** from the ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Everybody know that you passed to much time awake during night time...
Your task here is to define how much coffee you need to stay awake after your night.
You will have to ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The rgb function is incomplete. Complete it so that passing in RGB decimal values will result in a hexadecimal representation being returned. Valid decimal values for RGB are ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You are a *khm*mad*khm* scientist and you decided to play with electron distribution among atom's shells.
You know that basic idea of electron distribution is that electrons s... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.### Description
As hex values can include letters `A` through to `F`, certain English words can be spelled out, such as `CAFE`, `BEEF`, or `FACADE`.
This vocabulary can be ext... |
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 say we have a positive integer, `$n$`. You have to find the smallest possible positive integer that when multiplied by `$n$`, becomes a perfect power of integer... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Invalid Login - Bug Fixing #11
Oh NO! Timmy has moved divisions... but now he's in the field of security. Timmy, being the top coder he is, has allowed some bad code throug... |
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 create a function `isPronic` to check whether the argument passed is a Pronic Number and return true if it is & false otherwise.
### Description:
`Proni... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.```if:python
Create a function `args_count`, that returns the count of passed arguments
```
```if:kotlin
Create a function `argsCount`, that returns the count of passed argume... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.