id
stringlengths
11
14
content
stringlengths
424
1.17M
apps_data_3100
>When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said # Description: Given two array of integers(`arr1`,`arr2`). Your task is going to find a pair of numbers(an element in arr1, and another element in arr2), their difference...
apps_data_3101
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. Examples: Non-string inputs should be converted to strings. Return an array of arrays containing pairs of distinct indices that form palindro...
apps_data_3102
Johnny is a boy who likes to open and close lockers. He loves it so much that one day, when school was out, he snuck in just to play with the lockers. Each locker can either be open or closed. If a locker is closed when Johnny gets to it, he opens it, and vice versa. The lockers are numbered sequentially, starting at...
apps_data_3103
# Remove Duplicates You are to write a function called `unique` that takes an array of integers and returns the array with duplicates removed. It must return the values in the same order as first seen in the given array. Thus no sorting should be done, if 52 appears before 10 in the given array then it should also be ...
apps_data_3104
Santa puts all the presents into the huge sack. In order to let his reindeers rest a bit, he only takes as many reindeers with him as he is required to do. The others may take a nap. Two reindeers are always required for the sleigh and Santa himself. Additionally he needs 1 reindeer per 30 presents. As you know, Santa...
apps_data_3105
If you can't sleep, just count sheep!! ## Task: Given a non-negative integer, `3` for example, return a string with a murmur: `"1 sheep...2 sheep...3 sheep..."`. Input will always be valid, i.e. no negative integers. def count_sheep(n): return ''.join(f"{i} sheep..." for i in range(1,n+1)) def count_sheep(n): ...
apps_data_3106
You have a set of four (4) balls labeled with different numbers: ball_1 (1), ball_2 (2), ball_3 (3) and ball(4) and we have 3 equal boxes for distribute them. The possible combinations of the balls, without having empty boxes, are: ``` (1) (2) (3)(4) ______ ______ _______ ```...
apps_data_3107
Program the function distance(p1, p2) which returns the distance between the points p1 and p2 in n-dimensional space. p1 and p2 will be given as arrays. Your program should work for all lengths of arrays, and should return -1 if the arrays aren't of the same length or if both arrays are empty sets. If you don't know ...
apps_data_3108
Your goal is to return multiplication table for ```number``` that is always an integer from 1 to 10. For example, a multiplication table (string) for ```number == 5``` looks like below: ``` 1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25 6 * 5 = 30 7 * 5 = 35 8 * 5 = 40 9 * 5 = 45 10 * 5 = 50 ``` P. S. You can...
apps_data_3109
Background There is a message that is circulating via public media that claims a reader can easily read a message where the inner letters of each words is scrambled, as long as the first and last letters remain the same and the word contains all the letters. Another example shows that it is quite difficult to read the...
apps_data_3110
Each number should be formatted that it is rounded to two decimal places. You don't need to check whether the input is a valid number because only valid numbers are used in the tests. ``` Example: 5.5589 is rounded 5.56 3.3424 is rounded 3.34 ``` def two_decimal_places(n): return round(n, 2) def two_decim...
apps_data_3111
Format any integer provided into a string with "," (commas) in the correct places. **Example:** ``` csharp Kata.NumberFormat(100000); // return "100,000" Kata.NumberFormat(5678545); // return "5,678,545" Kata.NumberFormat(-420902); // return "-420,902" ``` ``` javascript numberFormat(100000); // return '100,000' numbe...
apps_data_3112
# Task You are given an array of integers `arr` that representing coordinates of obstacles situated on a straight line. Assume that you are jumping from the point with coordinate 0 to the right. You are allowed only to make jumps of the same length represented by some integer. Find the minimal length of the jump e...
apps_data_3113
There are some candies that need to be distributed to some children as fairly as possible (i.e. the variance of result needs to be as small as possible), but I don't know how to distribute them, so I need your help. Your assignment is to write a function with signature `distribute(m, n)` in which `m` represents how man...
apps_data_3114
A variation of determining leap years, assuming only integers are used and years can be negative and positive. Write a function which will return the days in the year and the year entered in a string. For example 2000, entered as an integer, will return as a string 2000 has 366 days There are a few assumptions we wi...
apps_data_3115
Given a square matrix (i.e. an array of subarrays), find the sum of values from the first value of the first array, the second value of the second array, the third value of the third array, and so on... ## Examples ``` array = [[1, 2], [3, 4]] diagonal sum: 1 + 4 = 5 ``` ``` array = [[5, 9,...
apps_data_3116
There are several (or no) spiders, butterflies, and dragonflies. In this kata, a spider has eight legs. A dragonfly or a butterfly has six legs. A __dragonfly__ has __two__ pairs of wings, while a __butterfly__ has __one__ pair of wings. __I am not sure whether they are biologically correct, but the values apply here...
apps_data_3117
The vowel substrings in the word `codewarriors` are `o,e,a,io`. The longest of these has a length of 2. Given a lowercase string that has alphabetic characters only (both vowels and consonants) and no spaces, return the length of the longest vowel substring. Vowels are any of `aeiou`. ```if:csharp Documentation: Kat...
apps_data_3118
###Lucky number Write a function to find if a number is lucky or not. If the sum of all digits is 0 or multiple of 9 then the number is lucky. `1892376 => 1+8+9+2+3+7+6 = 36`. 36 is divisble by 9, hence number is lucky. Function will return `true` for lucky numbers and `false` for others. def is_lucky(n): retu...
apps_data_3119
< PREVIOUS KATA NEXT KATA > ## Task: You have to write a function `pattern` which returns the following Pattern(See Examples) upto desired number of rows. * Note:`Returning` the pattern is not the same as `Printing` the pattern. ## Parameters: pattern( n , y ); ...
apps_data_3120
So you've found a meeting room - phew! You arrive there ready to present, and find that someone has taken one or more of the chairs!! You need to find some quick.... check all the other meeting rooms to see if all of the chairs are in use. Your meeting room can take up to 8 chairs. `need` will tell you how many have b...
apps_data_3121
In this Kata, you will be given an array of integers whose elements have both a negative and a positive value, except for one integer that is either only negative or only positive. Your task will be to find that integer. Examples: `[1, -1, 2, -2, 3] => 3` `3` has no matching negative appearance `[-3, 1, 2, 3, -1, ...
apps_data_3122
# Task Consider a `bishop`, a `knight` and a `rook` on an `n × m` chessboard. They are said to form a `triangle` if each piece attacks exactly one other piece and is attacked by exactly one piece. Calculate the number of ways to choose positions of the pieces to form a triangle. Note that the bishop attacks piec...
apps_data_3123
Write a function that returns the count of characters that have to be removed in order to get a string with no consecutive repeats. *Note:* This includes any characters ## Examples ```python 'abbbbc' => 'abc' # answer: 3 'abbcca' => 'abca' # answer: 2 'ab cca' => 'ab ca' # answer: 1 ``` from itertools ...
apps_data_3124
Write a method named `getExponent(n,p)` that returns the largest integer exponent `x` such that p^(x) evenly divides `n`. if `p<=1` the method should return `null`/`None` (throw an `ArgumentOutOfRange` exception in C#). def get_exponent(n, p): if p > 1: x = 0 while not n % p: x += 1 ...
apps_data_3125
In this Kata, you will be given a number `n` (`n > 0`) and your task will be to return the smallest square number `N` (`N > 0`) such that `n + N` is also a perfect square. If there is no answer, return `-1` (`nil` in Clojure, `Nothing` in Haskell, `None` in Rust). ```clojure solve 13 = 36 ; because 36 is the smalles...
apps_data_3126
# Task Given a string `s`, find out if its characters can be rearranged to form a palindrome. # Example For `s = "aabb"`, the output should be `true`. We can rearrange `"aabb"` to make `"abba"`, which is a palindrome. # Input/Output - `[input]` string `s` A string consisting of lowercase English letters....
apps_data_3127
You should write a function that takes a string and a positive integer `n`, splits the string into parts of length `n` and returns them in an array. It is ok for the last element to have less than `n` characters. If `n` is not a valid size (`> 0`) (or is absent), you should return an empty array. If `n` is greater th...
apps_data_3128
# Task A media access control address (MAC address) is a unique identifier assigned to network interfaces for communications on the physical network segment. The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly form is six groups of two hexadecimal digits (0 to 9 or A to F), separated by hy...
apps_data_3129
A trick I learned in elementary school to determine whether or not a number was divisible by three is to add all of the integers in the number together and to divide the resulting sum by three. If there is no remainder from dividing the sum by three, then the original number is divisible by three as well. Given a seri...
apps_data_3130
In this kata you need to build a function to return either `true/True` or `false/False` if a string can be seen as the repetition of a simpler/shorter subpattern or not. For example: ```cpp,java hasSubpattern("a") == false; //no repeated pattern hasSubpattern("aaaa") == true; //created repeating "a" hasSubpattern("ab...
apps_data_3131
# Task Let's call `product(x)` the product of x's digits. Given an array of integers a, calculate `product(x)` for each x in a, and return the number of distinct results you get. # Example For `a = [2, 8, 121, 42, 222, 23]`, the output should be `3`. Here are the products of the array's elements: ``` 2: product(2...
apps_data_3132
Write a function ```python alternate_sort(l) ``` that combines the elements of an array by sorting the elements ascending by their **absolute value** and outputs negative and non-negative integers alternatingly (starting with the negative value, if any). E.g. ```python alternate_sort([5, -42, 2, -3, -4, 8, -9,]) == [-...
apps_data_3133
### Vaccinations for children under 5 You have been put in charge of administrating vaccinations for children in your local area. Write a function that will generate a list of vaccines for each child presented for vaccination, based on the child's age and vaccination history, and the month of the year. #### The functio...
apps_data_3134
Given a string, determine if it's a valid identifier. ## Here is the syntax for valid identifiers: * Each identifier must have at least one character. * The first character must be picked from: alpha, underscore, or dollar sign. The first character cannot be a digit. * The rest of the characters (besides the first) ca...
apps_data_3135
Two moving objects A and B are moving accross the same orbit (those can be anything: two planets, two satellites, two spaceships,two flying saucers, or spiderman with batman if you prefer). If the two objects start to move from the same point and the orbit is circular, write a function that gives the time the two objec...
apps_data_3136
- Kids drink toddy. - Teens drink coke. - Young adults drink beer. - Adults drink whisky. Make a function that receive age, and return what they drink. **Rules:** - Children under 14 old. - Teens under 18 old. - Young under 21 old. - Adults have 21 or more. **Examples:** ```python people_with_age_drink(13) == "dri...
apps_data_3137
From this lesson, we learn about JS static object: ```Math```. It mainly helps us to carry out mathematical calculations. It has a lot of properties and methods. Some of the properties and methods we rarely used. So we only learn some common methods. The properties of the Math object are some constants, such as PI, on...
apps_data_3138
For every positive integer N, there exists a unique sequence starting with 1 and ending with N and such that every number in the sequence is either the double of the preceeding number or the double plus 1. For example, given N = 13, the sequence is [1, 3, 6, 13], because . . . : ``` 3 = 2*1 +1 6 = 2*3 13 = 2*6 +...
apps_data_3139
This kata is from check py.checkio.org You are given an array with positive numbers and a number N. You should find the N-th power of the element in the array with the index N. If N is outside of the array, then return -1. Don't forget that the first element has the index 0. Let's look at a few examples: * array = [...
apps_data_3140
Math geeks and computer nerds love to anthropomorphize numbers and assign emotions and personalities to them. Thus there is defined the concept of a "happy" number. A happy number is defined as an integer in which the following sequence ends with the number 1. * Start with the number itself. * Calculate the sum of the...
apps_data_3141
# Task John is an orchard worker. There are `n` piles of fruits waiting to be transported. Each pile of fruit has a corresponding weight. John's job is to combine the fruits into a pile and wait for the truck to take them away. Every time, John can combine any two piles(`may be adjacent piles, or not`), and the ener...
apps_data_3142
Write a function that removes every lone 9 that is inbetween 7s. ```python seven_ate9('79712312') => '7712312' seven_ate9('79797') => '777' ``` Input: String Output: String def seven_ate9(str_): while str_.find('797') != -1: str_ = str_.replace('797','77') return str_ import re def seven_ate9(str_): ...
apps_data_3143
# Hey You ! Sort these integers for me ... By name ... Do it now ! --- ## Input * Range is ```0```-```999``` * There may be duplicates * The array may be empty ## Example * Input: 1, 2, 3, 4 * Equivalent names: "one", "two", "three", "four" * Sorted by name: "four", "one", "three", "two" * Output: 4, 1, 3, 2...
apps_data_3144
Pair of gloves ============= Winter is coming, you must prepare your ski holidays. The objective of this kata is to determine the number of pair of gloves you can constitute from the gloves you have in your drawer. A pair of gloves is constituted of two gloves of the same color. You are given an array containing the...
apps_data_3145
Make a function that will return a greeting statement that uses an input; your program should return, `"Hello, how are you doing today?"`. SQL: return results in a column named ```greeting``` *[Make sure you type the exact thing I wrote or the program may not execute properly]* def greet(name): return "Hello, {...
apps_data_3146
Unicode Transformation Format – 8-bit As the name suggests UTF-8 was designed to encode data in a stream of bytes. It works by splitting the bits up in multiples of eight. This is achieved by inserting headers to mark in how many bytes the bits were split. If the bits need to be split in two, the header `110` is added...
apps_data_3147
*This is the advanced version of the [Total Primes](https://www.codewars.com/kata/total-primes/) kata.* --- The number `23` is the smallest prime that can be "cut" into **multiple** primes: `2, 3`. Another such prime is `6173`, which can be cut into `61, 73` or `617, 3` or `61, 7, 3` (all primes). A third one is `557...
apps_data_3148
# Story John found a path to a treasure, and while searching for its precise location he wrote a list of directions using symbols `"^"`, `"v"`, `"<"`, `">"` which mean `north`, `east`, `west`, and `east` accordingly. On his way John had to try many different paths, sometimes walking in circles, and even missing the tr...
apps_data_3149
The sports centre needs repair. Vandals have been kicking balls so hard into the roof that some of the tiles have started sticking up. The roof is represented by r. As a quick fix, the committee have decided to place another old roof over the top, if they can find one that fits. This is your job. A 'new' roof (f) wil...
apps_data_3150
## Task Implement a function which finds the numbers less than `2`, and the indices of numbers greater than `1` in the given sequence, and returns them as a pair of sequences. Return a nested array or a tuple depending on the language: * The first sequence being only the `1`s and `0`s from the original sequence. *...
apps_data_3151
Your task is to return the number of visible dots on a die after it has been rolled(that means the total count of dots that would not be touching the table when rolled) 6, 8, 10, 12, 20 sided dice are the possible inputs for "numOfSides" topNum is equal to the number that is on top, or the number that was rolled. f...
apps_data_3152
# Task: This kata asks you to make a custom esolang interpreter for the language [MiniBitMove](https://esolangs.org/wiki/MiniBitMove). MiniBitMove has only two commands and operates on a array of bits. It works like this: - `1`: Flip the bit at the current cell - `0`: Move selector by 1 It takes two inputs, the progr...
apps_data_3153
Let's imagine we have a popular online RPG. A player begins with a score of 0 in class E5. A1 is the highest level a player can achieve. Now let's say the players wants to rank up to class E4. To do so the player needs to achieve at least 100 points to enter the qualifying stage. Write a script that will check to see...
apps_data_3154
An array of size N x M represents pixels of an image. Each cell of this array contains an array of size 3 with the pixel's color information: `[R,G,B]` Convert the color image, into an *average* greyscale image. The `[R,G,B]` array contains integers between 0 and 255 for each color. To transform a color pixel into...
apps_data_3155
Mr. Square is going on a holiday. He wants to bring 2 of his favorite squares with him, so he put them in his rectangle suitcase. Write a function that, given the size of the squares and the suitcase, return whether the squares can fit inside the suitcase. ```Python fit_in(a,b,m,n) a,b are the sizes of the 2 squares m...
apps_data_3156
The integer ```64``` is the first integer that has all of its digits even and furthermore, is a perfect square. The second one is ```400``` and the third one ```484```. Give the numbers of this sequence that are in the range ```[a,b] ```(both values inclusive) Examples: ``` python even_digit_squares(100, 1000) == [4...
apps_data_3157
## Number of people in the bus There is a bus moving in the city, and it takes and drop some people in each bus stop. You are provided with a list (or array) of integer arrays (or tuples). Each integer array has two items which represent number of people get into bus (The first item) and number of people get off the b...
apps_data_3158
A very passive-aggressive co-worker of yours was just fired. While he was gathering his things, he quickly inserted a bug into your system which renamed everything to what looks like jibberish. He left two notes on his desk, one reads: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" while the other reads: "Uif u...
apps_data_3159
An array is defined to be `odd-heavy` if it contains at least one odd element and every element whose value is `odd` is greater than every even-valued element. eg. ``` Array [11,4,9,2,8] is odd-heavy because:- its odd elements [11,9] are greater than all the even elements [4,2,8] Array [11,4,9,2,3,10] is not odd-h...
apps_data_3160
Debug the functions Should be easy, begin by looking at the code. Debug the code and the functions should work. There are three functions: ```Multiplication (x)``` ```Addition (+)``` and ```Reverse (!esreveR)``` i { font-size:16px; } #heading { padding: 2em; text-align: center; background-color: #0033FF; wi...
apps_data_3161
_A mad sociopath scientist just came out with a brilliant invention! He extracted his own memories to forget all the people he hates! Now there's a lot of information in there, so he needs your talent as a developer to automatize that task for him._ > You are given the memories as a string containing people's surname ...
apps_data_3162
Compare two strings by comparing the sum of their values (ASCII character code). * For comparing treat all letters as UpperCase * `null/NULL/Nil/None` should be treated as empty strings * If the string contains other characters than letters, treat the whole string as it would be empty Your method should return `true`...
apps_data_3163
# Task `Triangular numbers` are defined by the formula `n * (n + 1) / 2` with `n` starting from 1. They count the number of objects that can form an equilateral triangle as shown in the picture below: ![](https://i.gyazo.com/eec11cc9e17a31324338edc4eb7bb746.png) So the sequence of triangular numbers begins as follows...
apps_data_3164
Finish the solution so that it takes an input `n` (integer) and returns a string that is the decimal representation of the number grouped by commas after every 3 digits. Assume: `0 <= n < 2147483647` ## Examples ``` 1 -> "1" 10 -> "10" 100 -> "100" 1000 -> "...
apps_data_3165
Introduction It's been more than 20 minutes since the negligent waiter has taken your order for the house special prime tofu steak with a side of chili fries. Out of boredom, you start fiddling around with the condiments tray. To be efficient, you want to be familiar with the choice of sauces and spices before your o...
apps_data_3166
# Task Suppose there are `n` people standing in a circle and they are numbered 1 through n in order. Person 1 starts off with a sword and kills person 2. He then passes the sword to the next person still standing, in this case person 3. Person 3 then uses the sword to kill person 4, and passes it to person 5. This...
apps_data_3167
The objective is to return all pairs of integers from a given array of integers that have a difference of 2. The result array should be sorted in ascending order of values. Assume there are no duplicate integers in the array. The order of the integers in the input array should not matter. ## Examples ~~~if-not:pyth...
apps_data_3168
Pirates have notorious difficulty with enunciating. They tend to blur all the letters together and scream at people. At long last, we need a way to unscramble what these pirates are saying. Write a function that will accept a jumble of letters as well as a dictionary, and output a list of words that the pirate might ...
apps_data_3169
We have the following sequence: ```python f(0) = 0 f(1) = 1 f(2) = 1 f(3) = 2 f(4) = 4; f(n) = f(n-1) + f(n-2) + f(n-3) + f(n-4) + f(n-5); ``` Your task is to give the number of total values for the odd terms of the sequence up to the n-th term (included). (The number n (of n-th term) will be given as a positive inte...
apps_data_3170
Create a function `longer` that accepts a string and sorts the words in it based on their respective lengths in an ascending order. If there are two words of the same lengths, sort them alphabetically. Look at the examples below for more details. ```python longer("Another Green World") => Green World Another longer("D...
apps_data_3171
You are stacking some boxes containing gold weights on top of each other. If a box contains more weight than the box below it, it will crash downwards and combine their weights. e.g. If we stack [2] on top of [1], it will crash downwards and become a single box of weight [3] ``` [2] [1] --> [3] ``` Given an array of ar...
apps_data_3172
A chess position can be expressed as a string using the Forsyth–Edwards Notation (FEN). Your task is to write a parser that reads in a FEN-encoded string and returns a depiction of the board using the Unicode chess symbols (♔,♕,♘,etc.). The board should be drawn from the perspective of the active color (i.e. the side ...
apps_data_3173
### Unfinished Loop - Bug Fixing #1 Oh no, Timmy's created an infinite loop! Help Timmy find and fix the bug in his unfinished for loop! def create_array(n): res=[] i=1 while i<=n: res+=[i] i+= 1 return res def create_array(n): return [i for i in range(1,n+1)] create_array = lamb...
apps_data_3174
Complete the function that calculates the derivative of a polynomial. A polynomial is an expression like: 3x^(4) - 2x^(2) + x - 10 ### How to calculate the derivative: * Take the exponent and multiply it with the coefficient * Reduce the exponent by 1 For example: 3x^(4) --> (4*3)x^((4-1)) = 12x^(3) ### Good to kno...
apps_data_3175
Write a function ```javascript tripledouble(num1,num2) ``` ```python triple_double(num1, num2) ``` which takes numbers `num1` and `num2` and returns `1` if there is a straight triple of a number at any place in `num1` and also a straight double of the **same** number in `num2`. If this isn't the case, return `0` ##...
apps_data_3176
Implement `String#to_cents`, which should parse prices expressed as `$1.23` and return number of cents, or in case of bad format return `nil`. import re def to_cents(amount): m = re.match(r'\$(\d+)\.(\d\d)\Z', amount) return int(m.expand(r'\1\2')) if m else None from re import compile, match REGEX = compi...
apps_data_3177
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: `2332, 110011, 54322345` For a given number ```num```, write a function which returns an array of all the numerical palindromes contained within each number. The arra...
apps_data_3178
Our friendly friend Pete is really a nice person, but he tends to be rather... Inappropriate. And possibly loud, if given enough ethanol and free rein, so we ask you to write a function that should take its not always "clean" speech and cover as much as possible of it, in order not to offend some more sensible spirits...
apps_data_3179
# Task You are given three integers `l, d and x`. Your task is: ``` • determine the minimal integer n such that l ≤ n ≤ d, and the sum of its digits equals x. • determine the maximal integer m such that l ≤ m ≤ d, and the sum of its digits equals x. ``` It is guaranteed that such numbers always exist. # Inp...
apps_data_3180
Bleatrix Trotter the sheep has devised a strategy that helps her fall asleep faster. First, she picks a number N. Then she starts naming N, 2 × N, 3 × N, and so on. Whenever she names a number, she thinks about all of the digits in that number. She keeps track of which digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) she has ...
apps_data_3181
## If/else syntax debug While making a game, your partner, Greg, decided to create a function to check if the user is still alive called `checkAlive`/`CheckAlive`/`check_alive`. Unfortunately, Greg made some errors while creating the function. `checkAlive`/`CheckAlive`/`check_alive` should return true if the player's...
apps_data_3182
Looking at consecutive powers of `2`, starting with `2^1`: `2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, ...` Note that out of all the digits `0-9`, the last one ever to appear is `7`. It only shows up for the first time in the number `32768 (= 2^15)`. So let us define LAST DIGIT TO APPE...
apps_data_3183
Task ====== Make a custom esolang interpreter for the language [InfiniTick](https://esolangs.org/wiki/InfiniTick). InfiniTick is a descendant of [Tick](https://esolangs.org/wiki/tick) but also very different. Unlike Tick, InfiniTick has 8 commands instead of 4. It also runs infinitely, stopping the program only when a...
apps_data_3184
Sam has opened a new sushi train restaurant - a restaurant where sushi is served on plates that travel around the bar on a conveyor belt and customers take the plate that they like. Sam is using Glamazon's new visual recognition technology that allows a computer to record the number of plates at a customer's table and...
apps_data_3185
In this kata your mission is to rotate matrix counter - clockwise N-times. So, you will have 2 inputs: 1)matrix 2)a number, how many times to turn it And an output is turned matrix. Example: matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, ...
apps_data_3186
# Task Your task is to find the similarity of given sorted arrays `a` and `b`, which is defined as follows: you take the number of elements which are present in both arrays and divide it by the number of elements which are present in at least one array. It also can be written as a formula `similarity(A, B) = #(A...
apps_data_3187
Implement a function to calculate the sum of the numerical values in a nested list. For example : ```python sum_nested([1, [2, [3, [4]]]]) -> 10 ``` def sum_nested(lst): return sum(sum_nested(x) if isinstance(x,list) else x for x in lst) def sum_nested(lst): total = 0 for ele in lst: total += ele...
apps_data_3188
# Base reduction ## Input A positive integer: ``` 0 < n < 1000000000 ``` ## Output The end result of the base reduction. If it cannot be fully reduced (reduced down to a single-digit number), return -1. Assume that if 150 conversions from base 11 take place in a row, the number cannot be fully reduced. ## Descri...
apps_data_3189
The Story: Aliens from Kepler 27b have immigrated to Earth! They have learned English and go to our stores, eat our food, dress like us, ride Ubers, use Google, etc. However, they speak English a little differently. Can you write a program that converts our English to their Alien English? Task: Write a function conve...
apps_data_3190
Consider the number `1176` and its square (`1176 * 1176) = 1382976`. Notice that: * the first two digits of `1176` form a prime. * the first two digits of the square `1382976` also form a prime. * the last two digits of `1176` and `1382976` are the same. Given two numbers representing a range (`a, b`), how many numb...
apps_data_3191
# 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_3192
Your friend has been out shopping for puppies (what a time to be alive!)... He arrives back with multiple dogs, and you simply do not know how to respond! By repairing the function provided, you will find out exactly how you should respond, depending on the number of dogs he has. The number of dogs will always be a n...
apps_data_3193
Raj was to move up through a pattern of stairs of a given number **(n)**. Help him to get to the top using the function **stairs**. ##Keep in mind : * If **n<1** then return ' ' . * There are a lot of spaces before the stair starts except for **pattern(1)** ##Examples : pattern(1) 1 1 pattern(...
apps_data_3194
In case you might be unlucky enough not to know the best dark fantasy franchise ever, Berserk tells the story of a man that, hating gratuitous violence, decided to become a mercenary (thus one who sells violence, no gratuity anymore!) and starts an epic struggle against apparently unsormountable odds, unsure if he real...
apps_data_3195
Write a function that checks the braces status in a string, and return `True` if all braces are properly closed, or `False` otherwise. Available types of brackets: `()`, `[]`, `{}`. **Please note, you need to write this function without using regex!** ## Examples ```python '([[some](){text}here]...)' => True '{([])...
apps_data_3196
Triangular numbers count the number of objects that can form an equilateral triangle. The nth triangular number forms an equilateral triangle with n dots on each side (including the vertices). Here is a graphic example for the triangular numbers of 1 to 5: ``` n=1: triangular number: 1 * n=2: triangular number: 3 * *...
apps_data_3197
In Spanish, the conjugated verb changes by adding suffixes and according to the person we're talking about. There's something similar in English when we talk about "She", "He"or "It" (3rd person singular): With the verb "run": **He / She / It runS** As you can see, the rule (at least with regular verbs) is to add t...
apps_data_3198
The first input array is the key to the correct answers to an exam, like ["a", "a", "b", "d"]. The second one contains a student's submitted answers. The two arrays are not empty and are the same length. Return the score for this array of answers, giving +4 for each correct answer, -1 for each incorrect answer, and +...
apps_data_3199
Say hello! Write a function to greet a person. Function will take name as input and greet the person by saying hello. Return null/nil/None if input is empty string or null/nil/None. Example: ```python greet("Niks") --> "hello Niks!" greet("") --> None # Return None if input is empty string greet(None) --> None ...