id stringlengths 11 14 | content stringlengths 424 1.17M |
|---|---|
apps_data_2900 | Given a string, return a new string that has transformed based on the input:
* Change case of every character, ie. lower case to upper case, upper case to lower case.
* Reverse the order of words from the input.
**Note:** You will have to handle multiple spaces, and leading/trailing spaces.
For example:
```
"Exampl... |
apps_data_2901 | Following from the previous kata and taking into account how cool psionic powers are compare to the Vance spell system (really, the idea of slots to dumb down the game sucks, not to mention that D&D became a smash hit among geeks, so...), your task in this kata is to create a function that returns how many power points... |
apps_data_2902 | 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 table with a column: `res`.
~~~
def opposite(number):
return -number
def opposite(number):
return number * -1
def opposite(number):
retu... |
apps_data_2903 | 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 JS, `math.pi` in Python or `Math::PI` in Ruby) and round down the volume to an Interger.
If you complete this kata and there are no issues, ple... |
apps_data_2904 | 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. Using `re` and `string` is not allowed.
Examples:
```python
filter_words('HELLO CAN YOU HEAR ME') #=> Hello can you hear me
filter_words('now THI... |
apps_data_2905 | 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 consonant, return the first 3 letters.
If the 3rd letter is a vowel, return the first 4 letters.
If the string is less than 4 characters, retur... |
apps_data_2906 | 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 than others.
Write a function generateNumber() that takes two arguments, an array of the current squad numbers (squad) and the new player's des... |
apps_data_2907 | 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 combinations (or distributions) (with no empty boxes) of a certain number of balls, but now, **with different amount of boxes.** In the previous kata... |
apps_data_2908 | ###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 will flatten a given dictionary.
###Info
Python dictionaries are a convenient data type to store and process configurations. They allow you to s... |
apps_data_2909 | 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 consists of seven notes, or scale degrees, in order (with tonic listed twice for demonstrative purposes):
Tonic, the base of the scale and the note ... |
apps_data_2910 | *** 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 are, return true. Else, return false.
You can assume all values in the array are numbers.
Do not use loops. Do not modify input array.
Looking... |
apps_data_2911 | 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 omitted.
### Examples:
```python
count_vowels("abcdefg") => 2
count_vowels("aAbcdeEfg") => 4
count_vowels(12) => None
```
def count_vowels(s ... |
apps_data_2912 | 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 of ```integer```, it should be included as well. There will only ever be positive integers passed into the function, not consisting of 0. The limi... |
apps_data_2913 | 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 characters: ■ □
For Ruby, Crystal and PHP: whitespace and o
e.g.:
■□□□■
■□■ ... |
apps_data_2914 | 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 are present in list `b`.
```python
array_diff([1,2],[1]) == [2]
```
If a value is present in `b`, all of its occurrences must be removed from th... |
apps_data_2915 | # 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 meeting schedule. When he's at a meeting and somebody texts him, he wants to send an automatic message informing that he's currently unavailable and th... |
apps_data_2916 | 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 events.
The probability of an OR event is calculated by the following rule:
`P(A || B) = P(A) + P(B) - P(A && B)`
The probability of event A ... |
apps_data_2917 | # 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 minimum year number which is strictly larger than the given one and has only distinct digits.
# Input/Output
- `[input]` integer `year`
`1... |
apps_data_2918 | 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 secondhand one.
He thinks he can save $1000 each month but the prices of his old
car and of the new one decrease of 1.5 percent per month.
Furtherm... |
apps_data_2919 | # 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 12 13
n o p q r s t u v w x y z
14 15 16 17 18 19 20 21 22 23 24 25 26
```
Instead of letters in encrypted word we write the corre... |
apps_data_2920 | ##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 "" i.e. empty string.*
##Pattern:
(n)
(n)(n-1)
(n)(n-1)(n-2)
................
.................
(n)(n-1)(n-2)....4
... |
apps_data_2921 | Just another day in the world of Minecraft, Steve is working on his new project -- building a beacon pyramid in front of his house.

Steve has already obtained the beacon (the glass wrapped blue thingy on the top), he just needs to ... |
apps_data_2922 | 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 and collect all of the dog cr@p - represented by '@'.
You will also be given the number of bags you have access to (bags), and the capactity of ... |
apps_data_2923 | 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, but those extra commas have to go!
Write a function called ```dadFilter``` that takes a string as argument and returns a string with the extraneou... |
apps_data_2924 | 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, 5, 10, 20
Factors of 27: 1, 3, 9, 27
Greatest shared factor: 1
20 and 27 are coprime```
An example of two numbers that are not coprime:
```
12 a... |
apps_data_2925 | 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
multiply(3)==15
multiply(10)==250
multiply(200)==25000
multiply(0)==0
multiply(-3)==-15
```
def multiply(n):
return n*5**len(str(abs(n)))
def mu... |
apps_data_2926 | ## 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: {"I", "like", "big", "butts", "and", "I", "cannot", "lie!"}
Output: {"!", "eilt", "onn", "acIdn", "ast", "t", "ubgibe", "kilI"}
```
Good luck!
d... |
apps_data_2927 | 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 brains. Luckily, you're a crack shot, and have your trusty rifle to hand.
The zombies start at `range` metres, and move at 0.5 metres per second... |
apps_data_2928 | # 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 too high and the war began.
# Task
Write a function that accepts `fight` string consists of only small letters and return who wins the fight. ... |
apps_data_2929 | #### 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` will contain all the numbers that, when squared, yield a number which is a factor of `n`,
while the `cb` part will contain all the numbers that, w... |
apps_data_2930 | # 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:racket
~~~
summation(2) -> 3
1 + 2
summation(8) -> 36
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8
~~~
```
```if:racket
~~~racket
(summation 2) ; 3 (+ 1 2)
(summat... |
apps_data_2931 | Consider having a cow that gives a child every year from her fourth year of life on and all her subsequent children do the same.
After n years how many cows will you have?
Return null if n is not an integer.
Note: Assume all the cows are alive after n years.
def count_cows(n):
if not isinstance(n, int):
... |
apps_data_2932 | 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 psychological meanings for us.
You are given a 2D array, composed of a colour and its 'common' association in each array element. The function you will wri... |
apps_data_2933 | 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 example if the item is 40 and the divisor is 3 you would have to add 1 since 40 minus the closest multiple of 3 which is 39 is 1. So the 40 in the lis... |
apps_data_2934 | 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 `"aeiou"`.
We shall assign the following values: `a = 1, b = 2, c = 3, .... z = 26`.
For example, for the word "zodiacs", let's cross out the... |
apps_data_2935 | Implement the function which should return `true` if given object is a vowel (meaning `a, e, i, o, u`), and `false` otherwise.
def is_vowel(s):
return s.lower() in set("aeiou")
import re
def is_vowel(s):
regex = r'^[aeiou]{1}$'
return bool(re.match(regex, re.escape(s), re.IGNORECASE))
import re
def is_... |
apps_data_2936 | 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" in the school. The principal asks the first student to go to every locker and open it. Then he has the second student go to every second locker an... |
apps_data_2937 | 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 = 1
b = 4
--> [1, 2, 3, 4]
```
def between(a,b):
return list(range(a,b+1))
def between(a,b):
# good luck
return list((x for x in r... |
apps_data_2938 | ###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 or a Negative Integer then it should return "" i.e. empty string.
* All the lines in the pattern have same length i.e equal to the number of char... |
apps_data_2939 | 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³`.
All the numbers `a`, `b`, `c` and `d` should be different and greater than `0`.
E.g. 1729 = 9³+10³ = 1³+12³.
```python
has_two_cube_sums(1729); /... |
apps_data_2940 | 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 occur only once.
For example, `repeats([4,5,7,5,4,8]) = 15` because only the numbers `7` and `8` occur once, and their sum is `15`.
More examples ... |
apps_data_2941 | This kata is all about adding numbers.
You will create a function named add. It will return the sum of all the arguments. Sounds easy, doesn't it?
Well Here's the Twist. The inputs will gradually decrease with their index as parameter to the function.
```python
add(3,4,6) #returns (3/1)+(4/2)+(6/3)=7
```
Remember... |
apps_data_2942 | Have you heard about the myth that [if you fold a paper enough times, you can reach the moon with it](http://scienceblogs.com/startswithabang/2009/08/31/paper-folding-to-the-moon/)? Sure you have, but exactly how many? Maybe it's time to write a program to figure it out.
You know that a piece of paper has a thickness ... |
apps_data_2943 | __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 possibly the last, is completely filled, and all nodes in the last level are as far left as possible."_
The Wikipedia page referenced above also... |
apps_data_2944 | ## 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 by an integer number next to or above each element of the periodic table (as highlighted in the image above).
As we move from left to right, st... |
apps_data_2945 | 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`.
Here is his banker plan:
- deposit `f0` at beginning of year 1
- his bank account has an interest rate of `p` percent per year, constant over t... |
apps_data_2946 | **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 written backwards.
Create a function called `reverseSentence()/reverse_sentence()` that accepts a string argument. The function returns a string of ... |
apps_data_2947 | # 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`, the output should be `21`.
For `n = 19, m = 3`, the output should be `18`.
For `n = 50, m = 100`, the output should be `50`.
# Input/Output... |
apps_data_2948 | 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 than ```k```;
all elements that are less than ```k``` remain in the same order with respect to each other;
all elements that are not less than ```... |
apps_data_2949 | *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 array as parameter that contains 1 or more integers and a number `n`.
Here is a little visualization of the process:
* Step 1: Split the array in t... |
apps_data_2950 | 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 progression, the differences between the elements must be the same.
```
[1, 2, 3, 5, 7, 9] ==> 5
// [1, 2, 3], [1, 3, 5], [1, 5, 9], [3, 5, 7], and... |
apps_data_2951 | 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 being of pure gold. In the worst case, how many iterations are actually needed to find the odd one out on a two plates scale*.
I am asking you t... |
apps_data_2952 | 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 the forest.
The terrain is dangerous and surveyors have determined that there are three possible safe *dropzones*, an array of three simple arrays... |
apps_data_2953 | 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 already seen it...
But will your code be **performant enough**?
___
## Examples:
```
input = "Hello, World!"
result = "1112111121311... |
apps_data_2954 | # 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 to about 10 days, before it was made obsolete by the [transcontinental telegraph](https://en.wikipedia.org/wiki/First_transcontinental_telegraph)... |
apps_data_2955 | 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 ) think of odd numbers as `n = 2m + 1`.
Now, some odd numbers can be more odd than others: when for some `n`, `m` is more odd than for another's. Re... |
apps_data_2956 | *Translations appreciated*
## Background information
The Hamming Code is used to correct errors, so-called bit flips, in data transmissions. Later in the description follows a detailed explanation of how it works.
In this Kata we will implement the Hamming Code with bit length 3, this has some advantages and disadvan... |
apps_data_2957 | Write a function `getDrinkByProfession`/`get_drink_by_profession()` that receives as input parameter a string, and produces outputs according to the following table:
Input
Output
"Jabroni"
"Patron Tequila"
"School Counselor"
"Anything with Alcohol"
"Programmer"
"Hipster Craft Beer"
"Bike Gang Member"
"Mo... |
apps_data_2958 | # 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 subcuboids have the same length, width, and height, but they are at different positions within the cuboid, they are distinct. Find the total number... |
apps_data_2959 | 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 to know the minimum number of coins for this operation (i'm sure you don't want to return 100 pennys instead of 1$ coin).
So, find an optimal numb... |
apps_data_2960 | 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](https://en.wikipedia.org/wiki/Least_common_multiple) of each couple of number compared to their simple product.
For example, if you are given:
... |
apps_data_2961 | 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 not in order you should order them, but if a value repeats, then you must return a sequence with only one item, and the value of that item must be ... |
apps_data_2962 | 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 `divisor`.
## Example
```python
divisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]
```
def divisible_by(numbers, divisor):
return [x for x ... |
apps_data_2963 | Given a string, swap the case for each of the letters.
e.g. CodEwArs --> cODeWaRS
### Examples
```
"" -> ""
"CodeWars" -> "cODEwARS"
"abc" -> "ABC"
"ABC" -> "abc"
"123235" -> "123235"
```
def swap(string_):
return string_.swapcase()
swap = str.swapcase
swap = lambda s: ... |
apps_data_2964 | 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.
For example, when an array is passed like `[19, 5, 42, 2, 77]`, the output should be `7`.
`[10, 343445353, 3453445, 3453545353453]` should return ... |
apps_data_2965 | 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 array of [[4, -3, 1, -10], [2, 1, 3, 0], [-1, 2, -5, 17]] and the result should be returned as an array like [1, 4, -2] (i.e. [x, y, z]).
Note: I... |
apps_data_2966 | 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 result of the calculation.
Example:
"Panda has 48 apples and loses 4" returns 44
"Jerry has 34 apples and gains 6" returns 40
"loses" and "g... |
apps_data_2967 | 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 contain upper or lower case characters and start with any amount of zeros.
Returns the binary representation (without leading zeros) of the numerical... |
apps_data_2968 | 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 even, return the middle 2 characters.
#Examples:
~~~if-not:bf
```
Kata.getMiddle("test") should return "es"
Kata.getMiddle("testing") should retur... |
apps_data_2969 | 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 very strong beliefs against women in academia sent some `agents` to find Bassi and end her career.
Help her escape by telling her the safest pl... |
apps_data_2970 | 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 x 3 x 3 # (we do not consider the product 18 x 1), (3 ways)
```
See this example a bit more complicated,
```python
60 = 2 x 30 = 3 x 20 = 4 x ... |
apps_data_2971 | 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_from_the_side(characters):
watch_pyramid_from_above(characters):
count_visible_characters_of_the_pyramid(characters):
count_all_characters_of_th... |
apps_data_2972 | 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
multiple_split('Hi, how are you?', [' ']) => ['Hi,', 'how', 'are', 'you?']
multiple_split('1+2-3', ['+', '-']) => ['1', '2', '3']
```
List of del... |
apps_data_2973 | # 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.
iterations (1-based) replace each pair of consecutive elements with their sum;
On the 2nd, 4th, 6th, etc.
iterations replace each pair of consecut... |
apps_data_2974 | 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) is: `200.00 + 15% = 230.00`
Thus, if your function receives `230.00` as input, it should return `200.00`
**Notes:**
* VAT is *always* `15%` f... |
apps_data_2975 | 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 dubstep remixes from them.
Let's assume that a song consists of some number of words (that don't contain WUB). To make the dubstep remix of this so... |
apps_data_2976 | 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-Eeee-Zzzzz-Tttttt-Yyyyyyy"
accum("cwAt") -> "C-Ww-Aaa-Tttt"
```
The parameter of accum is a string which includes only letters from `a..z` and `A..... |
apps_data_2977 | 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) Is ds divisible by pfs
12 2 + 2 + 3 = 7 1 + 2 + 3 + 4 + 6 + 12 = 28 28 / 7 = 4, Yes
63 3 + 3 + 7... |
apps_data_2978 | 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 presented bellow:
```[(1), (2), (3), [[(4)], 5]]```
(1) - Total amount of received integers.
(2) - Total amount of different values the array h... |
apps_data_2979 | 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 always valid and may look like
"1 year old" or "5 years old", etc.. The first char is number only.
def get_age(age):
return int(age[0])
imp... |
apps_data_2980 | 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 certain number of divisors.
For this purpose we have to create the function
```find_min_num() or findMinNum() or similar in the other languages```... |
apps_data_2981 | 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) --> [1]`
`last_digits(1234,2) --> [3,4]`
`last_digits(637547,6) --> [6,3,7,5,4,7]`
Special cases:
If `d` > the number of digits, just return th... |
apps_data_2982 | 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 has to return the corresponding pascal triangle up to that depth.
The triangle should be returned as a nested array.
for example:
```python
pasca... |
apps_data_2983 | A `bouncy number` is a positive integer whose digits neither increase nor decrease. For example, 1235 is an increasing number, 5321 is a decreasing number, and 2351 is a bouncy number. By definition, all numbers under 100 are non-bouncy, and 101 is the first bouncy number.
Determining if a number is bouncy is easy, bu... |
apps_data_2984 | 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 will it take for the whole list to become infected?
```
[0,1,1,0] ==> [0,0,0,0]
All infected in 1 turn.
[1,1,0,1,1] --> [1,0,0,0,1] --> [0,0,... |
apps_data_2985 | ## **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 enters this rectangle through a hole at the position `(0, 0)` and moves at an angle of 45 degrees relative to the axes. Each time it hits one of th... |
apps_data_2986 | 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 each other. Each segment is characterized by two integers li and ri — coordinates of the left and of the right endpoints.
Consider all integer ... |
apps_data_2987 | 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, -6) -> true
(-12, 2, -5) -> false
(45, 1, 6) -> false
(45, 5, 15) -> true
(4, 1, 4) -> true
(15, -5, 3) -> true
```
def is_... |
apps_data_2988 | 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 different "words" separated by spaces
```
1. More than one word? Reverse each word and combine first with second, third with fourth and so on...
(... |
apps_data_2989 | 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 binary representation, while the even numbers will fight using their `0` bits. If present in the list, number `0` will be neutral, hence not figh... |
apps_data_2990 | 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, and two without (represented with goats).
After choosing a door, the host would open one of the other two doors which didn't include a prize, ... |
apps_data_2991 | # 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 marbles that you can pull out of nowhere.
You ask your audience to repeatedly remove a pair of marbles from your hat and, for each pair removed... |
apps_data_2992 | 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' --> 'bca'
'aabacbaa' --> 'bbabcabb'
def switcheroo(s):
return s.translate(str.maketrans('ab','ba'))
def switcheroo(string):
return strin... |
apps_data_2993 | ## Nova polynomial add
This kata is from a series on polynomial handling. ( [#1](http://www.codewars.com/kata/nova-polynomial-1-add-1) [#2](http://www.codewars.com/kata/570eb07e127ad107270005fe) [#3](http://www.codewars.com/kata/5714041e8807940ff3001140 ) [#4](http://www.codewars.com/kata/571a2e2df24bdfd4e20001f5) )
... |
apps_data_2994 | 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 negative, ignore its sign and treat it as a positive value
- If ```nth``` is not positive, return `-1`
- Keep in mind that `42 = 00042`. This means... |
apps_data_2995 | ## 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 multiples
## Examples
def sum_mul(n, m):
if m>0 and n>0:
return sum(range(n, m, n))
else:
return 'INVALID'
def su... |
apps_data_2996 | 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 complete a function that take an array of events in arguments, according to this list you will return the number of coffee you need to stay awake... |
apps_data_2997 | 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 0 - 255. Any values that fall out of that range must be rounded to the closest valid value.
Note: Your answer should always be 6 characters long... |
apps_data_2998 | 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 should fill a shell untill it's holding the maximum number of electrons.
---
Rules:
- Maximum number of electrons in a shell is distribute... |
apps_data_2999 | ### 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 extended by using numbers to represent other letters, such as `5EAF00D`, or `DEC0DE5`.
Given a string, your task is to return the decimal sum of al... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.