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
After a long night (work, play, study) you find yourself sleeping on a bench in a park. As you wake up and try to figure out what happened you start counting trees.
Yo... |
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 the 42 number as "The answer to life, the universe and everything" according to Douglas Adams' "The Hitchhiker's Guide to the Galaxy". For Freud, the answer ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Making Change
Complete the method that will determine the minimum number of coins needed to make change for a given amount in American currency.
Coins used will be half-do... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A very easy task for you!
You have to create a method, that corrects a given date string.
There was a problem in addition, so many of the date strings are broken.
Date-Format... |
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 said to be `hollow` if it contains `3` or more `0`s in the middle that are preceded and followed by the same number of non-zero elements. Furthermore, all the zero... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A number is self-descriptive when the n'th digit describes the amount n appears in the number.
E.g. 21200:
There are two 0's in the number, so the first digit is 2.
There i... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The aim of the kata is to decompose `n!` (factorial n) into its prime factors.
Examples:
```
n = 12; decomp(12) -> "2^10 * 3^5 * 5^2 * 7 * 11"
since 12! is divisible by 2 ten... |
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 - Part 2
This is version 2 of my ['Write Number in Exanded Form' Kata](https://www.codewars.com/kata/write-number-in-expanded-form).
You will... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A wildlife study involving ducks is taking place in North America. Researchers are visiting some wetlands in a certain area taking a survey of what they see. The researchers w... |
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 the first of the ADFGX Ciphers, the harder version can be found `here.
The ADFGX Cipher is a pretty well-known Cryptographic tool, and is essentially a modified... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this Kata, you will be given a string and your task will be to return a list of ints detailing the count of uppercase letters, lowercase, numbers and special characters, as... |
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 buyer/seller and your buisness is at stake... You ___need___ to make profit... Or at least, you need to lose the least amount of money!
Knowing a list of prices for... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every Turkish citizen has an identity number whose validity can be checked by these set of rules:
- It is an 11 digit number
- First digit can't be zero
- Take the sum of 1st... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task:
Write a function that accepts an integer `n` and returns **the sum of the factorials of the first **`n`** Fibonacci numbers**
## Examples:
```python
sum_fib(2) = 2 ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Feynman's squares
Richard Phillips Feynman was a well-known American physicist and a recipient of the Nobel Prize in Physics. He worked in theoretical physics and pioneered ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task
John loves encryption. He can encrypt any string by the following algorithm:
```
take the first and the last letters of the word;
replace the letters between them with... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given three arrays of integers, return the sum of elements that are common in all three arrays.
For example:
```
common([1,2,3],[5,3,2],[7,3,2]) = 5 because 2 & 3 are commo... |
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 with the signature shown below:
```python
def is_int_array(arr):
return True
```
* returns `true / True` if every element in an array is an integer or a... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Imagine two rings with numbers on them. The inner ring spins clockwise (decreasing by 1 each spin) and the outer ring spins counter clockwise (increasing by 1 each spin). We s... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this Kata, you will be given a multi-dimensional array containing `2 or more` sub-arrays of integers. Your task is to find the maximum product that can be formed by taking ... |
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 `product`, find the smallest positive integer the product of whose digits is equal to product. If there is no such integer, return -1 instead.
# Exam... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The medians of a triangle are the segments that unit the vertices with the midpoint of their opposite sides.
The three medians of a triangle intersect at the same point, calle... |
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 must take an input string, reverse the order of the words, and reverse the order of the letters within the words.
But, as a bonus, every test input will end ... |
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 decimal number `n` as a **string**. Transform it into an array of numbers (given as **strings** again), such that each number has only one nonzero digi... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In this kata, your task is to write a function `to_bytes(n)` (or `toBytes(n)` depending on language) that produces a list of bytes that represent a given non-negative integer ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider a sequence, which is formed by the following rule: next term is taken as the smallest possible non-negative integer, which is not yet in the sequence, so that `no 3` ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In some countries of former Soviet Union there was a belief about lucky tickets. A transport ticket of any sort was believed to posess luck if sum of digits on the left half o... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Lucas numbers are numbers in a sequence defined like this:
```
L(0) = 2
L(1) = 1
L(n) = L(n-1) + L(n-2)
```
Your mission is to complete the function that returns the `n`th te... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.`late_clock` function receive an array with 4 digits and should return the latest time that can be built with those digits.
The time should be in `HH:MM` format.
Examples:
``... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task
Write a method `remainder` which takes two integer arguments, `dividend` and `divisor`, and returns the remainder when dividend is divided by divisor. Do NOT use the ... |
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 field, two beggars A and B found some gold at the same time. They all wanted the gold, and they decided to use simple rules to distribute gold:
```
They divided... |
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 returns the following Pattern(See Examples) upto (2n-1) rows, where n is parameter.
### Rules/Note:
* If the Argument... |
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 ```x(n)``` that takes in a number ```n``` and returns an ```nxn``` array with an ```X``` in the middle. The ```X``` will be represented by ```1's``` and the r... |
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 integers. Your task is to sort odd numbers within the array in ascending order, and even numbers in descending order.
Note that zero is an even numb... |
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, we will check is an array is (hyper)rectangular.
A rectangular array is an N-dimensional array with fixed sized within one dimension. Its sizes can be repsente... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Challenge :
Write a function that takes a single argument `n` that is a string representation of a simple mathematical expression and evaluates it as a floating point valu... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.DropCaps means that the first letter of the starting word of the paragraph should be in caps and the remaining lowercase, just like you see in the newspaper.
But for a chang... |
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**
Create a function, called ``removeVowels`` (or ``remove_vowels``), that takes a string argument and returns tha... |
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 so that it takes an array of keys and a default value and returns a hash (Ruby) / dictionary (Python) with all keys set to the default value.
## Exampl... |
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 ```prime_bef_aft()``` that gives the largest prime below a certain given value ```n```,
```befPrime or bef_prime``` (depending on the language),
and the... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.It is 2050 and romance has long gone, relationships exist solely for practicality.
MatchMyHusband is a website that matches busy working women with perfect house husbands. Yo... |
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 figure out the index of which vowel is missing from a given string:
* `A` has an index of 0,
* `E` has an index of 1,
* `I` has an index of 2,
* `O` has an i... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Quantum mechanics tells us that a molecule is only allowed to have specific, discrete amounts of internal energy. The 'rigid rotor model', a model for describing rotations, te... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.It's bonus time in the big city! The fatcats are rubbing their paws in anticipation... but who is going to make the most money?
Build a function that takes in two arguments ... |
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 write a function (`keepOrder` in JS/CoffeeScript, `keep_order` in Ruby/Crystal/Python, `keeporder` in Julia), which takes a sorted array `ary` ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.How many bees are in the beehive?
* bees can be facing UP, DOWN, LEFT, or RIGHT
* bees can share parts of other bees
Examples
Ex1
```
bee.bee
.e..e..
.b..eeb
```
*Ans... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.```if:python,php
In this kata you will have to write a function that takes `litres` and `price_per_litre` as arguments. Purchases of 2 or more litres get a discount of 5 cents... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## The Riddle
The King of a small country invites 1000 senators to his annual party. As a tradition, each senator brings the King a bottle of wine. Soon after, the Queen disc... |
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 numbers with different colours with the sequence: ['red', 'yellow', 'blue'].
That sequence colours the numbers in the following way:
1 2 3 4 5 6 7 ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given the triangle of consecutive odd numbers:
```
1
3 5
7 9 11
13 15 17 19
21 23 25 27 29
...
```
Calculate... |
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 array of integers, your task will be to count all pairs in that array and return their count.
**Notes:**
* Array can be empty or contain only one value; in ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task
In your favorite game, you must shoot a target with a water-gun to gain points. Each target can be worth a different amount of points.
You are guaranteed to hit e... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.My friend wants a new band name for her band. She like bands that use the formula: "The" + a noun with the first letter capitalized, for example:
`"dolphin" -> "The Dolphin"`... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Ever since you started work at the grocer, you have been faithfully logging down each item and its category that passes through. One day, your boss walks in and asks, "Why are... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# How much is the fish! (- Scooter )
The ocean is full of colorful fishes. We as programmers want to know the hexadecimal value of these fishes.
## Task
Take all hexadecimal ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.```if-not:racket
Write a function called `repeat_str` which repeats the given string `src` exactly `count` times.
```
```if:racket
Write a function called `repeat-string` whic... |
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 follow up from my kata Insert Dashes.
Write a function ```insertDashII(num)``` that will insert dashes ('-') between each two odd numbers and asterisk ('\*') betwee... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Uh oh, Someone at the office has dropped all these sequences on the floor and forgotten to label them with their correct bases.
We have to fix this before the boss gets back... |
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 flattens an `Array` of `Array` objects into a flat `Array`. Your function must only do one level of flattening.
```python
flatten [1,2,3] # => [1,2,3]
... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Similar to the [previous kata](https://www.codewars.com/kata/string-subpattern-recognition-ii/), but this time you need to operate with shuffled strings to identify if they ar... |
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, `gooseFilter` / `goose-filter` / `goose_filter` /` GooseFilter`, that takes an array of strings as an argument and returns a filtered array containing the sa... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Hi! Welcome to my first kata.
In this kata the task is to take a list of integers (positive and negative) and split them according to a simple rule; those ints greater than o... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every non-negative integer N has a binary representation. For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on. Note that except for N = 0... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given four positive integers $n$, $m$, $a$, $b$ ($1 \le b \le n \le 50$; $1 \le a \le m \le 50$). Find any such rectangular ma... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The principal of a school likes to put challenges to the students related with finding words of certain features.
One day she said: "Dear students, the challenge for today is ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have a long fence which consists of $n$ sections. Unfortunately, it is not painted, so you decided to hire $q$ painters to paint i... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Arpa is researching the Mexican wave.
There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The campus has $m$ rooms numbered from $0$ to $m - 1$. Also the $x$-mouse lives in the campus. The $x$-mouse is not just a mouse: each... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two arithmetic progressions: a_1k + b_1 and a_2l + b_2. Find the number of integers x such that L ≤ x ≤ R and x = a_1k' ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be t... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.В Берляндском государственном университете локальная сеть между серверами не всегда работает без ошибок. При передаче двух одинаковых ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given string $s$ of length $n$ consisting of 0-s and 1-s. You build an infinite string $t$ as a concatenation of an infinite n... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.
Neko has two integ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array of $n$ integers: $a_1, a_2, \ldots, a_n$. Your task is to find some non-zero integer $d$ ($-10^3 \leq d \leq 10... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is sev... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Suppose you are performing the following algorithm. There is an array $v_1, v_2, \dots, v_n$ filled with zeroes at start. The followin... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculat... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given two matrices $A$ and $B$. Each matrix contains exactly $n$ rows and $m$ columns. Each element of $A$ is either $0$ or $1... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.There is a grass field that stretches infinitely.
In this field, there is a negligibly small cow. Let (x, y) denote the point that is ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given a directed graph consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one directi... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have a set of items, each having some integer weight not greater than $8$. You denote that a subset of items is good if total weig... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Recently Vasya found a golden ticket — a sequence which consists of $n$ digits $a_1a_2\dots a_n$. Vasya considers a ticket to be lucky... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The circle line of the Roflanpolis subway has $n$ stations.
There are two parallel routes in the subway. The first one visits station... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.We have a sequence of N integers: A_1, A_2, \cdots, A_N.
You can perform the following operation between 0 and K times (inclusive):
-... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. Afte... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero sc... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Jzzhu has invented a kind of sequences, they meet the following property:$f_{1} = x ; f_{2} = y ; \forall i(i \geq 2), f_{i} = f_{i - ... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Given is a string S of length N.
Find the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there ar... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one. $0$
... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.You are given an array $a_1, a_2, \dots , a_n$ and two integers $m$ and $k$.
You can choose some subarray $a_l, a_{l+1}, \dots, a_{r-... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Let's define a split of $n$ as a nonincreasing sequence of positive integers, the sum of which is $n$.
For example, the following se... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Vasya should paint a fence in front of his own cottage. The fence is a sequence of n wooden boards arranged in a single row. Each boar... |
user: Generate an executable Python function generated from the given prompt. The function should take stdin as input and print the output. Simply call the function after the definition.Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.