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.Do you have in mind the good old TicTacToe?
Assuming that you get all the data in one array, you put a space around each value, `|` as a columns separator and multiple `-` as... |
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 sequence of a journey in London, UK. The sequence will contain bus **numbers** and TFL tube names as **strings** e.g.
```python
['Northern', 'Central', 243, 1... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your friend has invited you to a party, and tells you to meet them in the line to get in. The one problem is it's a masked party. Everyone in line is wearing a colored mask, i... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Pig Latin is an English language game where the goal is to hide the meaning of a word from people not aware of the rules.
So, the goal of this kata is to wite 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.Your retro heavy metal band, VÄxën, originally started as kind of a joke, just because why would anyone want to use the crappy foosball table in your startup's game room when ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.**Introduction**
Little Petya very much likes sequences. However, recently he received a sequence as a gift from his mother.
Petya didn't like it at all! He decided to make ... |
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 generate the Fibonacci sequence to `n` places, with each alternating value as `"skip"`. For example:
`"1 skip 2 skip 5 skip 13 skip 34"`
Return the result as... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example:
```
'abba' & 'baab' == true
'abba' & 'bbaa' == true
'abba... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You need to swap the head and the tail of the specified array:
the head (the first half) of array moves to the end, the tail (the second half) moves to the start.
The middle... |
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 square `matrix`, your task is to reverse the order of elements on both of its longest diagonals.
The longest diagonals of a square matrix are defined as follo... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement function which will return sum of roots of a quadratic equation rounded to 2 decimal places, if there are any possible roots, else return **None/null/nil/nothing**. ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Story
There are four warriors, they need to go through a dark tunnel. Tunnel is very narrow, every time only can let two warriors through, and there are lot of dangerous 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 will be given two positive integers `a` and `b` and your task will be to apply the following operations:
```
i) If a = 0 or b = 0, return [a,b]. Otherwise, ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Some languages like Chinese, Japanese, and Thai do not have spaces between words. However, most natural languages processing tasks like part-of-speech tagging require texts th... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task
Imagine `n` horizontal lines and `m` vertical lines.
Some of these lines intersect, creating rectangles.
How many rectangles are there?
# Examples
For `n=2, m=2,` t... |
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 fruit which a farmer has harvested, your job is to see if you should buy or sell.
You will be given 3 pairs of fruit. Your task is to trade your harvested... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Maya writes weekly articles to a well known magazine, but she is missing one word each time she is about to send the article to the editor. The article is not complete without... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task
Call two arms equally strong if the heaviest weights they each are able to lift are equal.
Call two people equally strong if their strongest arms are equally strong ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.One of the first algorithm used for approximating the integer square root of a positive integer `n` is known as "Hero's method",
named after the first-century Greek mathemati... |
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 first step to understanding FizzBuzz.
Your inputs:
a positive integer, n, greater than or equal to one.
n is provided, you have NO CONTROL over its value.
Your... |
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 characters, I want the function `findMiddle()`/`find_middle()` to return the middle number in the product of each digit in the string.
Example: 's7d8jd9' ->... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The most basic encryption method is to map a char to another char by a certain math rule.
Because every char has an ASCII value, we can manipulate this value with a simple mat... |
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 disambiguate two given names: the original with another
Let's start simple, and just work with plain ascii strings.
The function ```could_be``` is given... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.The Padovan sequence is the sequence of integers `P(n)` defined by the initial values
`P(0)=P(1)=P(2)=1`
and the recurrence relation
`P(n)=P(n-2)+P(n-3)`
The first few val... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Problem
Determine whether a positive integer number is **colorful** or not.
`263` is a colorful number because `[2, 6, 3, 2*6, 6*3, 2*6*3]` are all different; whereas `23... |
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 length of string and two thumbtacks. On thumbtack goes into the focus point *F₀* with coordinates *x₀* and *y₀*, and the other does into point *F₁* with points... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Speedcubing is the hobby involving solving a variety of twisty puzzles, the most famous being the 3x3x3 puzzle or Rubik's Cube, as quickly as possible.
In the majority of Spe... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Have a look at the following numbers.
```
n | score
---+-------
1 | 50
2 | 150
3 | 300
4 | 500
5 | 750
```
Can you find a pattern in it? If so, then write a funct... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There are some perfect squares with a particular property.
For example the number ```n = 256``` is a perfect square, its square root is ```16```. If we change the position of ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A little weird green frog speaks in a very strange variation of English: it reverses sentence, omitting all puntuation marks `, ; ( ) - ` except the final exclamation, questi... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Take a sentence (string) and reverse each word in the sentence. Do not reverse the order of the words, just the letters in each word.
If there is punctuation, it should be in... |
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 list of numbers, determine whether the sum of its elements is odd or even.
Give your answer as a string matching `"odd"` or `"even"`.
If the input array is e... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isog... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.#It's show time!
Archers have gathered from all around the world to participate in the Arrow Function Faire. But the faire will only start if there are archers signed and if t... |
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 the `length` and `width` of a 4-sided polygon. The polygon can either be a rectangle or a square.
If it is a square, return its area. If it is a rectangle, retu... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Fast & Furious Driving School's (F&F) charges for lessons are as below:
Time
Cost
Up to 1st hour
$30
Every subsequent half hour**
$10
** Subsequent charges are calcu... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There exist two zeroes: +0 (or just 0) and -0.
Write a function that returns `true` if the input number is -0 and `false` otherwise (`True` and `False` for Python).
In JavaS... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A generalization of Bézier surfaces, called the S-patch, uses an interesting scheme for indexing its control points.
In the case of an n-sided surface of degree d, each index... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Given a long number, return all the possible sum of two digits of it.
For example, `12345`: all possible sum of two digits from that number are:
[ 1 + 2, 1 + 3, 1 + 4, 1... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every Friday and Saturday night, farmer counts amount of sheep returned back to his farm (sheep returned on Friday stay and don't leave for a weekend).
Sheep return in groups... |
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 (arr) as an argument complete the function `countSmileys` that should return the total number of smiling faces.
Rules for a smiling face:
- Each smiley face ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.It's the fourth quater of the Super Bowl and your team is down by 4 points. You're 10 yards away from the endzone, if your team doesn't score a touchdown in the next four play... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.A friend of mine told me privately: "I don't like palindromes". "why not?" - I replied. "Because when I want to do some programming challenges, I encounter 2 or 3 ones first r... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Alice and Bob have participated to a Rock Off with their bands. A jury of true metalheads rates the two challenges, awarding points to the bands on a scale from 1 to 50 for th... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Late last night in the Tanner household, ALF was repairing his spaceship so he might get back to Melmac. Unfortunately for him, he forgot to put on the parking brake, and the ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Let's assume we need "clean" strings. Clean means a string should only contain letters `a-z`, `A-Z` and spaces. We assume that there are no double spaces or line breaks.
Writ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We define the "unfairness" of a list/array as the *minimal* difference between max(x1,x2,...xk) and min(x1,x2,...xk), for all possible combinations of k elements you can take ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task
In this kata you'll be given a string of English digits "collapsed" together, like this:
`zeronineoneoneeighttwoseventhreesixfourtwofive`
Your task is to split the s... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Little Petya often visits his grandmother in the countryside. The grandmother has a large vertical garden, which can be represented as a set of `n` rectangles of varying heigh... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task
Given two integers `a` and `b`, return the sum of the numerator and the denominator of the reduced fraction `a/b`.
# Example
For `a = 2, b = 4`, the result should be ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a function `generatePairs` that accepts an integer argument `n` and generates an array containing the pairs of integers `[a, b]` that satisfy the following conditions:
`... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Right in the Center
_This is inspired by one of Nick Parlante's exercises on the [CodingBat](https://codingbat.com/java) online code practice tool._
Given a sequence of ch... |
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 make a function that converts between `camelCase`, `snake_case`, and `kebab-case`.
You must write a function that changes to a given case. It must be a... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Story
John runs a shop, bought some goods, and then sells them. He used a special accounting method, like this:
```
[[60,20],[60,-20]]
```
Each sub array records the commo... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## The Story
Green Lantern's long hours of study and practice with his ring have really paid off -- his skills, focus, and control have improved so much that now he can even u... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We have two consecutive integers k1 and k2, k2 = k1 + 1
We need to calculate the lowest integer `n`, such that:
the values nk1 and nk2 have the same digits but in different o... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a function that takes a list comprised of other lists of integers and returns the sum of all numbers that appear in two or more lists in the input list. Now that might ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Most football fans love it for the goals and excitement. Well, this Kata doesn't.
You are to handle the referee's little notebook and count the players who were sent off for f... |
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 ___find the next higher number (int) with same '1'- Bits___.
I.e. as much `1` bits as before and output next higher than input. Input is always an int in betw... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Return an output string that translates an input string `s`/`$s` by replacing each character in `s`/`$s` with a number representing the number of times that character occurs i... |
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 sequence of 0s and 1s, determine if it is a prefix of Thue-Morse sequence.
The infinite Thue-Morse sequence is obtained by first taking a sequence containing... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Imagine you start on the 5th floor of a building, then travel down to the 2nd floor, then back up to the 8th floor. You have travelled a total of 3 + 6 = 9 floors of distance.... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In geometry, a cube is a three-dimensional solid object bounded by six square faces, facets or sides, with three meeting at each vertex.The cube is the only regular hexahedron... |
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 if a string contains consecutive letters as they appear in the English alphabet and if each letter occurs only once.
```Haskell
Rules are: (1) th... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In computing, there are two primary byte order formats: big-endian and little-endian. Big-endian is used primarily for networking (e.g., IP addresses are transmitted in big-en... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Section numbers are strings of dot-separated integers. The highest level sections (chapters) are numbered 1, 2, 3, etc. Second level sections are numbered 1.1, 1.2, 1.3, 2.1, ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Palindrome strings
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. This includes capital letters, punctuat... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Linear Kingdom has exactly one tram line. It has `n` stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passen... |
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 accepts two parameters (a and b) and says whether a is smaller than, bigger than, or equal to b.
Here is an example code:
var noIfsNoButs = function (a,... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Description
Lets imagine a yoga classroom as a Square 2D Array of Integers ```classroom```, with each integer representing a person, and the value representing their skill le... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution..task {
background: #fff;
color: #333;
padding: 25px;
box-sizing: border-box;
font-family: Comfortaa, sans-serif !important;
position: relative;
}
.task code, .tas... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Background:
You're working in a number zoo, and it seems that one of the numbers has gone missing!
Zoo workers have no idea what number is missing, and are too incompetent... |
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 integer `9457`.
We distribute its digits in two buckets having the following possible distributions (we put the generated numbers as strings and we add the corre... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.## Task
Complete function `splitOddAndEven`, accept a number `n`(n>0), return an array that contains the continuous parts of odd or even digits.
Please don't worry about dig... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Karan's company makes software that provides different features based on the version of operating system of the user.
For finding which version is more recent, Karan uses the... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.We have an array with string digits that occurrs more than once, for example, ```arr = ['1', '2', '2', '2', '3', '3']```. How many different string numbers can be generated ta... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Welcome young Jedi! In this Kata you must create a function that takes an amount of US currency in `cents`, and returns a dictionary/hash which shows the least amount of coins... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Consider the prime number `23`. If we sum the square of its digits we get:
`2^2 + 3^2 = 13`, then for `13: 1^2 + 3^2 = 10`, and finally for `10: 1^2 + 0^2 = 1`.
Similarly, i... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Every number may be factored in prime factors.
For example, the number 18 may be factored by its prime factors ``` 2 ``` and ```3```
```
18 = 2 . 3 . 3 = 2 . 3²
```
The sum o... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Implement a class/function, which should parse time expressed as `HH:MM:SS`, or `null/nil/None` otherwise.
Any extra characters, or minutes/seconds higher than 59 make the in... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Welcome
This kata is inspired by This Kata
We have a string s
We have a number n
Here is a function that takes your string, concatenates the even-indexed chars to the fro... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.In the previous Kata we discussed the OR case.
We will now discuss the AND case, where rather than calculating the probablility for either of two (or more) possible results, ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.There's a **"3 for 2"** (or **"2+1"** if you like) offer on mangoes. For a given quantity and price (per mango), calculate the total cost of the mangoes.
### Examples
```pyth... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your task it to return ```true``` if the fractional part (rounded to 1 digit) of the result (```a``` / ```b```) exists, more than ```0``` and is multiple of ```n```.
Otherwise... |
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 integers, sum consecutive even numbers and consecutive odd numbers. Repeat the process while it can be done and return the length of the final array.... |
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 series of characters that read the same forwards as backwards such as "hannah", "racecar" and "lol".
For this Kata you need to write a function that takes a... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Write a function
```python
vowel_2_index```
that takes in a string and replaces all the vowels [a,e,i,o,u] with their respective positions within that string.
E.g:
```py... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You have managed to intercept an important message and you are trying to read it.
You realise that the message has been encoded and can be decoded by switching each letter wi... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Jump is a simple one-player game:
You are initially at the first cell of an array of cells containing non-negative integers;
At each step you can jump ahead in the array as ... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Your task is to calculate logical value of boolean array. Test arrays are one-dimensional and their size is in the range 1-50.
Links referring to logical operations: [AND](ht... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You need to write a function, that returns the first non-repeated character in the given string.
For example for string `"test"` function should return `'e'`.
For string `"... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.Similarly to the [previous kata](https://www.codewars.com/kata/string-subpattern-recognition-i/), you will need to return a boolean value if the base string can be expressed a... |
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 sum for the range `0 ... m` for all powers from `0 ... n.
# Example
For `m = 2, n = 3`, the result should be `20`
`0^0+1^0+2^0 + 0^1+1^1+... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For this problem you must create a program that says who ate the last cookie. If the input is a string then "Zach" ate the cookie. If the input is a float or an int then "Moni... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.For this kata, you are given three points ```(x1,y1,z1)```, ```(x2,y2,z2)```, and ```(x3,y3,z3)``` that lie on a straight line in 3-dimensional space.
You have to figure out w... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.# Task
Find the integer from `a` to `b` (included) with the greatest number of divisors. For example:
```
divNum(15, 30) ==> 24
divNum(1, 2) ==> 2
divNum(0, 0) ==>... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but **exactly** 4 digits or exactly 6 digits.
If the function is passed a valid PIN string, r... |
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 very simple. Given an input string s, case\_sensitive(s), check whether all letters are lowercase or not. Return True/False and a list of all the entries that are... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.You throw a ball vertically upwards with an initial speed `v (in km per hour)`. The height `h` of the ball at each time `t`
is given by `h = v*t - 0.5*g*t*t` where `g` is Eart... |
user: Generate an executable Python function generated from the given prompt. Return the function body without invoking it at the final solution.An abundant number or excessive number is a number for which the sum of its proper divisors is greater than the number itself.
The integer 12 is the first abundant number. I... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.