id
stringlengths
11
14
content
stringlengths
424
1.17M
apps_data_4900
Consider the sequence `S(n, z) = (1 - z)(z + z**2 + z**3 + ... + z**n)` where `z` is a complex number and `n` a positive integer (n > 0). When `n` goes to infinity and `z` has a correct value (ie `z` is in its domain of convergence `D`), `S(n, z)` goes to a finite limit `lim` depending on `z`. Experiment with `S(n,...
apps_data_4901
We all use 16:9, 16:10, 4:3 etc. ratios every day. Main task is to determine image ratio by its width and height dimensions. Function should take width and height of an image and return a ratio string (ex."16:9"). If any of width or height entry is 0 function should throw an exception (or return `Nothing`). from fra...
apps_data_4902
The built-in print function for Python class instances is not very entertaining. In this Kata, we will implement a function ```show_me(instname)``` that takes an instance name as parameter and returns the string "Hi, I'm one of those (classname)s! Have a look at my (attrs).", where (classname) is the class name and (a...
apps_data_4903
A sequence is usually a set or an array of numbers that has a strict way for moving from the nth term to the (n+1)th term. If ``f(n) = f(n-1) + c`` where ``c`` is a constant value, then ``f`` is an arithmetic sequence. An example would be (where the first term is 0 and the constant is 1) is [0, 1, 2, 3, 4, 5, ... and s...
apps_data_4904
Write a function ```unpack()``` that unpacks a ```list``` of elements that can contain objects(`int`, `str`, `list`, `tuple`, `dict`, `set`) within each other without any predefined depth, meaning that there can be many levels of elements contained in one another. Example: ```python unpack([None, [1, ({2, 3}, {'foo':...
apps_data_4905
You're given a mystery `puzzlebox` object. Examine it to make the tests pass and solve this kata. def answer(puzzlebox): return 42 def answer(puzzlebox): #print(dir(puzzlebox)) #puzzlebox.hint #print(puzzlebox.hint_two) #print(puzzlebox.lock(puzzlebox.key)) return 42 pass # 09/01/2019 # I...
apps_data_4906
**See Also** * [Traffic Lights - one car](.) * [Traffic Lights - multiple cars](https://www.codewars.com/kata/5d230e119dd9860028167fa5) --- # Overview A character string represents a city road. Cars travel on the road obeying the traffic lights.. Legend: * `.` = Road * `C` = Car * `G` = GREEN traffic light * `O` =...
apps_data_4907
# Task When a candle finishes burning it leaves a leftover. makeNew leftovers can be combined to make a new candle, which, when burning down, will in turn leave another leftover. You have candlesNumber candles in your possession. What's the total number of candles you can burn, assuming that you create new candles a...
apps_data_4908
In 1978 the British Medical Journal reported on an outbreak of influenza at a British boarding school. There were `1000` students. The outbreak began with one infected student. We want to study the spread of the disease through the population of this school. The total population may be divided into three: the infecte...
apps_data_4909
Write a class Random that does the following: 1. Accepts a seed ```python >>> random = Random(10) >>> random.seed 10 ``` 2. Gives a random number between 0 and 1 ```python >>> random.random() 0.347957 >>> random.random() 0.932959 ``` 3. Gives a random int from a range ```python >>> random.randint(0, 100) 67 >>> rand...
apps_data_4910
This kata is part one of precise fractions series (see pt. 2: http://www.codewars.com/kata/precise-fractions-pt-2-conversion). When dealing with fractional values, there's always a problem with the precision of arithmetical operations. So lets fix it! Your task is to implement class ```Fraction``` that takes care of ...
apps_data_4911
#Adding values of arrays in a shifted way You have to write a method, that gets two parameter: ```markdown 1. An array of arrays with int-numbers 2. The shifting value ``` #The method should add the values of the arrays to one new array. The arrays in the array will all have the same size and this size will always ...
apps_data_4912
# Task You are implementing your own HTML editor. To make it more comfortable for developers you would like to add an auto-completion feature to it. Given the starting HTML tag, find the appropriate end tag which your editor should propose. # Example For startTag = "<button type='button' disabled>", the output sh...
apps_data_4913
# Our Setup Alice and Bob work in an office. When the workload is light and the boss isn't looking, they often play simple word games for fun. This is one of those days! # This Game Today Alice and Bob are playing what they like to call _Mutations_, where they take turns trying to "think up" a new four-letter word i...
apps_data_4914
When provided with a letter, return its position in the alphabet. Input :: "a" Ouput :: "Position of alphabet: 1" `This kata is meant for beginners. Rank and upvote to bring it out of beta` def position(alphabet): return "Position of alphabet: {}".format(ord(alphabet) - 96) def position(alphabet): return "...
apps_data_4915
Help Suzuki rake his garden! The monastery has a magnificent Zen garden made of white gravel and rocks and it is raked diligently everyday by the monks. Suzuki having a keen eye is always on the lookout for anything creeping into the garden that must be removed during the daily raking such as insects or moss. You wi...
apps_data_4916
Write a function generator that will generate the first `n` primes grouped in tuples of size `m`. If there are not enough primes for the last tuple it will have the remaining values as `None`. ## Examples ```python For n = 11 and m = 2: (2, 3), (5, 7), (11, 13), (17, 19), (23, 29), (31, None) For n = 11 and m = 3: (...
apps_data_4917
Write a function that takes a string of braces, and determines if the order of the braces is valid. It should return `true` if the string is valid, and `false` if it's invalid. This Kata is similar to the [Valid Parentheses](https://www.codewars.com/kata/valid-parentheses) Kata, but introduces new characters: brackets...
apps_data_4918
You have been tasked with converting a number from base i (sqrt of -1) to base 10. Recall how bases are defined: abcdef = a * 10^5 + b * 10^4 + c * 10^3 + d * 10^2 + e * 10^1 + f * 10^0 Base i follows then like this: ... i^4 + i^3 + i^2 + i^1 + i^0 The only numbers in any place will be 1 or 0 Examples: ...
apps_data_4919
You are given an n by n ( square ) grid of characters, for example: ```python [['m', 'y', 'e'], ['x', 'a', 'm'], ['p', 'l', 'e']] ``` You are also given a list of integers as input, for example: ```python [1, 3, 5, 8] ``` You have to find the characters in these indexes of the grid if you think of the indexes a...
apps_data_4920
Given a certain array of integers, create a function that may give the minimum number that may be divisible for all the numbers of the array. ```python min_special_mult([2, 3 ,4 ,5, 6, 7]) == 420 ``` The array may have integers that occurs more than once: ```python min_special_mult([18, 22, 4, 3, 21, 6, 3]) == 2772 ``...
apps_data_4921
In this kata, we're going to create the function `nato` that takes a `word` and returns a string that spells the word using the [NATO phonetic alphabet](https://en.wikipedia.org/wiki/NATO_phonetic_alphabet). There should be a space between each word in the returned string, and the first letter of each word should be c...
apps_data_4922
Linked lists are data structures composed of nested or chained objects, each containing a single value and a reference to the next object. Here's an example of a list: ```python class LinkedList: def __init__(self, value=0, next=None): self.value = value self.next = next LinkedList(1, Li...
apps_data_4923
You have two arguments: ```string``` - a string of random letters(only lowercase) and ```array``` - an array of strings(feelings). Your task is to return how many specific feelings are in the ```array```. For example: ``` string -> 'yliausoenvjw' array -> ['anger', 'awe', 'joy', 'love', 'grief'] output -> '3 feelin...
apps_data_4924
Professor Oak has just begun learning Python and he wants to program his new Pokedex prototype with it. For a starting point, he wants to instantiate each scanned Pokemon as an object that is stored at Pokedex's memory. He needs your help! Your task is to: 1) Create a ```PokeScan``` class that takes in 3 arguments: ...
apps_data_4925
## Preface A collatz sequence, starting with a positive integern, is found by repeatedly applying the following function to n until n == 1 : `$f(n) = \begin{cases} n/2, \text{ if $n$ is even} \\ 3n+1, \text{ if $n$ is odd} \end{cases}$` ---- A more detailed description of the collatz conjecture may be found [on...
apps_data_4926
Given any number of boolean flags function should return true if and only if one of them is true while others are false. If function is called without arguments it should return false. ```python only_one() == False only_one(True, False, False) == True only_one(True, False, False, True) == False only_one(False,...
apps_data_4927
Given an array `A` and an integer `x`, map each element in the array to `F(A[i],x)` then return the xor sum of the resulting array. where F(n,x) is defined as follows: F(n, x) = ^(x)Cx **+** ^(x+1)Cx **+** ^(x+2)Cx **+** ... **+** ^(n)Cx and ^(n)Cx represents [Combination](https://en.m.wikipedia.org/wiki/Combination...
apps_data_4928
A startup office has an ongoing problem with its bin. Due to low budgets, they don't hire cleaners. As a result, the staff are left to voluntarily empty the bin. It has emerged that a voluntary system is not working and the bin is often overflowing. One staff member has suggested creating a rota system based upon the s...
apps_data_4929
## Decode the diagonal. Given a grid of characters. Output a decoded message as a string. Input ``` H Z R R Q D I F C A E A ! G H T E L A E L M N H P R F X Z R P E ``` Output `HITHERE!` (diagonally down right `↘` and diagonally up right `↗` if you can't go further). The message ends when there is n...
apps_data_4930
You are given an array of positive and negative integers and a number ```n``` and ```n > 1```. The array may have elements that occurs more than once. Find all the combinations of n elements of the array that their sum are 0. ```python arr = [1, -1, 2, 3, -2] n = 3 find_zero_sum_groups(arr, n) == [-2, -1, 3] # -2 - 1 +...
apps_data_4931
# Task Given a rectangular matrix containing only digits, calculate the number of different `2 × 2` squares in it. # Example For ``` matrix = [[1, 2, 1], [2, 2, 2], [2, 2, 2], [1, 2, 3], [2, 2, 1]] ``` the output should be `6`. Here are all 6 different 2 × 2 squares: ```...
apps_data_4932
# Toggling Grid You are given a grid (2d array) of 0/1's. All 1's represents a solved puzzle. Your job is to come up with a sequence of toggle moves that will solve a scrambled grid. Solved: ``` [ [1, 1, 1], [1, 1, 1], [1, 1, 1] ] ``` "0" (first row) toggle: ``` [ [0, 0, 0], [1, 1, 1], [1, 1, 1] ] ``` then...
apps_data_4933
Write a function that will randomly upper and lower characters in a string - `randomCase()` (`random_case()` for Python). A few examples: ``` randomCase("Lorem ipsum dolor sit amet, consectetur adipiscing elit") == "lOReM ipSum DOloR SiT AmeT, cOnsEcTEtuR aDiPiSciNG eLIt" randomCase("Donec eleifend cursus lobortis")...
apps_data_4934
Write a `sort` function that will sort a massive list of strings in caseless, lexographic order. Example Input: `['b', 'ba', 'ab', 'bb', 'c']` Expected Output: `['ab', 'b', 'ba', 'bb', 'c']` * The argument for your function will be a generator that will return a new word for each call of next() * Your function will ...
apps_data_4935
⚠️ The world is in quarantine! There is a new pandemia that struggles mankind. Each continent is isolated from each other but infected people have spread before the warning. ⚠️ 🗺️ You would be given a map of the world in a type of string: string s = "01000000X000X011X0X" '0' : uninfected '1' : infected...
apps_data_4936
Write a function `reverse` which reverses a list (or in clojure's case, any list-like data structure) (the dedicated builtin(s) functionalities are deactivated) from collections import deque def reverse(lst): q = deque() for x in lst: q.appendleft(x) return list(q) def reverse(lst): out = li...
apps_data_4937
You're in the casino, playing Roulette, going for the "1-18" bets only and desperate to beat the house and so you want to test how effective the [Martingale strategy](https://en.wikipedia.org/wiki/Martingale_(betting_system)) is. You will be given a starting cash balance and an array of binary digits to represent a w...
apps_data_4938
The goal of this kata is to write a function that takes two inputs: a string and a character. The function will count the number of times that character appears in the string. The count is case insensitive. For example: ```python count_char("fizzbuzz","z") => 4 count_char("Fancy fifth fly aloof","f") => 5 ``` The c...
apps_data_4939
# Background I drink too much coffee. Eventually it will probably kill me. *Or will it..?* Anyway, there's no way to know. *Or is there...?* # The Discovery of the Formula I proudly announce my discovery of a formula for measuring the life-span of coffee drinkers! For * ```h``` is a health number assigned to ...
apps_data_4940
# Story Old MacDingle had a farm... ...and on that farm he had * horses * chickens * rabbits * some apple trees * a vegetable patch Everything is idylic in the MacDingle farmyard **unless somebody leaves the gates open** Depending which gate was left open then... * horses might run away * horses might eat the...
apps_data_4941
Suzuki needs help lining up his students! Today Suzuki will be interviewing his students to ensure they are progressing in their training. He decided to schedule the interviews based on the length of the students name in descending order. The students will line up and wait for their turn. You will be given a string o...
apps_data_4942
You are given a list of directions in the form of a list: goal = ["N", "S", "E", "W"] Pretend that each direction counts for 1 step in that particular direction. Your task is to create a function called directions, that will return a reduced list that will get you to the same point.The order of directions must be re...
apps_data_4943
Your task is to return how many times a string contains a given character. The function takes a string(inputS) as a paremeter and a char(charS) which is the character that you will have to find and count. For example, if you get an input string "Hello world" and the character to find is "o", return 2. def string_co...
apps_data_4944
Create a class Vector that has simple (3D) vector operators. In your class, you should support the following operations, given Vector ```a``` and Vector ```b```: ```python a + b # returns a new Vector that is the resultant of adding them a - b # same, but with subtraction a == b # returns true if they have the same m...
apps_data_4945
A great flood has hit the land, and just as in Biblical times we need to get the animals to the ark in pairs. We are only interested in getting one pair of each animal, and not interested in any animals where there are less than 2....they need to mate to repopulate the planet after all! You will be given a list of ani...
apps_data_4946
# Task A boy is walking a long way from school to his home. To make the walk more fun he decides to add up all the numbers of the houses that he passes by during his walk. Unfortunately, not all of the houses have numbers written on them, and on top of that the boy is regularly taking turns to change streets, so the n...
apps_data_4947
Create a function ```sel_number()```, that will select numbers that fulfill the following constraints: 1) The numbers should have 2 digits at least. 2) They should have their respective digits in increasing order from left to right. Examples: 789, 479, 12678, have these feature. But 617, 89927 are not of this type. ...
apps_data_4948
Write the function `resistor_parallel` that receive an undefined number of resistances parallel resistors and return the total resistance. You can assume that there will be no 0 as parameter. Also there will be at least 2 arguments. Formula: `total = 1 / (1/r1 + 1/r2 + .. + 1/rn)` Examples: `resistor_parallel(...
apps_data_4949
Robinson Crusoe decides to explore his isle. On a sheet of paper he plans the following process. His hut has coordinates `origin = [0, 0]`. From that origin he walks a given distance `d` on a line that has a given angle `ang` with the x-axis. He gets to a point A. (Angles are measured with respect to the x-axis) Fro...
apps_data_4950
### Task Your main goal is to find two numbers(` >= 0 `), greatest common divisor of wich will be `divisor` and number of iterations, taken by Euclids algorithm will be `iterations`. ### Euclid's GCD ```CSharp BigInteger FindGCD(BigInteger a, BigInteger b) { // Swaping `a` and `b` if (a < b) { a += b; b ...
apps_data_4951
Take the following IPv4 address: 128.32.10.1 This address has 4 octets where each octet is a single byte (or 8 bits). * 1st octet 128 has the binary representation: 10000000 * 2nd octet 32 has the binary representation: 00100000 * 3rd octet 10 has the binary representation: 00001010 * 4th octet 1 has the binary repre...
apps_data_4952
**The Rub** You need to make a function that takes an object as an argument, and returns a very similar object but with a special property. The returned object should allow a user to access values by providing only the beginning of the key for the value they want. For example if the given object has a key `idNumber`, ...
apps_data_4953
Lets play some Pong! ![pong](http://gifimage.net/wp-content/uploads/2017/08/pong-gif-3.gif) For those who don't know what Pong is, it is a simple arcade game where two players can move their paddles to hit a ball towards the opponent's side of the screen, gaining a point for each opponent's miss. You can read more a...
apps_data_4954
Design a data structure that supports the following two operations: * `addWord` (or `add_word`) which adds a word, * `search` which searches a literal word or a regular expression string containing lowercase letters `"a-z"` or `"."` where `"."` can represent any letter You may assume that all given words contain only...
apps_data_4955
It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let the groups know ahead of time which will be picked up for each comet by a clever s...
apps_data_4956
Our cells go through a process called protein synthesis to translate the instructions in DNA into an amino acid chain, or polypeptide. Your job is to replicate this! --- **Step 1: Transcription** Your input will be a string of DNA that looks like this: `"TACAGCTCGCTATGAATC"` You then must transcribe it to mRNA. ...
apps_data_4957
Teach snoopy and scooby doo how to bark using object methods. Currently only snoopy can bark and not scooby doo. ```python snoopy.bark() #return "Woof" scoobydoo.bark() #undefined ``` Use method prototypes to enable all Dogs to bark. class Dog (): def __init__(self, breed): self.breed = breed def bark(self)...
apps_data_4958
Complete the solution so that it returns a formatted string. The return value should equal "Value is VALUE" where value is a 5 digit padded number. Example: ```python solution(5) # should return "Value is 00005" ``` def solution(value): return "Value is %05d" % value solution='Value is {:05d}'.format ...
apps_data_4959
There are a **n** balls numbered from 0 to **n-1** (0,1,2,3,etc). Most of them have the same weight, but one is heavier. Your task is to find it. Your function will receive two arguments - a `scales` object, and a ball count. The `scales` object has only one method: ```python get_weight(left, right) ``` where `l...
apps_data_4960
[Harshad numbers](http://en.wikipedia.org/wiki/Harshad_number) (also called Niven numbers) are positive numbers that can be divided (without remainder) by the sum of their digits. For example, the following numbers are Harshad numbers: * 10, because 1 + 0 = 1 and 10 is divisible by 1 * 27, because 2 + 7 = 9 and 27 is...
apps_data_4961
Everyday we go to different places to get our things done. Those places can be represented by specific location points `[ [, ], ... ]` on a map. I will be giving you an array of arrays that contain coordinates of the different places I had been on a particular day. Your task will be to find `peripheries (outermost edge...
apps_data_4962
Polly is 8 years old. She is eagerly awaiting Christmas as she has a bone to pick with Santa Claus. Last year she asked for a horse, and he brought her a dolls house. Understandably she is livid. The days seem to drag and drag so Polly asks her friend to help her keep count of how long it is until Christmas, in days. ...
apps_data_4963
Given a number return the closest number to it that is divisible by 10. Example input: ``` 22 25 37 ``` Expected output: ``` 20 30 40 ``` def closest_multiple_10(i): return round(i, -1) def closest_multiple_10(i): return round(i / 10) * 10 def closest_multiple_10(i): r = i % 10 return i - r if r ...
apps_data_4964
# Is the string uppercase? ## Task ```if-not:haskell,csharp,javascript,coffeescript,elixir,forth,go,dart,julia,cpp,reason,typescript,racket,ruby Create a method `is_uppercase()` to see whether the string is ALL CAPS. For example: ``` ```if:haskell,reason,typescript Create a method `isUpperCase` to see whether the str...
apps_data_4965
Your task in this kata is to implement a function that calculates the sum of the integers inside a string. For example, in the string "The30quick20brown10f0x1203jumps914ov3r1349the102l4zy dog", the sum of the integers is 3635. *Note: only positive integers will be tested.* import re def sum_of_integers_in_string(s):...
apps_data_4966
You and your friends have been battling it out with your Rock 'Em, Sock 'Em robots, but things have gotten a little boring. You've each decided to add some amazing new features to your robot and automate them to battle to the death. Each robot will be represented by an object. You will be given two robot objects, and ...
apps_data_4967
Imagine the following situations: - A truck loading cargo - A shopper on a budget - A thief stealing from a house using a large bag - A child eating candy very quickly All of these are examples of ***The Knapsack Problem***, where there are more things that you ***want*** to take with you than you ***can*** take with...
apps_data_4968
Two numbers are **relatively prime** if their greatest common factor is 1; in other words: if they cannot be divided by any other common numbers than 1. `13, 16, 9, 5, and 119` are all relatively prime because they share no common factors, except for 1. To see this, I will show their factorizations: ```python 13: 13 ...
apps_data_4969
Build Tower Advanced --- Build Tower by the following given arguments: __number of floors__ (integer and always greater than 0) __block size__ (width, height) (integer pair and always greater than (0, 0)) Tower block unit is represented as `*` * Python: return a `list`; * JavaScript: returns an `Array`; Have fun! *...
apps_data_4970
---- Vampire Numbers ---- Our loose definition of [Vampire Numbers](http://en.wikipedia.org/wiki/Vampire_number) can be described as follows: ```python 6 * 21 = 126 # 6 and 21 would be valid 'fangs' for a vampire number as the # digits 6, 1, and 2 are present in both the product and multiplicands 10 * 11 = 110 # 11...
apps_data_4971
Linked Lists - Sorted Insert Write a SortedInsert() function which inserts a node into the correct location of a pre-sorted linked list which is sorted in ascending order. SortedInsert takes the head of a linked list and data used to create a node as arguments. SortedInsert() should also return the head of the list. ...
apps_data_4972
Linked Lists - Length & Count Implement Length() to count the number of nodes in a linked list. Implement Count() to count the occurrences of an integer in a linked list. I've decided to bundle these two functions within the same Kata since they are both very similar. The `push()`/`Push()` and `buildOneTwoThree()`/...
apps_data_4973
Given an array of integers (x), and a target (t), you must find out if any two consecutive numbers in the array sum to t. If so, remove the second number. Example: x = [1, 2, 3, 4, 5] t = 3 1+2 = t, so remove 2. No other pairs = t, so rest of array remains: [1, 3, 4, 5] Work through the array from left to right. ...
apps_data_4974
You're putting together contact information for all the users of your website to ship them a small gift. You queried your database and got back a list of users, where each user is another list with up to two items: a string representing the user's name and their shipping zip code. Example data might look like: ```pyth...
apps_data_4975
Create a function taking a positive integer as its parameter and returning a string containing the Roman Numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately starting with the left most digit and skipping any digit with a value of zero. In Roman numerals 1990 is...
apps_data_4976
The function must return the sequence of titles that match the string passed as an argument. ```if:javascript TITLES is a preloaded sequence of strings. ``` ```python titles = ['Rocky 1', 'Rocky 2', 'My Little Poney'] search(titles, 'ock') --> ['Rocky 1', 'Rocky 2'] ``` But the function return some weird result an...
apps_data_4977
# Messi goals function [Messi](https://en.wikipedia.org/wiki/Lionel_Messi) is a soccer player with goals in three leagues: - LaLiga - Copa del Rey - Champions Complete the function to return his total number of goals in all three leagues. Note: the input will always be valid. For example: ``` 5, 10, 2 --> 17 `...
apps_data_4978
In this kata, your task is to implement what I call **Iterative Rotation Cipher (IRC)**. To complete the task, you will create an object with two methods, `encode` and `decode`. (For non-JavaScript versions, you only need to write the two functions without the enclosing dict) Input The encode method will receive two a...
apps_data_4979
# Story Those pesky rats have returned and this time they have taken over the Town Square. The Pied Piper has been enlisted again to play his magical tune and coax all the rats towards him. But some of the rats are deaf and are going the wrong way! # Kata Task How many deaf rats are there? ## Input Notes * The T...
apps_data_4980
#Sort the columns of a csv-file You get a string with the content of a csv-file. The columns are separated by semicolons. The first line contains the names of the columns. Write a method that sorts the columns by the names of the columns alphabetically and incasesensitive. An example: ``` Before sorting: As table (o...
apps_data_4981
Many websites use weighted averages of various polls to make projections for elections. They’re weighted based on a variety of factors, such as historical accuracy of the polling firm, sample size, as well as date(s). The weights, in this kata, are already calculated for you. All you need to do is convert a set of poll...
apps_data_4982
# Introduction Dots and Boxes is a pencil-and-paper game for two players (sometimes more). It was first published in the 19th century by Édouard Lucas, who called it la pipopipette. It has gone by many other names, including the game of dots, boxes, dot to dot grid, and pigs in a pen. Starting with an empty grid of ...
apps_data_4983
Your task is to implement a function that takes one or more dictionaries and combines them in one result dictionary. The keys in the given dictionaries can overlap. In that case you should combine all source values in an array. Duplicate values should be preserved. Here is an example: ```cs var source1 = new Dictiona...
apps_data_4984
John has invited some friends. His list is: ``` s = "Fred:Corwill;Wilfred:Corwill;Barney:Tornbull;Betty:Tornbull;Bjon:Tornbull;Raphael:Corwill;Alfred:Corwill"; ``` Could you make a program that - makes this string uppercase - gives it sorted in alphabetical order by last name. When the last names are the same, sort...
apps_data_4985
*You are a composer who just wrote an awesome piece of music. Now it's time to present it to a band that will perform your piece, but there's a problem! The singers vocal range doesn't stretch as your piece requires, and you have to transpose the whole piece.* # Your task Given a list of notes (represented as strings)...
apps_data_4986
# Write this function ![](http://i.imgur.com/mlbRlEm.png) `for i from 1 to n`, do `i % m` and return the `sum` f(n=10, m=5) // returns 20 (1+2+3+4+0 + 1+2+3+4+0) *You'll need to get a little clever with performance, since n can be a very large number* def f(n, m): re, c = divmod(n,m) return m*(m-1)/2*...
apps_data_4987
Write a function that receives two strings as parameter. This strings are in the following format of date: `YYYY/MM/DD`. Your job is: Take the `years` and calculate the difference between them. Examples: ``` '1997/10/10' and '2015/10/10' -> 2015 - 1997 = returns 18 '2015/10/10' and '1997/10/10' -> 2015 - 1997 = retur...
apps_data_4988
Now you have to write a function that takes an argument and returns the square of it. def square(n): return n ** 2 def square(n): return n*n square = lambda n: n*n def square(n): return pow(n, 2) def square(n): return n*n if isinstance(n,int) else None def mult(a, b): mv = 0 for c in range...
apps_data_4989
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle. ``` hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#...
apps_data_4990
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string). Examples: ```python solution('abc', 'bc') # returns true solution('abc', 'd') # returns false ``` def solution(string, ending): return string.endswith(ending) solution = str.endswit...
apps_data_4991
I will give you two strings. I want you to transform stringOne into stringTwo one letter at a time. Example: def mutate_my_strings(s1,s2): return '\n'.join( [s1] + [s2[:i]+s1[i:] for i,(a,b) in enumerate(zip(s1,s2),1) if a != b ]) + '\n' def mutate_my_strings(s1, s2): result = [s1] result.extend(f"{s2[:i...
apps_data_4992
Given a random bingo card and an array of called numbers, determine if you have a bingo! *Parameters*: `card` and `numbers` arrays. *Example input*: ``` card = [ ['B', 'I', 'N', 'G', 'O'], [1, 16, 31, 46, 61], [3, 18, 33, 48, 63], [5, 20, 'FREE SPACE', 50, 65], [7, 22, 37, 52, 67], [9, 24, 39, 54, 69] ] ...
apps_data_4993
The description is rather long but you are given all needed formulas (almost:-) John has bought a bike but before going moutain biking he wants us to do a few simulations. He gathered information: - His trip will consist of an ascent of `dTot` kilometers with an average slope of `slope` *percent* - We suppose that:...
apps_data_4994
A grammar is a set of rules that let us define a language. These are called **production rules** and can be derived into many different tools. One of them is **String Rewriting Systems** (also called Semi-Thue Systems or Markov Algorithms). Ignoring technical details, they are a set of rules that substitute ocurrences ...
apps_data_4995
Another rewarding day in the fast-paced world of WebDev. Man, you love your job! But as with any job, somtimes things can get a little tedious. Part of the website you're working on has a very repetitive structure, and writing all the HTML by hand is a bore. Time to automate! You want to write some functions that will ...
apps_data_4996
## **Instructions** The goal of this kata is two-fold: 1.) You must produce a fibonacci sequence in the form of an array, containing a number of items equal to the input provided. 2.) You must replace all numbers in the sequence `divisible by 3` with `Fizz`, those `divisible by 5` with `Buzz`, and those `divisible...
apps_data_4997
The function sigma 1, σ1 in mathematics, is known as the one that gives the sum of the divisors of an integer number. For example for the number 10, ```python σ1(10) = 18 # because the divisors of 10 are: 1, 2, 5, 10 σ1(10) = 1 + 2 + 5 + 10 = 18 ``` You can see the graph of this important function up to 250: The n...
apps_data_4998
The principal of a school likes to put challenges to the students related with finding words of certain features. One day she said: "Dear students, the challenge for today is to find a word that has only one vowel and seven consonants but cannot have the letters "y" and "m". I'll give a special award for the first stud...
apps_data_4999
Complete the method that takes a sequence of objects with two keys each: country or state, and capital. Keys may be symbols or strings. The method should return an array of sentences declaring the state or country and its capital. ## Examples ```python [{'state': 'Maine', 'capital': 'Augusta'}] --> ["The capital of ...