description
stringlengths 38
154k
| category
stringclasses 5
values | solutions
stringlengths 13
289k
| name
stringlengths 3
179
| id
stringlengths 24
24
| tags
sequencelengths 0
13
| url
stringlengths 54
54
| rank_name
stringclasses 8
values |
---|---|---|---|---|---|---|---|
One man (lets call him Eulampy) has a collection of some almost identical Fabergé eggs. One day his friend Tempter said to him:
> + Do you see that skyscraper? And can you tell me a maximal floor that if you drop your egg from will not crack it?
> + No, - said Eulampy.
> + But if you give me N eggs, - says Tempter - I'l tell you an answer.
> + Deal - said Eulampy. But I have one requirement before we start this: if I will see more than M falls of egg, my heart will be crushed instead of egg. So you have only M trys to throw eggs. Would you tell me an exact floor with this limitation?
## Task
Your task is to help Tempter - write a function
```haskell
height :: Integer -> Integer -> Integer
height n m = -- see text
```
that takes 2 arguments - the number of eggs `n` and the number of trys `m` - you should calculate maximum scyscrapper height (in floors), in which it is guaranteed to find an exactly maximal floor from which that an egg won't crack it.
Which means,
0. You can throw an egg from a specific floor every try
0. Every egg has the same, certain durability - if they're thrown from a certain floor or below, they won't crack. Otherwise they crack.
0. You have `n` eggs and `m` tries
0. What is the maxmimum height, such that you can always determine which floor the target floor is when the target floor can be any floor between `1` to this maximum height?
## Examples
```
height 0 14 = 0
height 2 0 = 0
height 2 14 = 105
height 7 20 = 137979
```
## Data range
```
n <= 20000
m <= 20000
```
| algorithms | def height(n, m):
h, t = 0, 1
for i in range(1, n + 1):
t = t * (m - i + 1) / / i
h += t
return h
| Fabergé Easter Eggs crush test | 54cb771c9b30e8b5250011d4 | [
"Mathematics",
"Dynamic Programming",
"Performance",
"Algorithms"
] | https://www.codewars.com/kata/54cb771c9b30e8b5250011d4 | 3 kyu |
This kata focuses on the Numpy python package and you can read up on the Numpy array manipulation functions here: https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.array-manipulation.html
You will get two integers `N` and `M`. You must return an array with two sub-arrays with numbers in ranges `[0, N / 2)` and `[N / 2, N)` respectively, each of them being rotated `M` times.
```
reorder(10, 1) => [[4, 0, 1, 2, 3], [9, 5, 6, 7, 8]]
reorder(10, 3) => [[2, 3, 4, 0, 1], [7, 8, 9, 5, 6]]
reorder(10, 97) => [[3, 4, 0, 1, 2], [8, 9, 5, 6, 7]]
``` | reference | import numpy as np
def reorder(a, b):
return np . roll(np . arange(a). reshape(2, - 1), b, 1). tolist()
| Reorder Array 2 | 5a48fab7bdb9b5b3690009b6 | [
"NumPy",
"Fundamentals"
] | https://www.codewars.com/kata/5a48fab7bdb9b5b3690009b6 | 6 kyu |
You task is to implement an simple interpreter for the notorious esoteric language [HQ9+](https://esolangs.org/wiki/HQ9+) that will work for a single character input:
- If the input is `'H'`, return `'Hello World!'`
- If the input is `'Q'`, return the input
- If the input is `'9'`, return the full lyrics of [99 Bottles of Beer](http://www.99-bottles-of-beer.net/lyrics.html). It should be formatted like this:
```if:rust
__Note__: In Rust, return `Some` containing the appropriate value.
```
```
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.
...
...
...
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
```
- For everything else, don't return anything (return `null` in C#, `None` in Rust, and `""` in Haskell).
(`+` has no visible effects so we can safely ignore it.) | reference | LINES = "{0} of beer on the wall, {0} of beer.\nTake one down and pass it around, {1} of beer on the wall."
SONG = '\n' . join(LINES . format("{} bottles" . format(
n), "{} bottle" . format(n - 1) + "s" * (n != 2)) for n in range(99, 1, - 1))
SONG += """
1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall."""
def HQ9(code):
return {'H': 'Hello World!', 'Q': 'Q', '9': SONG}. get(code, None)
| 8kyu interpreters: HQ9+ | 591588d49f4056e13f000001 | [
"Fundamentals"
] | https://www.codewars.com/kata/591588d49f4056e13f000001 | 8 kyu |
### Sudoku Background
Sudoku is a game played on a 9x9 grid. The goal of the game is to fill all cells of the grid with digits from 1 to 9, so that each column, each row, and each of the nine 3x3 sub-grids (also known as blocks) contain all of the digits from 1 to 9. <br/>
(More info at: http://en.wikipedia.org/wiki/Sudoku)
### Sudoku Solution Validator
Write a function `validSolution`/`ValidateSolution`/`valid_solution()` that accepts a 2D array representing a Sudoku board, and returns true if it is a valid solution, or false otherwise. The cells of the sudoku board may also contain 0's, which will represent empty cells. Boards containing one or more zeroes are considered to be invalid solutions.
The board is always 9 cells by 9 cells, and every cell only contains integers from 0 to 9.
### Examples
```
validSolution([
[5, 3, 4, 6, 7, 8, 9, 1, 2],
[6, 7, 2, 1, 9, 5, 3, 4, 8],
[1, 9, 8, 3, 4, 2, 5, 6, 7],
[8, 5, 9, 7, 6, 1, 4, 2, 3],
[4, 2, 6, 8, 5, 3, 7, 9, 1],
[7, 1, 3, 9, 2, 4, 8, 5, 6],
[9, 6, 1, 5, 3, 7, 2, 8, 4],
[2, 8, 7, 4, 1, 9, 6, 3, 5],
[3, 4, 5, 2, 8, 6, 1, 7, 9]
]); // => true
```
```
validSolution([
[5, 3, 4, 6, 7, 8, 9, 1, 2],
[6, 7, 2, 1, 9, 0, 3, 4, 8],
[1, 0, 0, 3, 4, 2, 5, 6, 0],
[8, 5, 9, 7, 6, 1, 0, 2, 0],
[4, 2, 6, 8, 5, 3, 7, 9, 1],
[7, 1, 3, 9, 2, 4, 8, 5, 6],
[9, 0, 1, 5, 3, 7, 2, 1, 4],
[2, 8, 7, 4, 1, 9, 6, 3, 5],
[3, 0, 0, 4, 8, 1, 1, 7, 9]
]); // => false
``` | algorithms | correct = [1, 2, 3, 4, 5, 6, 7, 8, 9]
def validSolution(board):
# check rows
for row in board:
if sorted(row) != correct:
return False
# check columns
for column in zip(* board):
if sorted(column) != correct:
return False
# check regions
for i in range(3):
for j in range(3):
region = []
for line in board[i * 3:(i + 1) * 3]:
region += line[j * 3:(j + 1) * 3]
if sorted(region) != correct:
return False
# if everything correct
return True
| Sudoku Solution Validator | 529bf0e9bdf7657179000008 | [
"Data Structures",
"Algorithms"
] | https://www.codewars.com/kata/529bf0e9bdf7657179000008 | 4 kyu |
What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example:
```
'abba' & 'baab' == true
'abba' & 'bbaa' == true
'abba' & 'abbba' == false
'abba' & 'abca' == false
```
Write a function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words. You should return an array of all the anagrams or an empty array if there are none. For example:
```javascript
anagrams('abba', ['aabb', 'abcd', 'bbaa', 'dada']) => ['aabb', 'bbaa']
anagrams('racer', ['crazer', 'carer', 'racar', 'caers', 'racer']) => ['carer', 'racer']
anagrams('laser', ['lazing', 'lazy', 'lacer']) => []
```
```if:go
Empty string slice is expected when there are no anagrams found.
``` | algorithms | def anagrams(word, words): return [
item for item in words if sorted(item) == sorted(word)]
| Where my anagrams at? | 523a86aa4230ebb5420001e1 | [
"Strings",
"Algorithms"
] | https://www.codewars.com/kata/523a86aa4230ebb5420001e1 | 5 kyu |
Alex just got a new hula hoop, he loves it but feels discouraged because his little brother is better than him
Write a program where Alex can input (n) how many times the hoop goes round and it will return him an encouraging message :)
- If Alex gets 10 or more hoops, return the string "Great, now move on to tricks".
- If he doesn't get 10 hoops, return the string "Keep at it until you get it". | reference | def hoopCount(n):
return "Keep at it until you get it" if n < 10 else "Great, now move on to tricks"
| Keep up the hoop | 55cb632c1a5d7b3ad0000145 | [
"Fundamentals"
] | https://www.codewars.com/kata/55cb632c1a5d7b3ad0000145 | 8 kyu |
Your task is to find the nearest square number, `nearest_sq(n)` or `nearestSq(n)`, of a positive integer `n`.
For example, if `n = 111`, then `nearest\_sq(n)` (`nearestSq(n)`) equals 121, since 111 is closer to 121, the square of 11, than 100, the square of 10.
If the `n` is already the perfect square (e.g. `n = 144`, `n = 81`, etc.), you need to just return `n`.
Good luck :)
Check my other katas:
<a href="https://www.codewars.com/kata/5a8059b1fd577709860000f6">Alphabetically ordered </a>
<a href="https://www.codewars.com/kata/5a805631ba1bb55b0c0000b8">Case-sensitive! </a>
<a href="https://www.codewars.com/kata/5a9a70cf5084d74ff90000f7">Not prime numbers </a>
<a href="https://www.codewars.com/kata/6402205dca1e64004b22b8de">Find your caterer </a>
| reference | def nearest_sq(n):
return round(n * * 0.5) * * 2
| Find Nearest square number | 5a805d8cafa10f8b930005ba | [
"Fundamentals",
"Mathematics"
] | https://www.codewars.com/kata/5a805d8cafa10f8b930005ba | 8 kyu |
Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for [some of his philosophy that he delivers via Twitter](https://twitter.com/jaden). When writing on Twitter, he is known for almost always capitalizing every word. For simplicity, you'll have to capitalize each word, check out how contractions are expected to be in the example below.
Your task is to convert strings to how they would be written by Jaden Smith. The strings are actual quotes from Jaden Smith, but they are not capitalized in the same way he originally typed them.
Example:
Not Jaden-Cased: "How can mirrors be real if our eyes aren't real"
Jaden-Cased: "How Can Mirrors Be Real If Our Eyes Aren't Real"
```if:java
Note that the **Java version** expects a return value of null for an empty string or null.
```
[Link to Jaden's former Twitter account @officialjaden via archive.org](https://web.archive.org/web/20190624190255/https://twitter.com/officialjaden) | reference | def to_jaden_case(string):
return ' ' . join(word . capitalize() for word in string . split())
| Jaden Casing Strings | 5390bac347d09b7da40006f6 | [
"Strings",
"Fundamentals"
] | https://www.codewars.com/kata/5390bac347d09b7da40006f6 | 7 kyu |
<div style="border:1px solid;position:relative;padding:1ex 1ex 1ex 11.1em;"><div style="position:absolute;left:0;top:0;bottom:0; width:10em; padding:1ex;text-align:center;border:1px solid;margin:0 1ex 0 0;color:#000;background-color:#eee;font-variant:small-caps">Part of Series 1/3</div><div>This kata is part of a series on the Morse code. After you solve this kata, you may move to the <a href="/kata/decode-the-morse-code-advanced">next one</a>.</div></div><br>In this kata you have to write a simple <a href="https://en.wikipedia.org/wiki/Morse_code">Morse code</a> decoder. While the Morse code is now mostly superseded by voice and digital data communication channels, it still has its use in some applications around the world.
The Morse code encodes every character as a sequence of "dots" and "dashes". For example, the letter <code>A</code> is coded as <code>·−</code>, letter <code>Q</code> is coded as <code>−−·−</code>, and digit <code>1</code> is coded as <code>·−−−−</code>. The Morse code is case-insensitive, traditionally capital letters are used. When the message is written in Morse code, a single space is used to separate the character codes and 3 spaces are used to separate words. For example, the message <code>HEY JUDE</code> in Morse code is <code>···· · −·−− ·−−− ··− −·· ·</code>.
**NOTE:** Extra spaces before or after the code have no meaning and should be ignored.
In addition to letters, digits and some punctuation, there are some special service codes, the most notorious of those is the international distress signal <a href="https://en.wikipedia.org/wiki/SOS">SOS</a> (that was first issued by <a href="https://en.wikipedia.org/wiki/RMS_Titanic">Titanic</a>), that is coded as <code>···−−−···</code>. These special codes are treated as single special characters, and usually are transmitted as separate words.
Your task is to implement a function that would take the morse code as input and return a decoded human-readable string.
For example:
```coffeescript
decodeMorse('.... . -.-- .--- ..- -.. .')
//should return "HEY JUDE"
```
```cpp
decodeMorse('.... . -.-- .--- ..- -.. .')
//should return "HEY JUDE"
```
```csharp
MorseCodeDecoder.Decode(".... . -.-- .--- ..- -.. .")
//should return "HEY JUDE"
```
```fsharp
decodeMorse ".... . -.-- .--- ..- -.. ."
// should return "HEY JUDE"
```
```elixir
MorseCode.decode('.... . -.-- .--- ..- -.. .')
#=> "HEY JUDE"
```
```elm
MorseCode.decode ".... . -.-- .--- ..- -.. ."
--should return "HEY JUDE"
```
```go
DecodeMorse(".... . -.-- .--- ..- -.. .")
// should return "HEY JUDE"
```
```haskell
decodeMorse ".... . -.-- .--- ..- -.. ."
--should return "HEY JUDE"
```
```java
MorseCodeDecoder.decode(".... . -.-- .--- ..- -.. .")
//should return "HEY JUDE"
```
```javascript
decodeMorse('.... . -.-- .--- ..- -.. .')
//should return "HEY JUDE"
```
```kotlin
decodeMorse('.... . -.-- .--- ..- -.. .')
//should return "HEY JUDE"
```
```php
decode_morse('.... . -.-- .--- ..- -.. .')
//should return "HEY JUDE"
```
```python
decode_morse('.... . -.-- .--- ..- -.. .')
#should return "HEY JUDE"
```
```racket
(decode-morse ".... . -.-- .--- ..- -.. .")
; should return "HEY JUDE"
```
```ruby
decodeMorse('.... . -.-- .--- ..- -.. .')
#should return "HEY JUDE"
```
```swift
decodeMorse('.... . -.-- .--- ..- -.. .')
//should return "HEY JUDE"
```
```typescript
decodeMorse('.... . -.-- .--- ..- -.. .')
//should return "HEY JUDE"
```
```rust
decode_morse(".... . -.-- .--- ..- -.. .")
//should return "HEY JUDE"
```
```scala
MorseDecoder.decode(".... . -.-- .--- ..- -.. .")
//should return "HEY JUDE"
```
```c
decode_morse(".... . -.-- .--- ..- -.. .")
// should return "HEY JUDE"
```
```julia
decodemorse(".... . -.-- .--- ..- -.. .")
# should return "HEY JUDE"
```
```NASM
a call to decode_morse with RDI set to the address of ".... . -.-- .--- ..- -.. ."
should fill the buffer pointed to by RDI with db 'HEY JUDE',0
```
**NOTE:** For coding purposes you have to use ASCII characters `.` and `-`, not Unicode characters.
The Morse code table is preloaded for you as a dictionary, feel free to use it:
+ Coffeescript/C++/Go/JavaScript/Julia/PHP/Python/Ruby/TypeScript: `MORSE_CODE['.--']`
+ C#: `MorseCode.Get(".--")` (returns `string`)
+ F#: `MorseCode.get ".--"` (returns `string`)
+ Elixir: `@morse_codes` variable (from `use MorseCode.Constants`). Ignore the unused variable warning for `morse_codes` because it's no longer used and kept only for old solutions.
+ Elm: `MorseCodes.get : Dict String String`
+ Haskell: `morseCodes ! ".--"` (Codes are in a `Map String String`)
+ Java: `MorseCode.get(".--")`
+ Kotlin: `MorseCode[".--"] ?: ""` or `MorseCode.getOrDefault(".--", "")`
+ Racket: `morse-code` (a hash table)
+ Rust: `MORSE_CODE`
+ Scala: `morseCodes(".--")`
+ Swift: `MorseCode[".--"] ?? ""` or `MorseCode[".--", default: ""]`
* C: provides parallel arrays, i.e. `morse[2] == "-.-"` for `ascii[2] == "C"`
+ NASM: a table of pointers to the morsecodes, and a corresponding list of ascii symbols
All the test strings would contain valid Morse code, so you may skip checking for errors and exceptions. In C#, tests will fail if the solution code throws an exception, please keep that in mind. This is mostly because otherwise the engine would simply ignore the tests, resulting in a "valid" solution.
Good luck!
After you complete this kata, you may try yourself at <a href="http://www.codewars.com/kata/decode-the-morse-code-advanced">Decode the Morse code, advanced</a>.
| algorithms | def decodeMorse(morseCode):
return ' ' . join('' . join(MORSE_CODE[letter] for letter in word . split(' ')) for word in morseCode . strip(). split(' '))
| Decode the Morse code | 54b724efac3d5402db00065e | [
"Algorithms"
] | https://www.codewars.com/kata/54b724efac3d5402db00065e | 6 kyu |
Complete the solution so that it reverses all of the words within the string passed in.
Words are separated by exactly one space and there are no leading or trailing spaces.
**Example(Input --> Output):**
```
"The greatest victory is that which requires no battle" --> "battle no requires which that is victory greatest The"
```
| algorithms | def reverseWords(str):
return " " . join(str . split(" ")[:: - 1])
| Reversed Words | 51c8991dee245d7ddf00000e | [
"Strings",
"Algorithms"
] | https://www.codewars.com/kata/51c8991dee245d7ddf00000e | 8 kyu |
You live in the city of Cartesia where all roads are laid out in a perfect grid. You arrived ten minutes too early to an appointment, so you decided to take the opportunity to go for a short walk. The city provides its citizens with a Walk Generating App on their phones -- everytime you press the button it sends you an array of one-letter strings representing directions to walk (eg. ['n', 's', 'w', 'e']). You always walk only a single block for each letter (direction) and you know it takes you one minute to traverse one city block, so create a function that will return **true** if the walk the app gives you will take you exactly ten minutes (you don't want to be early or late!) and will, of course, return you to your starting point. Return **false** otherwise.
> **Note**: you will always receive a valid array containing a random assortment of direction letters ('n', 's', 'e', or 'w' only). It will never give you an empty array (that's not a walk, that's standing still!).
| reference | def isValidWalk(walk):
return len(walk) == 10 and walk . count('n') == walk . count('s') and walk . count('e') == walk . count('w')
| Take a Ten Minutes Walk | 54da539698b8a2ad76000228 | [
"Arrays",
"Fundamentals"
] | https://www.codewars.com/kata/54da539698b8a2ad76000228 | 6 kyu |
The wide-mouth frog is particularly interested in the eating habits of other creatures.
He just can't stop asking the creatures he encounters what they like to eat. But, then he meets the alligator who just LOVES to eat wide-mouthed frogs!
When he meets the alligator, it then makes a tiny mouth.
Your goal in this kata is to create complete the `mouth_size` method this method takes one argument `animal` which corresponds to the animal encountered by the frog. If this one is an `alligator` (case-insensitive) return `small` otherwise return `wide`. | reference | def mouth_size(animal):
return 'small' if animal . lower() == 'alligator' else 'wide'
| The Wide-Mouthed frog! | 57ec8bd8f670e9a47a000f89 | [
"Strings",
"Logic",
"Fundamentals"
] | https://www.codewars.com/kata/57ec8bd8f670e9a47a000f89 | 8 kyu |
Complete the method that takes a boolean value and return a `"Yes"` string for `true`, or a `"No"` string for `false`.
| reference | def bool_to_word(bool):
return "Yes" if bool else "No"
| Convert boolean values to strings 'Yes' or 'No'. | 53369039d7ab3ac506000467 | [
"Fundamentals"
] | https://www.codewars.com/kata/53369039d7ab3ac506000467 | 8 kyu |
Given an array of ones and zeroes, convert the equivalent binary value to an integer.
Eg: `[0, 0, 0, 1]` is treated as `0001` which is the binary representation of `1`.
Examples:
```
Testing: [0, 0, 0, 1] ==> 1
Testing: [0, 0, 1, 0] ==> 2
Testing: [0, 1, 0, 1] ==> 5
Testing: [1, 0, 0, 1] ==> 9
Testing: [0, 0, 1, 0] ==> 2
Testing: [0, 1, 1, 0] ==> 6
Testing: [1, 1, 1, 1] ==> 15
Testing: [1, 0, 1, 1] ==> 11
```
However, the arrays can have varying lengths, not just limited to `4`. | reference | def binary_array_to_number(arr):
return int("" . join(map(str, arr)), 2)
| Ones and Zeros | 578553c3a1b8d5c40300037c | [
"Fundamentals",
"Arrays"
] | https://www.codewars.com/kata/578553c3a1b8d5c40300037c | 7 kyu |
Build a function that returns an array of integers from n to 1 where ```n>0```.
Example : `n=5` --> `[5,4,3,2,1]`
~~~if:nasm
*NOTE: In NASM, the function signature is* `int *reverse_seq(int n, size_t *size)` *where the first parameter* `n` *is as described above and the second parameter* `size` *is a pointer to an "out" parameter which should be set to the size of the array your function returns (which should be equal to* `n` *if your implementation is correct).*
~~~
~~~if:riscv
RISC-V: The function signature is
```c
void n_to_1(int n, int *arr);
```
Write your result to `arr`. You may assume it is large enough to hold the result. You do not need to return anything.
~~~ | reference | def reverseseq(n):
return list(range(n, 0, - 1))
| Reversed sequence | 5a00e05cc374cb34d100000d | [
"Fundamentals"
] | https://www.codewars.com/kata/5a00e05cc374cb34d100000d | 8 kyu |
Simple challenge - eliminate all bugs from the supplied code so that the code runs and outputs the expected value. Output should be the length of the longest word, as a number.
There will only be one 'longest' word. | bug_fixes | def find_longest(strng):
return max(len(a) for a in strng . split())
| Squash the bugs | 56f173a35b91399a05000cb7 | [
"Debugging",
"Fundamentals"
] | https://www.codewars.com/kata/56f173a35b91399a05000cb7 | 8 kyu |
# Exclusive "or" (xor) Logical Operator
## Overview
In some scripting languages like PHP, there exists a logical operator (e.g. `&&`, `||`, `and`, `or`, etc.) called the "Exclusive Or" (hence the name of this Kata). The exclusive or evaluates two booleans. It then returns `true` if **exactly one of the two expressions are true**, `false` otherwise. For example:
```php
false xor false == false // since both are false
true xor false == true // exactly one of the two expressions are true
false xor true == true // exactly one of the two expressions are true
true xor true == false // Both are true. "xor" only returns true if EXACTLY one of the two expressions evaluate to true.
```
## Task
Since we cannot define keywords in Javascript (well, at least I don't know how to do it), your task is to define a function `xor(a, b)` where `a` and `b` are the two expressions to be evaluated. Your `xor` function should have the behaviour described above, returning `true` if **exactly one of the two expressions evaluate to true**, `false` otherwise. | reference | def xor(a, b):
return a != b
| Exclusive "or" (xor) Logical Operator | 56fa3c5ce4d45d2a52001b3c | [
"Fundamentals"
] | https://www.codewars.com/kata/56fa3c5ce4d45d2a52001b3c | 8 kyu |
You are provided with a function of the form `f(x) = axⁿ`, that consists of a single term only and 'a' and 'n' are integers, e.g `f(x) = 3x²`, `f(x) = 5` etc.
Your task is to create a function that takes f(x) as the argument and returns the result of differentiating the function, that is, the derivative.
If `$ f(x) = ax^n $`, then `$ f^{\prime}(x) = nax^{n-1} $`
Input is a string, for example `"5x^4"`. The function f(x) consists of a single term only. Variable is denoted by `x`.
Output should be a string, for example `"20x^3"`.
### Examples
```text
"3x^2" => "6x"
"-5x^3" => "-15x^2"
"6x^-2" => "-12x^-3"
"5x" => "5"
"-x" => "-1"
"42" => "0"
``` | algorithms | from re import compile
REGEX = compile(r"(-?\d*)(x?)\^?(-?\d*)"). fullmatch
def differentiate(poly):
a, x, n = REGEX(poly). groups()
a, n = int(- 1 if a == '-' else a or 1), int(n or bool(x))
if n == 0 or n == 1:
return f" { a * n } "
if n == 2:
return f" { a * n } x"
return f" { a * n } x^ { n - 1 } "
| Derivatives of type x^n | 55e2de13b668981d3300003d | [
"Mathematics"
] | https://www.codewars.com/kata/55e2de13b668981d3300003d | 6 kyu |
Usually when you buy something, you're asked whether your credit card number, phone number or answer to your most secret question is still correct. However, since someone could look over your shoulder, you don't want that shown on your screen. Instead, we mask it.
Your task is to write a function `maskify`, which changes all but the last four characters into `'#'`.
## Examples (input --> output):
```
"4556364607935616" --> "############5616"
"64607935616" --> "#######5616"
"1" --> "1"
"" --> ""
// "What was the name of your first pet?"
"Skippy" --> "##ippy"
"Nananananananananananananananana Batman!" --> "####################################man!"
```
| algorithms | # return masked string
def maskify(cc):
return "#" * (len(cc) - 4) + cc[- 4:]
| Credit Card Mask | 5412509bd436bd33920011bc | [
"Strings",
"Algorithms"
] | https://www.codewars.com/kata/5412509bd436bd33920011bc | 7 kyu |
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-1) Kata, but introduces new characters: brackets `[]`, and curly braces `{}`. Thanks to `@arnedag` for the idea!
All input strings will be nonempty, and will only consist of parentheses, brackets and curly braces: `()[]{}`.
### What is considered Valid?
A string of braces is considered valid if all braces are matched with the correct brace.
## Examples
```
"(){}[]" => True
"([{}])" => True
"(}" => False
"[(])" => False
"[({})](]" => False
```
| algorithms | def validBraces(string):
braces = {"(": ")", "[": "]", "{": "}"}
stack = []
for character in string:
if character in braces . keys():
stack . append(character)
else:
if len(stack) == 0 or braces[stack . pop()] != character:
return False
return len(stack) == 0
| Valid Braces | 5277c8a221e209d3f6000b56 | [
"Algorithms"
] | https://www.codewars.com/kata/5277c8a221e209d3f6000b56 | 6 kyu |
Write a function which calculates the average of the numbers in a given list.
**Note:** Empty arrays should return 0. | reference | def find_average(array):
return sum(array) / len(array) if array else 0
| Calculate average | 57a2013acf1fa5bfc4000921 | [
"Fundamentals",
"Arrays"
] | https://www.codewars.com/kata/57a2013acf1fa5bfc4000921 | 8 kyu |
*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 two:
```
[1, 2, 5, 7, 2, 3, 5, 7, 8]
/ \
[1, 2, 5, 7] [2, 3, 5, 7, 8]
```
* Step 2: Put the arrays on top of each other:
```
[1, 2, 5, 7]
[2, 3, 5, 7, 8]
```
* Step 3: Add them together:
```
[2, 4, 7, 12, 15]
```
Repeat the above steps `n` times or until there is only one number left, and then return the array.
## Example
```
Input: arr=[4, 2, 5, 3, 2, 5, 7], n=2
Round 1
-------
step 1: [4, 2, 5] [3, 2, 5, 7]
step 2: [4, 2, 5]
[3, 2, 5, 7]
step 3: [3, 6, 7, 12]
Round 2
-------
step 1: [3, 6] [7, 12]
step 2: [3, 6]
[7, 12]
step 3: [10, 18]
Result: [10, 18]
``` | algorithms | def split_and_add(numbers, n):
for _ in range(n):
middle = len(numbers) / / 2
left = numbers[: middle]
right = numbers[middle:]
numbers = [a + b for a,
b in zip((len(right) - len(left)) * [0] + left, right)]
if len(numbers) == 1:
return numbers
return numbers
| Split and then add both sides of an array together. | 5946a0a64a2c5b596500019a | [
"Arrays",
"Algorithms"
] | https://www.codewars.com/kata/5946a0a64a2c5b596500019a | 6 kyu |
A normal deck of 52 playing cards contains suits `'H', 'C', 'D', 'S'` - Hearts, Clubs, Diamonds, Spades respectively - and cards with values from Ace (1) to King (13): `1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13`
## Your Task
Complete the function that returns a shuffled deck of 52 playing cards without repeats.
Each card should have format `"{suit} {value}"`, e.g. the Queen of Hearts is `"H 12"` and the Ace of Spades is ```"S 1"```. The order of the cards must be different each time the function is called. | reference | from random import shuffle
def shuffled_deck():
arr = [f' { x } { i } ' for x in "HCDS" for i in range(1, 14)]
shuffle(arr)
return arr
| Deal a Shuffled Deck of Cards | 5810ad962b321bac8f000178 | [
"Fundamentals"
] | https://www.codewars.com/kata/5810ad962b321bac8f000178 | 6 kyu |
Nathan loves cycling.
Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling.
You get given the time in hours and you need to return the number of litres Nathan will drink, rounded to the smallest value.
For example:
~~~if-not:sql
```
time = 3 ----> litres = 1
time = 6.7---> litres = 3
time = 11.8--> litres = 5
```
~~~
~~~if:sql
```
hours = 3 ----> liters = 1
hours = 6.7---> liters = 3
hours = 11.8--> liters = 5
```
Input data is available from the table `cycling`, which has 2 columns: `id` and `hours`. For each row, you have to return 3 columns: `id`, `hours` and `liters` (not litres, it's a difference from the kata description)
~~~ | reference | def litres(time):
return time / / 2
| Keep Hydrated! | 582cb0224e56e068d800003c | [
"Algorithms",
"Mathematics",
"Fundamentals"
] | https://www.codewars.com/kata/582cb0224e56e068d800003c | 8 kyu |
Create a function that gives a personalized greeting. This function takes two parameters: `name` and `owner`.
Use conditionals to return the proper message:
case | return
--- | ---
name equals owner | 'Hello boss'
otherwise | 'Hello guest'
| reference | def greet(name, owner):
return "Hello boss" if name == owner else "Hello guest"
| Grasshopper - Personalized Message | 5772da22b89313a4d50012f7 | [
"Fundamentals",
"Strings"
] | https://www.codewars.com/kata/5772da22b89313a4d50012f7 | 8 kyu |
The fusc function is defined recursively as follows:
1. fusc(0) = 0
2. fusc(1) = 1
3. fusc(2 * n) = fusc(n)
4. fusc(2 * n + 1) = fusc(n) + fusc(n + 1)
The 4 rules above are sufficient to determine the value of `fusc` for any non-negative input `n`. For example, let's say you want to compute `fusc(10)`.
1. `fusc(10) = fusc(5)`, by rule 3.
2. `fusc(5) = fusc(2) + fusc(3)`, by rule 4.
3. `fusc(2) = fusc(1)`, by rule 3.
4. `fusc(1) = 1`, by rule 2.
5. `fusc(3) = fusc(1) + fusc(2)` by rule 4.
6. `fusc(1)` and `fusc(2)` have already been computed are both equal to `1`.
Putting these results together `fusc(10) = fusc(5) = fusc(2) + fusc(3) = 1 + 2 = 3`
Your job is to produce the code for the `fusc` function. In this kata, your function will be tested with small values of `n`, so you should not need to be concerned about stack overflow or timeouts.
Hint: Use recursion.
When done, move on to [Part 2](http://www.codewars.com/kata/the-fusc-function-part-2).
~~~if:lambdacalc
### Encodings
purity: `LetRec`
numEncoding: `BinaryScott`
~~~ | algorithms | def fusc(n):
assert type(n) == int and n >= 0
if n < 2:
return n
if n % 2 == 0:
return fusc(n / / 2)
else:
return fusc(n / / 2) + fusc(n / / 2 + 1)
| The fusc function -- Part 1 | 570409d3d80ec699af001bf9 | [
"Algorithms"
] | https://www.codewars.com/kata/570409d3d80ec699af001bf9 | 7 kyu |
~~~if-not:sql,shell
Create a function that takes an integer as an argument and returns `"Even"` for even numbers or `"Odd"` for odd numbers.
~~~
~~~if:sql
You will be given a table `numbers`, with one column `number`.</br>
Return a dataset with two columns: `number` and `is_even`, where `number` contains the original input value, and `is_even` containing `"Even"` or `"Odd"` depending on `number` column values.
### Numbers table schema
```text
* number INT
```
### Output table schema
```text
* number INT
* is_even STRING
```
~~~
~~~if:shell
Write a script that takes an integer as an argument and returns `"Even"` for even numbers or `"Odd"` for odd numbers.
~~~
| reference | def even_or_odd(number):
return 'Odd' if number % 2 else 'Even'
| Even or Odd | 53da3dbb4a5168369a0000fe | [
"Mathematics",
"Fundamentals"
] | https://www.codewars.com/kata/53da3dbb4a5168369a0000fe | 8 kyu |
Write a function named `setAlarm`/`set_alarm`/`set-alarm`/`setalarm` (depending on language) which receives two parameters. The first parameter, `employed`, is true whenever you are employed and the second parameter, `vacation` is true whenever you are on vacation.
The function should return true if you are employed and not on vacation (because these are the circumstances under which you need to set an alarm). It should return false otherwise. Examples:
```
employed | vacation
true | true => false
true | false => true
false | true => false
false | false => false
``` | reference | def set_alarm(employed, vacation):
return employed and not vacation
| L1: Set Alarm | 568dcc3c7f12767a62000038 | [
"Fundamentals",
"Logic"
] | https://www.codewars.com/kata/568dcc3c7f12767a62000038 | 8 kyu |
You and a friend have decided to play a game to drill your statistical intuitions. The game works like this:
You have a bunch of red and blue marbles. To start the game you grab a handful of marbles of each color and put them into the bag, keeping track of how many of each color go in. You take turns reaching into the bag, guessing a color, and then pulling one marble out. You get a point if you guessed correctly. The trick is you only have three seconds to make your guess, so you have to think quickly.
You've decided to write a function, `guessBlue()` to help automatically calculate whether you should guess "blue" or "red". The function should take four arguments:
* the number of blue marbles you put in the bag to start
* the number of red marbles you put in the bag to start
* the number of blue marbles pulled out so far (always lower than the starting number of blue marbles)
* the number of red marbles pulled out so far (always lower than the starting number of red marbles)
`guessBlue()` should return the probability of drawing a blue marble, expressed as a float. For example, `guessBlue(5, 5, 2, 3)` should return `0.6`. | reference | def guess_blue(blue_start, red_start, blue_pulled, red_pulled):
blue_remaining = blue_start - blue_pulled
red_remaining = red_start - red_pulled
return blue_remaining / (blue_remaining + red_remaining)
| Thinkful - Number Drills: Blue and red marbles | 5862f663b4e9d6f12b00003b | [
"Probability",
"Fundamentals"
] | https://www.codewars.com/kata/5862f663b4e9d6f12b00003b | 8 kyu |
Mr. Scrooge has a sum of money 'P' that he wants to invest. Before he does, he wants to know how many years 'Y' this sum 'P' has to be kept in the bank in order for it to amount to a desired sum of money 'D'.
The sum is kept for 'Y' years in the bank where interest 'I' is paid yearly. After paying taxes 'T' for the year the new sum is re-invested.
Note to Tax: not the invested principal is taxed, but only the year's accrued interest
Example:
Let P be the Principal = 1000.00
Let I be the Interest Rate = 0.05
Let T be the Tax Rate = 0.18
Let D be the Desired Sum = 1100.00
After 1st Year -->
P = 1041.00
After 2nd Year -->
P = 1083.86
After 3rd Year -->
P = 1128.30
Thus Mr. Scrooge has to wait for 3 years for the initial principal to amount to the desired sum.
Your task is to complete the method provided and return the number of years 'Y' as a whole in order for Mr. Scrooge to get the desired sum.
Assumption: Assume that Desired Principal 'D' is always greater than the initial principal. However it is best to take into consideration that if Desired Principal 'D' is equal to Principal 'P' this should return 0 Years. | reference | def calculate_years(principal, interest, tax, desired):
years = 0
while principal < desired:
principal += (interest * principal) * (1 - tax)
years += 1
return years
| Money, Money, Money | 563f037412e5ada593000114 | [
"Fundamentals"
] | https://www.codewars.com/kata/563f037412e5ada593000114 | 7 kyu |
Given an array of integers your solution should find the smallest integer.
For example:
- Given `[34, 15, 88, 2]` your solution will return `2`
- Given `[34, -345, -1, 100]` your solution will return `-345`
You can assume, for the purpose of this kata, that the supplied array will not be empty.
| reference | def findSmallestInt(arr):
return min(arr)
| Find the smallest integer in the array | 55a2d7ebe362935a210000b2 | [
"Fundamentals"
] | https://www.codewars.com/kata/55a2d7ebe362935a210000b2 | 8 kyu |
# Instructions
Given a mathematical expression as a string you must return the result as a number.
## Numbers
Number may be both whole numbers and/or decimal numbers. The same goes for the returned result.
## Operators
You need to support the following mathematical operators:
* Multiplication `*`
* Division `/` (as floating point division)
* Addition `+`
* Subtraction `-`
Operators are always evaluated from left-to-right, and `*` and `/` must be evaluated before `+` and `-`.
## Parentheses
You need to support multiple levels of nested parentheses, ex. `(2 / (2 + 3.33) * 4) - -6`
## Whitespace
There may or may not be whitespace between numbers and operators.
An addition to this rule is that the minus sign (`-`) used for negating numbers and parentheses will *never* be separated by whitespace. I.e all of the following are **valid** expressions.
```
1-1 // 0
1 -1 // 0
1- 1 // 0
1 - 1 // 0
1- -1 // 2
1 - -1 // 2
1--1 // 2
6 + -(4) // 2
6 + -( -4) // 10
```
And the following are **invalid** expressions
```
1 - - 1 // Invalid
1- - 1 // Invalid
6 + - (4) // Invalid
6 + -(- 4) // Invalid
```
## Validation
You do not need to worry about validation - you will only receive **valid** mathematical expressions following the above rules.
## Restricted APIs
```if:javascript
NOTE: Both `eval` and `Function` are disabled.
```
```if:php
NOTE: `eval` is disallowed in your solution.
```
```if:python
NOTE: `eval` and `exec` are disallowed in your solution.
```
```if:clojure
NOTE: `eval` and `import` are disallowed in your solution.
```
```if:java
NOTE: To keep up the difficulty of the kata, use of some classes and functions is disallowed. Their names cannot appear in the solution file, even in comments and variable names.
```
```if:rust
NOTE: `std::process::Command` is disallowed in your solution.
```
| algorithms | import re
from operator import mul, truediv as div, add, sub
OPS = {'*': mul, '/': div, '-': sub, '+': add}
def calc(expression):
tokens = re . findall(r'[.\d]+|[()+*/-]', expression)
return parse_AddSub(tokens, 0)[0]
def parse_AddSub(tokens, iTok):
v, iTok = parse_MulDiv(tokens, iTok)
while iTok < len(tokens) and tokens[iTok] != ')':
tok = tokens[iTok]
if tok in '-+':
v2, iTok = parse_MulDiv(tokens, iTok + 1)
v = OPS[tok](v, v2)
return v, iTok
def parse_MulDiv(tokens, iTok):
v, iTok = parse_Term(tokens, iTok)
while iTok < len(tokens) and tokens[iTok] in '*/':
op = tokens[iTok]
v2, iTok = parse_Term(tokens, iTok + 1)
v = OPS[op](v, v2)
return v, iTok
def parse_Term(tokens, iTok):
tok = tokens[iTok]
if tok == '(':
v, iTok = parse_AddSub(tokens, iTok + 1)
if iTok < len(tokens) and tokens[iTok] != ')':
raise Exception()
elif tok == '-':
v, iTok = parse_Term(tokens, iTok + 1)
v, iTok = - v, iTok - 1
else:
v = float(tok)
return v, iTok + 1
| Evaluate mathematical expression | 52a78825cdfc2cfc87000005 | [
"Mathematics",
"Parsing",
"Algorithms"
] | https://www.codewars.com/kata/52a78825cdfc2cfc87000005 | 2 kyu |
## Find Mean
Find the mean (average) of a list of numbers in an array.
## Information
To find the mean (average) of a set of numbers add all of the numbers together and divide by the number of values in the list.
For an example list of `1, 3, 5, 7`
<span>1.</span> Add all of the numbers
```
1+3+5+7 = 16
```
<span>2.</span> Divide by the number of values in the list. In this example there are 4 numbers in the list.
```
16/4 = 4
```
<span>3.</span> The mean (or average) of this list is 4 | reference | def find_average(nums):
return sum(nums) / len(nums) if nums else 0
| Grasshopper - Array Mean | 55d277882e139d0b6000005d | [
"Arrays",
"Lists",
"Fundamentals"
] | https://www.codewars.com/kata/55d277882e139d0b6000005d | 8 kyu |
Write a program that will calculate the number of trailing zeros in a factorial of a given number.
`N! = 1 * 2 * 3 * ... * N`
Be careful `1000!` has 2568 digits...
For more info, see: http://mathworld.wolfram.com/Factorial.html
## Examples
```python
zeros(6) = 1
# 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zero
zeros(12) = 2
# 12! = 479001600 --> 2 trailing zeros
```
*Hint: You're not meant to calculate the factorial. Find another way to find the number of zeros.* | algorithms | def zeros(n):
"""
No factorial is going to have fewer zeros than the factorial of a smaller
number.
Each multiple of 5 adds a 0, so first we count how many multiples of 5 are
smaller than `n` (`n // 5`).
Each multiple of 25 adds two 0's, so next we add another 0 for each multiple
of 25 smaller than n.
We continue on for all powers of 5 smaller than (or equal to) n.
"""
pow_of_5 = 5
zeros = 0
while n >= pow_of_5:
zeros += n / / pow_of_5
pow_of_5 *= 5
return zeros
| Number of trailing zeros of N! | 52f787eb172a8b4ae1000a34 | [
"Algorithms",
"Logic",
"Mathematics"
] | https://www.codewars.com/kata/52f787eb172a8b4ae1000a34 | 5 kyu |
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 number and there will always be at least 1 dog.
```agda
Good luck!
```
```r
The expected behaviour is as follows:
- Your friend has fewer than 10 dogs: "Hardly any"
- Your friend has at least 10 but fewer than 51 dogs: "More than a handful!"
- Your friend has at least 51 but not exactly 101 dogs: "Woah that's a lot of dogs!"
- Your friend has 101 dogs: "101 DALMATIANS!!!"
Your friend will always have between 1 and 101 dogs, inclusive.
``` | bug_fixes | def how_many_dalmatians(n):
dogs = ["Hardly any", "More than a handful!",
"Woah that's a lot of dogs!", "101 DALMATIONS!!!"]
return dogs[0] if n <= 10 else dogs[1] if n <= 50 else dogs[3] if n == 101 else dogs[2]
| 101 Dalmatians - squash the bugs, not the dogs! | 56f6919a6b88de18ff000b36 | [
"Debugging",
"Fundamentals"
] | https://www.codewars.com/kata/56f6919a6b88de18ff000b36 | 8 kyu |
Your classmates asked you to copy some paperwork for them. You know that there are 'n' classmates and the paperwork has 'm' pages.
Your task is to calculate how many blank pages do you need. If `n < 0` or `m < 0` return `0`.
### Example:
```
n= 5, m=5: 25
n=-5, m=5: 0
```
Waiting for translations and Feedback! Thanks!
| reference | def paperwork(n, m):
return n * m if n > 0 and m > 0 else 0
| Beginner Series #1 School Paperwork | 55f9b48403f6b87a7c0000bd | [
"Fundamentals"
] | https://www.codewars.com/kata/55f9b48403f6b87a7c0000bd | 8 kyu |
# How many ways can you make the sum of a number?
From wikipedia: https://en.wikipedia.org/wiki/Partition_(number_theory)
>In number theory and combinatorics, a partition of a positive integer *n*, also called an *integer partition*, is a way of writing n as a sum of positive integers. Two sums that differ only in the order of their summands are considered the same partition. If order matters, the sum becomes a composition. For example, 4 can be partitioned in five distinct ways:
```
4
3 + 1
2 + 2
2 + 1 + 1
1 + 1 + 1 + 1
```
## Examples
### Basic
```javascript
sum(1) // 1
sum(2) // 2 -> 1+1 , 2
sum(3) // 3 -> 1+1+1, 1+2, 3
sum(4) // 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
sum(5) // 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3
sum(10) // 42
```
```haskell
explosiveSum 1 -- 1
explosiveSum 2 -- 2 -> 1+1 , 2
explosiveSum 3 -- 3 -> 1+1+1, 1+2, 3
explosiveSum 4 -- 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
explosiveSum 5 -- 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3
explosiveSum 10 -- 42
```
```ruby
exp_sum(1) # 1
exp_sum(2) # 2 -> 1+1 , 2
exp_sum(3) # 3 -> 1+1+1, 1+2, 3
exp_sum(4) # 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
exp_sum(5) # 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3
exp_sum(10) # 42
```
```python
exp_sum(1) # 1
exp_sum(2) # 2 -> 1+1 , 2
exp_sum(3) # 3 -> 1+1+1, 1+2, 3
exp_sum(4) # 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
exp_sum(5) # 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3
exp_sum(10) # 42
```
```cpp
exp_sum(1) // 1
exp_sum(2) // 2 -> 1+1 , 2
exp_sum(3) // 3 -> 1+1+1, 1+2, 3
exp_sum(4) // 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
exp_sum(5) // 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3
exp_sum(10) // 42
```
```go
ExpSum(1) // 1
ExpSum(2) // 2 -> 1+1 , 2
ExpSum(3) // 3 -> 1+1+1, 1+2, 3
ExpSum(4) // 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
ExpSum(5) // 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3
ExpSum(10) // 42
```
```rust
exp_sum(1) // 1
exp_sum(2) // 2 -> 1+1 , 2
exp_sum(3) // 3 -> 1+1+1, 1+2, 3
exp_sum(4) // 5 -> 1+1+1+1, 1+1+2, 1+3, 2+2, 4
exp_sum(5) // 7 -> 1+1+1+1+1, 1+1+1+2, 1+1+3, 1+2+2, 1+4, 5, 2+3
exp_sum(10) // 42
```
### Explosive
```javascript
sum(50) // 204226
sum(80) // 15796476
sum(100) // 190569292
```
```haskell
explosiveSum 50 -- 204226
explosiveSum 80 -- 15796476
explosiveSum 100 -- 190569292
```
```ruby
exp_sum(50) # 204226
exp_sum(80) # 15796476
exp_sum(100) # 190569292
```
```python
exp_sum(50) # 204226
exp_sum(80) # 15796476
exp_sum(100) # 190569292
```
```cpp
exp_sum(50) // 204226
exp_sum(80) // 15796476
exp_sum(100) // 190569292
```
```go
ExpSum(50) // 204226
ExpSum(80) // 15796476
ExpSum(100) // 190569292
```
```rust
exp_sum(50) // 204226
exp_sum(80) // 15796476
exp_sum(100) // 190569292
```
See [here](http://www.numericana.com/data/partition.htm) for more examples.
| reference | ANSWERS = {
0: 1,
1: 1,
2: 2,
3: 3,
4: 5,
5: 7,
6: 11,
7: 15,
8: 22,
9: 30,
10: 42,
11: 56,
12: 77,
13: 101,
14: 135,
15: 176,
16: 231,
17: 297,
18: 385,
19: 490,
20: 627,
21: 792,
22: 1002,
23: 1255,
24: 1575,
25: 1958,
26: 2436,
27: 3010,
28: 3718,
29: 4565,
30: 5604,
31: 6842,
32: 8349,
33: 10143,
34: 12310,
35: 14883,
36: 17977,
37: 21637,
38: 26015,
39: 31185,
40: 37338,
41: 44583,
42: 53174,
43: 63261,
44: 75175,
45: 89134,
46: 105558,
47: 124754,
48: 147273,
49: 173525,
50: 204226,
51: 239943,
52: 281589,
53: 329931,
54: 386155,
55: 451276,
56: 526823,
57: 614154,
58: 715220,
59: 831820,
60: 966467,
61: 1121505,
62: 1300156,
63: 1505499,
64: 1741630,
65: 2012558,
66: 2323520,
67: 2679689,
68: 3087735,
69: 3554345,
70: 4087968,
71: 4697205,
72: 5392783,
73: 6185689,
74: 7089500,
75: 8118264,
76: 9289091,
77: 10619863,
78: 12132164,
79: 13848650,
80: 15796476,
81: 18004327,
82: 20506255,
83: 23338469,
84: 26543660,
85: 30167357,
86: 34262962,
87: 38887673,
88: 44108109,
89: 49995925,
90: 56634173,
91: 64112359,
92: 72533807,
93: 82010177,
94: 92669720,
95: 104651419,
96: 118114304,
97: 133230930,
98: 150198136,
99: 169229875,
100: 190569292,
101: 214481126,
102: 241265379,
103: 271248950,
104: 304801365,
105: 342325709,
106: 384276336,
107: 431149389,
108: 483502844,
109: 541946240,
110: 607163746,
111: 679903203,
112: 761002156,
113: 851376628,
114: 952050665,
115: 1064144451,
116: 1188908248,
117: 1327710076,
118: 1482074143,
119: 1653668665,
120: 1844349560,
121: 2056148051,
122: 2291320912,
123: 2552338241,
124: 2841940500,
125: 3163127352,
126: 3519222692,
127: 3913864295,
128: 4351078600,
129: 4835271870,
130: 5371315400,
131: 5964539504,
132: 6620830889,
133: 7346629512,
134: 8149040695,
135: 9035836076,
136: 10015581680,
137: 11097645016,
138: 12292341831,
139: 13610949895,
140: 15065878135,
141: 16670689208,
142: 18440293320,
143: 20390982757,
144: 22540654445,
145: 24908858009,
146: 27517052599,
147: 30388671978,
148: 33549419497,
149: 37027355200,
150: 40853235313,
151: 45060624582,
152: 49686288421,
153: 54770336324,
154: 60356673280,
155: 66493182097,
156: 73232243759,
157: 80630964769,
158: 88751778802,
159: 97662728555,
160: 107438159466,
161: 118159068427,
162: 129913904637,
163: 142798995930,
164: 156919475295,
165: 172389800255,
166: 189334822579,
167: 207890420102,
168: 228204732751,
169: 250438925115,
170: 274768617130,
171: 301384802048,
172: 330495499613,
173: 362326859895,
174: 397125074750,
175: 435157697830,
176: 476715857290,
177: 522115831195,
178: 571701605655,
179: 625846753120,
180: 684957390936,
181: 749474411781,
182: 819876908323,
183: 896684817527,
184: 980462880430,
185: 1071823774337,
186: 1171432692373,
187: 1280011042268,
188: 1398341745571,
189: 1527273599625,
190: 1667727404093,
191: 1820701100652,
192: 1987276856363,
193: 2168627105469,
194: 2366022741845,
195: 2580840212973,
196: 2814570987591,
197: 3068829878530,
198: 3345365983698,
199: 3646072432125,
200: 3972999029388,
201: 4328363658647,
202: 4714566886083,
203: 5134205287973,
204: 5590088317495,
205: 6085253859260,
206: 6622987708040,
207: 7206841706490,
208: 7840656226137,
209: 8528581302375,
210: 9275102575355,
211: 10085065885767,
212: 10963707205259,
213: 11916681236278,
214: 12950095925895,
215: 14070545699287,
216: 15285151248481,
217: 16601598107914,
218: 18028182516671,
219: 19573856161145,
220: 21248279009367,
221: 23061871173849,
222: 25025873760111,
223: 27152408925615,
224: 29454549941750,
225: 31946390696157,
226: 34643126322519,
227: 37561133582570,
228: 40718063627362,
229: 44132934884255,
230: 47826239745920,
231: 51820051838712,
232: 56138148670947,
233: 60806135438329,
234: 65851585970275,
235: 71304185514919,
236: 77195892663512,
237: 83561103925871,
238: 90436839668817,
239: 97862933703585,
240: 105882246722733,
241: 114540884553038,
242: 123888443077259,
243: 133978259344888,
244: 144867692496445,
245: 156618412527946,
246: 169296722391554,
247: 182973889854026,
248: 197726516681672,
249: 213636919820625,
250: 230793554364681,
251: 249291451168559,
252: 269232701252579,
253: 290726957916112,
254: 313891991306665,
255: 338854264248680,
256: 365749566870782,
257: 394723676655357,
258: 425933084409356,
259: 459545750448675,
260: 495741934760846,
261: 534715062908609,
262: 576672674947168,
263: 621837416509615,
264: 670448123060170,
265: 722760953690372,
266: 779050629562167,
267: 839611730366814,
268: 904760108316360,
269: 974834369944625,
270: 1050197489931117,
271: 1131238503938606,
272: 1218374349844333,
273: 1312051800816215,
274: 1412749565173450,
275: 1520980492851175,
276: 1637293969337171,
277: 1762278433057269,
278: 1896564103591584,
279: 2040825852575075,
280: 2195786311682516,
281: 2362219145337711,
282: 2540952590045698,
283: 2732873183547535,
284: 2938929793929555,
285: 3160137867148997,
286: 3397584011986773,
287: 3652430836071053,
288: 3925922161489422,
289: 4219388528587095,
290: 4534253126900886,
291: 4872038056472084,
292: 5234371069753672,
293: 5622992691950605,
294: 6039763882095515,
295: 6486674127079088,
296: 6965850144195831,
297: 7479565078510584,
298: 8030248384943040,
299: 8620496275465025,
300: 9253082936723602,
301: 9930972392403501,
302: 10657331232548839,
303: 11435542077822104,
304: 12269218019229465,
305: 13162217895057704,
306: 14118662665280005,
307: 15142952738857194,
308: 16239786535829663,
309: 17414180133147295,
310: 18671488299600364,
311: 20017426762576945,
312: 21458096037352891,
313: 23000006655487337,
314: 24650106150830490,
315: 26415807633566326,
316: 28305020340996003,
317: 30326181989842964,
318: 32488293351466654,
319: 34800954869440830,
320: 37274405776748077,
321: 39919565526999991,
322: 42748078035954696,
323: 45772358543578028,
324: 49005643635237875,
325: 52462044228828641,
326: 56156602112874289,
327: 60105349839666544,
328: 64325374609114550,
329: 68834885946073850,
330: 73653287861850339,
331: 78801255302666615,
332: 84300815636225119,
333: 90175434980549623,
334: 96450110192202760,
335: 103151466321735325,
336: 110307860425292772,
337: 117949491546113972,
338: 126108517833796355,
339: 134819180623301520,
340: 144117936527873832,
341: 154043597379576030,
342: 164637479165761044,
343: 175943559810422753,
344: 188008647052292980,
345: 200882556287683159,
346: 214618299743286299,
347: 229272286871217150,
348: 244904537455382406,
349: 261578907351144125,
350: 279363328483702152,
351: 298330063062758076,
352: 318555973788329084,
353: 340122810048577428,
354: 363117512048110005,
355: 387632532919029223,
356: 413766180933342362,
357: 441622981929358437,
358: 471314064268398780,
359: 502957566506000020,
360: 536679070310691121,
361: 572612058898037559,
362: 610898403751884101,
363: 651688879997206959,
364: 695143713458946040,
365: 741433159884081684,
366: 790738119649411319,
367: 843250788562528427,
368: 899175348396088349,
369: 958728697912338045,
370: 1022141228367345362,
371: 1089657644424399782,
372: 1161537834849962850,
373: 1238057794119125085,
374: 1319510599727473500,
375: 1406207446561484054,
376: 1498478743590581081,
377: 1596675274490756791,
378: 1701169427975813525,
379: 1812356499739472950,
380: 1930656072350465812,
381: 2056513475336633805,
382: 2190401332423765131,
383: 2332821198543892336,
384: 2484305294265418180,
385: 2645418340688763701,
386: 2816759503217942792,
387: 2998964447736452194,
388: 3192707518433532826,
389: 3398704041358160275,
390: 3617712763867604423,
391: 3850538434667429186,
392: 4098034535626594791,
393: 4361106170762284114,
394: 4640713124699623515,
395: 4937873096788191655,
396: 5253665124416975163,
397: 5589233202595404488,
398: 5945790114707874597,
399: 6324621482504294325,
400: 6727090051741041926,
401: 7154640222653942321,
402: 7608802843339879269,
403: 8091200276484465581,
404: 8603551759348655060,
405: 9147679068859117602,
406: 9725512513742021729,
407: 10339097267123947241,
408: 10990600063775926994,
409: 11682316277192317780,
410: 12416677403151190382,
411: 13196258966925435702,
412: 14023788883518847344,
413: 14902156290309948968,
414: 15834420884488187770,
415: 16823822787139235544,
416: 17873792969689876004,
417: 18987964267331664557,
418: 20170183018805933659,
419: 21424521360255636320,
420: 22755290216580025259,
421: 24167053021441363961,
422: 25664640213837714846,
423: 27253164546230421739,
424: 28938037257084798150,
425: 30724985147095051099,
426: 32620068617410232189,
427: 34629700713903575934,
428: 36760667241831527309,
429: 39020148000237259665,
430: 41415739207102358378,
431: 43955477170518116534,
432: 46647863284229267991,
433: 49501890409405150715,
434: 52527070729108240605,
435: 55733465144636286656,
436: 59131714309169618645,
437: 62733071376043079215,
438: 66549436566966297367,
439: 70593393646562135510,
440: 74878248419470886233,
441: 79418069346443402240,
442: 84227730407729499781,
443: 89322956321353645667,
444: 94720370257893471820,
445: 100437544171752847604,
446: 106493051905239118581,
447: 112906525199196103354,
448: 119698712782720205954,
449: 126891542690981418000,
450: 134508188001572923840,
451: 142573136155347404229,
452: 151112262071917313678,
453: 160152905244553715585,
454: 169723951046458040965,
455: 179855916453958267598,
456: 190581040442651931034,
457: 201933379285114688629,
458: 213948907032733069132,
459: 226665621435831345565,
460: 240123655613925192081,
461: 254365395758574199975,
462: 269435605212954994471,
463: 285381555241961986287,
464: 302253162872576636605,
465: 320103136152993290544,
466: 338987127249525432549,
467: 358963893768162876613,
468: 380095468763120598477,
469: 402447339861711475160,
470: 426088638015652413417,
471: 451092336355096099864,
472: 477535459708164115593,
473: 505499305314204629558,
474: 535069675351607262125,
475: 566337121865805599675,
476: 599397204782301852926,
477: 634350763653787028583,
478: 671304203896731807232,
479: 710369798236628238005,
480: 751666004194993125591,
481: 795317798414758232180,
482: 841457028742823649455,
483: 890222784951928088294,
484: 941761789114997698055,
485: 996228806608573411012,
486: 1053787078862455346513,
487: 1114608778936426484248,
488: 1178875491155735802646,
489: 1246778716001272919665,
490: 1318520401612270233223,
491: 1394313503224447816939,
492: 1474382572040363953132,
493: 1558964374994977806173,
494: 1648308547066172438760,
495: 1742678277747760981187,
496: 1842351033503159891466,
497: 1947619317987658064007,
498: 2058791472042884901563,
499: 2176192515439287461625,
500: 2300165032574323995027,
501: 2431070104309287327876,
502: 2569288288377098289281,
503: 2715220650772245313220,
504: 2869289850802400662045,
505: 3031941282464413132742,
506: 3203644275096202070012,
507: 3384893356244349844341,
508: 3576209579998154653671,
509: 3778141924035171537110,
510: 3991268758958164118300,
511: 4216199393504640098482,
512: 4453575699570940947378,
513: 4704073821002175842062,
514: 4968405970488126319775,
515: 5247322318923878793976,
516: 5541612982013113936133,
517: 5852110108921301661040,
518: 6179690078238084808000,
519: 6525275806549652788115,
520: 6889839175409542385648,
521: 7274403582551733377346,
522: 7680046623716094332553,
523: 8107902911527474124146,
524: 8559167038437716736150,
525: 9035096690829005915201,
526: 9537015921990240021538,
527: 10066318591787500106586,
528: 10624471981512075020731,
529: 11213020592521695111580,
530: 11833590138006300416410,
531: 12487891737367521803652,
532: 13177726323474524612308,
533: 13904989273245567335012,
534: 14671675272840783232475,
535: 15479883428970761068959,
536: 16331822638729701493803,
537: 17229817230617210720599,
538: 18176312890390861435034,
539: 19173882885687454484110,
540: 20225234604409151266221,
541: 21333216422211708570598,
542: 22500824915577356165493,
543: 23731212437346370138355,
544: 25027695072821279146420,
545: 26393760995005382968154,
546: 27833079238879849385687,
547: 29349508915133986374841,
548: 30947108885217475101876,
549: 32630147920163234060900,
550: 34403115367205050943160,
551: 36270732348871285128752,
552: 38237963520943177237554,
553: 40310029416409244587122,
554: 42492419404397720872600,
555: 44790905293907018009131,
556: 47211555614160398040338,
557: 49760750604354432757376,
558: 52445197947746313627407,
559: 55271949286085137715955,
560: 58248417552751868050007,
561: 61382395164161775318496,
562: 64682073111542943380454,
563: 68156060996536236172174,
564: 71813408056839596203570,
565: 75663625229609055443637,
566: 79716708303343130521599,
567: 83983162210640880002321,
568: 88474026517495817981253,
569: 93200902166643654187580,
570: 98175979536033971312388,
571: 103412067875563710992446,
572: 108922626189067392956037,
573: 114721795630860408658491,
574: 120824433490320564237125,
575: 127246148840551966562301,
576: 134003339931725153597473,
577: 141113233412529912746558,
578: 148593925468119890197615,
579: 156464424966082817448060,
580: 164744698707340387584240,
581: 173455718882380096095248,
582: 182619512839056823919887,
583: 192259215272078129526277,
584: 202399122950629095580175,
585: 213064752104884207160129,
586: 224282898599046831034631,
587: 236081701023305130945921,
588: 248490706844586261413858,
589: 261540941761240642265710,
590: 275264982414934173206642,
591: 289697032618827122974972,
592: 304873003269975366031783,
593: 320830596120295386610807,
594: 337609391590065169560935,
595: 355250940815002702558187,
596: 373798862128436852709430,
597: 393298942187883251157044,
598: 413799241966727832978027,
599: 435350207840317348270000,
600: 458004788008144308553622,
601: 481818554503286362923739,
602: 506849831053734861481872,
603: 533159827070679866278987,
604: 560812778053476538349420,
605: 589876092712502332463864,
606: 620420507127059714307352,
607: 652520246268116112057164,
608: 686253193233019826880477,
609: 721701066553229757379480,
610: 758949605954969709105721,
611: 798088766967999186006767,
612: 839212924798226411060795,
613: 882421087896683264554175,
614: 927817121679723721849795,
615: 975509982873756796925504,
616: 1025613964982134990453294,
617: 1078248955392080004474789,
618: 1133540704665979618906662,
619: 1191621108583631746910145,
620: 1252628503530795506440909,
621: 1316707975853817969920561,
622: 1384011685831426958558879,
623: 1454699206941558115141676,
624: 1528937881135168275063375,
625: 1606903190858354689128371,
626: 1688779148601189609516729,
627: 1774758704783877366657989,
628: 1865044174831202682776536,
629: 1959847686321528964669495,
630: 2059391647140527228529479,
631: 2163909235608484556362424,
632: 2273644913597837330081136,
633: 2388854963699932382735982,
634: 2509808051552031608082535,
635: 2636785814481962651219075,
636: 2770083477684418110395121,
637: 2910010499193691843303014,
638: 3056891244979232231862474,
639: 3211065695545980277248740,
640: 3372890185488482409685019,
641: 3542738177508596708707874,
642: 3721001072479541451508397,
643: 3908089057205582486668934,
644: 4104431991606013700457110,
645: 4310480337124871462076948,
646: 4526706128254173781044298,
647: 4753603989138067267826945,
648: 4991692197319220372390544,
649: 5241513796775816319683700,
650: 5503637762499727151307095,
651: 5778660218961559003723580,
652: 6067205714919484306343541,
653: 6369928557132709817142929,
654: 6687514205661440172553650,
655: 7020680733548749464953877,
656: 7370180353811425547662139,
657: 7736801016790889035132284,
658: 8121368081058512888507057,
659: 8524746061205131302394950,
660: 8947840456000332817673697,
661: 9391599660555044587641517,
662: 9857016966290401433259592,
663: 10345132652677367520056676,
664: 10857036174895938656583295,
665: 11393868451739000294452939,
666: 11956824258286445517629485,
667: 12547154728067493595502055,
668: 13166169969647255482980383,
669: 13815241802783448943206160,
670: 14495806619536377005379418,
671: 15209368375944215483241988,
672: 15957501720133631304230773,
673: 16741855262985451980947171,
674: 17564154997755650263621500,
675: 18426207875324210441995136,
676: 19329905542049511423199336,
677: 20277228247502764885900784,
678: 21270248929688765106878025,
679: 22311137485682880566295780,
680: 23402165235974892374954302,
681: 24545709591163085124246501,
682: 25744258930034131533263392,
683: 27000417698448800353553865,
684: 28316911738879831363625420,
685: 29696593860867277871605321,
686: 31142449663120060247020395,
687: 32657603618448918933404658,
688: 34245325433219728719773420,
689: 35909036693513349075724695,
690: 37652317810725762600765183,
691: 39478915279883795756623331,
692: 41392749264546866860893416,
693: 43397921522754943172592795,
694: 45498723689129703063649450,
695: 47699645928878027716139269,
696: 50005385980149860746062163,
697: 52420858601901549459658530,
698: 54951205445179608281719072,
699: 57601805366500810491219000,
700: 60378285202834474611028659,
701: 63286531028521032840985510,
702: 66332699915362724119980694,
703: 69523232218023552371152320,
704: 72864864407855341219969825,
705: 76364642479247406973532354,
706: 80029935953661656574123574,
707: 83868452507581852374822598,
708: 87888253251761884175130183,
709: 92097768690318501305952845,
710: 96505815389469697877049934,
711: 101121613386982294887579670,
712: 105954804374756131323439197,
713: 111015470688345108146850290,
714: 116314155138696524440183805,
715: 121861881722882938654960142,
716: 127670177252209281782740521,
717: 133751093937700984130081285,
718: 140117232974725477106760252,
719: 146781769170263852819573505,
720: 153758476658245881594406593,
721: 161061755750279477635534762,
722: 168706660971164630122439117,
723: 176708930330666271859881567,
724: 185085015885255746880625875,
725: 193852115645795752984189381,
726: 203028206889569986197651315,
727: 212632080937520072186590492,
728: 222683379460186024851577401,
729: 233202632378520643600875145,
730: 244211297428606706709925517,
731: 255731801462210865865001525,
732: 267787583558210323920375877,
733: 280403140023083872114273884,
734: 293604071362025285843562670,
735: 307417131305664218954016427,
736: 321870277981032622582593573,
737: 336992727319136467572139095,
738: 352815008795455957133215652,
739: 369369023603738655757458075,
740: 386688105367749941220651375,
741: 404807083500032850651734059,
742: 423762349321394151918928481,
743: 443591925059596733749014862,
744: 464335535850798483634138280,
745: 486034684872448271784326296,
746: 508732731741838107613602755,
747: 532474974320122372524707631,
748: 557308734067567635805394638,
749: 583283445101886813536239875,
750: 610450747117966916191771809,
751: 638864582333908382360557376,
752: 668581296635294279311393900,
753: 699659745096778286894322787,
754: 732161402067670820574405230,
755: 766150476015982127183457373,
756: 801694029333610862568750951,
757: 838862103313805798709299373,
758: 877727848520950325159242658,
759: 918367660781873199488134935,
760: 960861323037560814483873080,
761: 1005292153304074193879898920,
762: 1051747159001957690209588887,
763: 1100317197924192833923669753,
764: 1151097146124113726578727360,
765: 1204186073016375022219516992,
766: 1259687423996378387111229150,
767: 1317709210896221493178043552,
768: 1378364210608578997366598385,
769: 1441770172223648126550509165,
770: 1508050033038752490738311726,
771: 1577332143815074048889599022,
772: 1649750503671651735806603894,
773: 1725445005022910006140645612,
774: 1804561688982956164492944650,
775: 1887253011677361609828822380,
776: 1973678121921532286407950000,
777: 2064003150743712843868729636,
778: 2158401513250589964731360493,
779: 2257054223353982965849642005,
780: 2360150221898687182164777966,
781: 2467886718753771981901721670,
782: 2580469549453004933593920862,
783: 2698113546994164480174756373,
784: 2821042929432312216467202070,
785: 2949491703928193388274450292,
786: 3083704087940340693022764503,
787: 3223934948277725160271634798,
788: 3370450258759473520427114109,
789: 3523527577258789108163787100,
790: 3683456542940343404363084600,
791: 3850539394533563994343413787,
792: 4025091510519029370421431033,
793: 4207441972141088280734057870,
794: 4397934150197476827913759850,
795: 4596926316595586652827474186,
796: 4804792281705797515062559743,
797: 5021922058584382849328869242,
798: 5248722555182613689484387822,
799: 5485618295704258477069984050,
800: 5733052172321422504456911979,
801: 5991486228508002426815719537,
802: 6261402475301701333080509487,
803: 6543303741858946450905285538,
804: 6837714561722963378455094385,
805: 7145182096283051986707103605,
806: 7466277096963606051213804496,
807: 7801594907743960700949000443,
808: 8151756509675604512522473567,
809: 8517409609130970421571757565,
810: 8899229771588828461969917962,
811: 9297921602834531195851268718,
812: 9714219979529959777862768265,
813: 10148891331187245215547993864,
814: 10602734975663191221223594155,
815: 11076584510377034355391142064,
816: 11571309261543787320061392679,
817: 12087815793808125625662163707,
818: 12627049482760689878061744701,
819: 13189996152918959195978870030,
820: 13777683783859651786576215682,
821: 14391184287298069419105856949,
822: 15031615358023124634594092724,
823: 15700142401714084441377203063,
824: 16397980542787591098996821750,
825: 17126396715550358417594267021,
826: 17886711842065410771034749979,
827: 18680303100276877491522988120,
828: 19508606286081561360311437674,
829: 20373118273183778133458320225,
830: 21275399574724765449983360003,
831: 22217077010838260632179411313,
832: 23199846486451169343993151122,
833: 24225475883821531494697782922,
834: 25295808074486832813101046425,
835: 26412764055483014097178757689,
836: 27578346214889968804237171486,
837: 28794641731961759722351371983,
838: 30063826117310982372086476080,
839: 31388166898835484452139885750,
840: 32770027459303858556350798600,
841: 34211871031752548278772284453,
842: 35716264859093977687647313415,
843: 37285884524590579748861394570,
844: 38923518460115987806848673270,
845: 40632072639400673752129300324,
846: 42414575463747094337180792099,
847: 44274182847997609942310578598,
848: 46214183514849300594196193732,
849: 48238004505931946889525421000,
850: 50349216918401212177548479675,
851: 52551541876147039010384562987,
852: 54848856745079917639394818823,
853: 57245201602333536237114022805,
854: 59744785969613964515539259105,
855: 62351995821331449988466091712,
856: 65071400878573831543609957267,
857: 67907762200418949875852866531,
858: 70866040084540107092698343096,
859: 73951402289532005957331751320,
860: 77169232591877674590168543277,
861: 80525139690988018278755885205,
862: 84024966476277979232856334449,
863: 87674799670795146675673859587,
864: 91480979866491345649258758095,
865: 95450111966823518214883921610,
866: 99589076052990565170686659417,
867: 103905038690755971019484297576,
868: 108405464695475636367939373595,
869: 113098129373644577851404473535,
870: 117991131259998859170817958839,
871: 123092905369958432777075796052,
872: 128412236987976529870072690275,
873: 133958276013169939669531019316,
874: 139740551884446204479331411000,
875: 145768989108216487062234772851,
876: 152053923412691097170490155923,
877: 158606118553696417431847045996,
878: 165436783797931931934295220337,
879: 172557592110602218633091543840,
880: 179980699075416049556058362840,
881: 187718762576041099642814429720,
882: 195784963269243383580949581161,
883: 204193025881123335512830178821,
884: 212957241359090878236182734445,
885: 222092489913497780851227603386,
886: 231614264984172822820073009257,
887: 241538698168481624527315178361,
888: 251882585148964518765460484674,
889: 262663412660090356154504995095,
890: 273899386535208029575034561337,
891: 285609460876378579895067651923,
892: 297813368391435715163322531331,
893: 310531651944349233813920512829,
894: 323785697366761254448562966675,
895: 337597767580427105501057917306,
896: 351991038082228660789452118410,
897: 366989633845435601723754690835,
898: 382618667692977386826261193199,
899: 398904280200653395819254517900,
900: 415873681190459054784114365430,
901: 433555192876539531087229255477,
902: 451978294728708525214023001725,
903: 471173670120985588372050797999,
904: 491173254835220446432862090800,
905: 512010287492584845146484412308,
906: 533719361988531136324395159455,
907: 556336482009740068071399064008,
908: 579899117714618242279047917300,
909: 604446264662056374189988834755,
910: 630018505076433611630379753807,
911: 656658071540248718776792346785,
912: 684408913209287275550344075013,
913: 713316764648893234122621625751,
914: 743429217393715213042975617565,
915: 774795794337240928934816284899,
916: 807468027061529837515792402675,
917: 841499536221802614337232047468,
918: 876946115104959930393838357571,
919: 913865816485680423486405066750,
920: 952319042908502961911588247808,
921: 992368640529229737341624411924,
922: 1034079996654109332431762911842,
923: 1077521141120571341397403386532,
924: 1122762851668802145076610697775,
925: 1169878763459173895733432737528,
926: 1218945482896482311379736998403,
927: 1270042705928112564209840426896,
928: 1323253340989653981276400185806,
929: 1378663636778122744608506419570,
930: 1436363315039845896899358328033,
931: 1496445708567209282036578487803,
932: 1559007904605896258842021462474,
933: 1624150893881942976244820893255,
934: 1691979725465930503404211099660,
935: 1762603667699924360130192603237,
936: 1836136375421380008668856717532,
937: 1912696063727159213943851080855,
938: 1992405688530070149968413761596,
939: 2075393134169954709485716047155,
940: 2161791408351324312330912522447,
941: 2251738844689892053427982289844,
942: 2345379313161090374436414551558,
943: 2442862438754801545567295092897,
944: 2544343828652090726779455860435,
945: 2649985308251720770267133439311,
946: 2759955166386673475403099789409,
947: 2874428410083806869907819978392,
948: 2993587029233173241168779714732,
949: 3117620271547411926979127053250,
950: 3246724928206047105940972859506,
951: 3381105630594468612010288127863,
952: 3520975158562887897616477410546,
953: 3666554760646647127956344306190,
954: 3818074486705953843294627812035,
955: 3975773533460423034845675035419,
956: 4139900603411771887815710365915,
957: 4310714277666637214536144927329,
958: 4488483403190813123215639907302,
959: 4673487495046245204241629451110,
960: 4866017154182911354694265206413,
961: 5066374501379277964399166419563,
962: 5274873627947390097986152243705,
963: 5491841063841846500452896053582,
964: 5717616263835974099255567733750,
965: 5952552112453464578853008309794,
966: 6197015448369619941842104648894,
967: 6451387609023188709970129910797,
968: 6716064996207615136996693074302,
969: 6991459663439386169435859778910,
970: 7277999925931103886207676505429,
971: 7576130994027952290703815097177,
972: 7886315630998429231248733036419,
973: 8209034836103596418058528755338,
974: 8544788553903729460741526714750,
975: 8894096410797147287955714755082,
976: 9257498479823236816318777820416,
977: 9635556074800288403768986034253,
978: 10028852574908795418824727341746,
979: 10437994280872373856676062879735,
980: 10863611303931504965592652844878,
981: 11306358488849924787366667765407,
982: 11766916372239763961801564990016,
983: 12245992177539511607834487453052,
984: 12744320848028628464246059627690,
985: 13262666119314202551196742822008,
986: 13801821632778520931079437719552,
987: 14362612091531863067120268402228,
988: 14945894460472306341153073892017,
989: 15552559212113915719970799358900,
990: 16183531619906475296861224625027,
991: 16839773100833956878604913215477,
992: 17522282609145324707635966077022,
993: 18232098083140097717852712346115,
994: 18970297947002453464660671155990,
995: 19738002669751617842096992232436,
996: 20536376383452971700767593594021,
997: 21366628562913781584556907794729,
998: 22230015769169865076825741905555,
999: 23127843459154899464880444632250,
1000: 24061467864032622473692149727991,
1001: 25032297938763929621013218349796,
1002: 26041797385576000582369625213281,
1003: 27091486754099167408984061096127,
1004: 28182945621039436811282417218990,
1005: 29317814852360484763188469380980,
1006: 30497798951058731380716134731126,
1007: 31724668493728872881006491578226,
1008: 33000262659235183814081519827753,
1009: 34326491852926110526276105821510,
1010: 35705340429956356495500048880518,
1011: 37138869521411924622451440267117,
1012: 38629219967069644267226780200798,
1013: 40178615358763694337831877170404,
1014: 41789365198477765393682507986660,
1015: 43463868175432916528376380161993,
1016: 45204615566598118821992112719830,
1017: 47014194765213080671467587361162,
1018: 48895292942081479136595740785155,
1019: 50850700844567331975836762416180,
1020: 52883316738408211899530127054215,
1021: 54996150497646497195116039121846,
1022: 57192327848174163803231700285962,
1023: 59475094770587936660132803278445,
1024: 61847822068260244309086870983975,
1025: 64314010106747559065438412709786,
1026: 66877293730881687431325192921834,
1027: 69541447366121616918816177545634,
1028: 72310390310983979753319152713934,
1029: 75188192227619293524858181464065,
1030: 78179078837859260757658669457252,
1031: 81287437832327804842152878336251,
1032: 84517825000485590628268677129623,
1033: 87874970589764795726619149717517,
1034: 91363785902248291467082481888195,
1035: 94989370137655453801161398756590,
1036: 98757017491716010698603869808070,
1037: 102672224519343960454073227246547,
1038: 106740697772366151410092496101554,
1039: 110968361721914939732387042839470,
1040: 115361366975961956826368092270559,
1041: 119926098802850790583643914139778,
1042: 124669185972080868004022654618279,
1043: 129597509924003418690815024769614,
1044: 134718214280513689012974236132740,
1045: 140038714709261994367964528304147,
1046: 145566709154360370820516947589011,
1047: 151310188447031979898125505211430,
1048: 157277447310137702096803724432844,
1049: 163477095771019024080265786609550,
1050: 169918070997619096807349078318498,
1051: 176609649573385253852206425342508,
1052: 183561460227017093724267411668558,
1053: 190783497033705025399011223174627,
1054: 198286133105105766051740791002035,
1055: 206080134785924286913455951259466,
1056: 214176676375616994965530422655441,
1057: 222587355394399185288134561600051,
1058: 231324208413431926871476886628488,
1059: 240399727469780275150398352541295,
1060: 249826877087477024806306436682550,
1061: 259619111926794902903903858282467,
1062: 269790395084626208521306859330203,
1063: 280355217069693265922512204254601,
1064: 291328615477166797747643128851965,
1065: 302726195388153340970512449363108,
1066: 314564150520428320398942429589829,
1067: 326859285157739328217944658021195,
1068: 339629036885985812650521091739503,
1069: 352891500165597792693064105229860,
1070: 366665450770488753893927654278831,
1071: 380970371125047658469252263285168,
1072: 395826476571763477972460354798893,
1073: 411254742603244027745802489871124,
1074: 427276933093600703409672633110750,
1075: 443915629565423279460548833975619,
1076: 461194261529865886819548193737883,
1077: 479137137938708024340405275972933,
1078: 497769479788644748304553495300446,
1079: 517117453919499510741582247311995,
1080: 537208208049543370281513128274546,
1081: 558069907092647074919064078269009,
1082: 579731770803589829653889090465310,
1083: 602224112799502127836867703068534,
1084: 625578381007131993715400129218655,
1085: 649827199587396195485096741151797,
1086: 675004412390512738195023734124239,
1087: 701145127996910209394091171983043,
1088: 728285766401075776846633724874013,
1089: 756464107397538946738052845597325,
1090: 785719340730295196686468011045384,
1091: 816092118069154575020287144949660,
1092: 847624606878758096201928227674051,
1093: 880360546248341702038727418718373,
1094: 914345304752746677204951178080640,
1095: 949625940417679322961779585842763,
1096: 986251262864814583017230902369159,
1097: 1024271897715020987348060381346241,
1098: 1063740353330761125682320075116819,
1099: 1104711089981595892462307006170625,
1100: 1147240591519695580043346988281283,
1101: 1191387439655339764253910592315288,
1102: 1237212390925574690626025966996290,
1103: 1284778456452494990829233226377379,
1104: 1334150984591030161739618104847170,
1105: 1385397746569649033264079085023363,
1106: 1438589025231051837956193683375282,
1107: 1493797706983703451005350179037500,
1108: 1551099377078977592324977502565855,
1109: 1610572418332734533482318570551190,
1110: 1672298113414349146588255526290127,
1111: 1736360750830546535004742869861557,
1112: 1802847734735894350158767668809929,
1113: 1871849698706449115822481531031302,
1114: 1943460623617864164855763103650900,
1115: 2017777959774244383161311335135412,
1116: 2094902753439183950276117590000925,
1117: 2174939777925753277977786731439319,
1118: 2257997669407716887103312005936867,
1119: 2344189067619971039484826726136835,
1120: 2433630761622095504505007624351926,
1121: 2526443840805024325560621670846260,
1122: 2622753851327163276606626468293628,
1123: 2722690958172823755991785784326387,
1124: 2826390113032612069265970456163500,
1125: 2933991228212416784843441604124699,
1126: 3045639356784883554548008634432380,
1127: 3161484879204764376319516386806829,
1128: 3281683696617285755657387337131749,
1129: 3406397431096706053660787897070925,
1130: 3535793633060536116646611744883745,
1131: 3670045996113488118329838058723628,
1132: 3809334579584105681944821254585338,
1133: 3953846039026223475533484851711932,
1134: 4103773864966917551549475742004630,
1135: 4259318630192449100691154502765975,
1136: 4420688245873885709566584952625897,
1137: 4588098226844616747507844508037264,
1138: 4761771966352875646576237849731855,
1139: 4941941020623653451737160975884815,
1140: 5128845403576048431946742302750170,
1141: 5322733892054158457915227866236060,
1142: 5523864341942100491068450472029219,
1143: 5732504015546648477080676455520535,
1144: 5948929920644332374606657683899745,
1145: 6173429161603651508297858791951031,
1146: 6406299303007341112943259722223788,
1147: 6647848746214407376439536432805536,
1148: 6898397119316930779355317551024978,
1149: 7158275680962446691834888697663475,
1150: 7427827738529064471293660118664110,
1151: 7707409081157399483953096394984678,
1152: 7997388428160886234821473483000555,
1153: 8298147893354134143293856722998488,
1154: 8610083465857701451154337181278065,
1155: 8933605507957017621037375468973282,
1156: 9269139270613202791504126859283685,
1157: 9617125427244236129299819591578718,
1158: 9978020626416337178370164768812546,
1159: 10352298064107568778430054733760345,
1160: 10740448076228572334937735566562385,
1161: 11142978752109030998555590333304243,
1162: 11560416569682950887414131083801684,
1163: 11993307053131181401163436777097233,
1164: 12442215453765791987839842332792770,
1165: 12907727454968012800119940123354311,
1166: 13390449902019461518054086533162960,
1167: 13891011557695348536983250121102793,
1168: 14410063884518310798493113995825913,
1169: 14948281854602503175542820411276425,
1170: 15506364788049610799716682308517542,
1171: 16085037220891570656183958875514689,
1172: 16685049803609043819824168449851071,
1173: 17307180231290097851615771678718278,
1174: 17952234206530182283975172821446800,
1175: 18621046436212348314484589328413725,
1176: 19314481663345819649385158162679300,
1177: 20033435735181507108244024178275807,
1178: 20778836708864920831259413450679734,
1179: 21551645995930215818617016034137500,
1180: 22352859546983857840754489692613399,
1181: 23183509077972665661421886007454584,
1182: 24044663339478824029548767493555588,
1183: 24937429430533921473492651656959612,
1184: 25862954158495203059166455452470495,
1185: 26822425446580095904068198565803164,
1186: 27817073790709723558345700246365971,
1187: 28848173767368633057992125893483779,
1188: 29917045594246378653834785571179351,
1189: 31025056745487001593014803461929555,
1190: 32173623623434883211416744742294747,
1191: 33364213288829995905464566634140396,
1192: 34598345251472305106432161856883007,
1193: 35877593323444056632515580254383154,
1194: 37203587537049994338271609307035630,
1195: 38578016129709269105524749061283955,
1196: 40002627598109003613035027587346239,
1197: 41479232824008249429294178038617951,
1198: 43009707274162500911950054844789890,
1199: 44595993276923101114218051405894000,
1200: 46240102378152881298913555099661657,
1201: 47944117779189310556261099429006223,
1202: 49710196859679394486867802358932901,
1203: 51540573788206651013836802198036893,
1204: 53437562223729812777303406841914935,
1205: 55403558110955564979344325681437822,
1206: 57441042572873737644094937785113022,
1207: 59552584903793044889004529388335732,
1208: 61740845666328821093587961517238033,
1209: 64008579895911365238424857597692590,
1210: 66358640416504598253672231293216761,
1211: 68793981271349892486345394543503614,
1212: 71317661272679283934970057444157431,
1213: 73932847674475963853859804733408932,
1214: 76642819972498112301511348487927130,
1215: 79450973835924928534740056571220837,
1216: 82360825175131287067719845184002304,
1217: 85376014350249959857626768802856615,
1218: 88500310525337959944194241004565748,
1219: 91737616173126446538485123122674660,
1220: 95091971735501962459496140992085663,
1221: 98567560445040729668418191983592407,
1222: 102168713313097495533124764187939944,
1223: 105899914290136190948927875636615483,
1224: 109765805604181632042444034426405625,
1225: 113771193283469872120310539095739833,
1226: 117921052869579803514689801523449638,
1227: 122220535327540435729044764084697099,
1228: 126674973159627164610485151798391797,
1229: 131289886729786527240095013237443045,
1230: 136070990805862651658706033366694460,
1231: 141024201327040104811696041691045190,
1232: 146155642404167375009402954907061316,
1233: 151471653560883058451095421311451141,
1234: 156978797223733228787865722354959930,
1235: 162683866469743733376335192519362494,
1236: 168593893040195573779320686453020964,
1237: 174716155629645388794651866300906835,
1238: 181058188459536679140275000227478496,
1239: 187627790146061111217741961494883890,
1240: 194433032872253346998515292619988830,
1241: 201482271874637706375741021005730181,
1242: 208784155255090933098578892158986338,
1243: 216347634128942766400406396453655835,
1244: 224181973120705296790445342451587490,
1245: 232296761219203590802475861123264133,
1246: 240701923004274209788971782007579802,
1247: 249407730257605432130910077287592727,
1248: 258424813970713646981839124047488243,
1249: 267764176763484957967824140618533500,
1250: 277437205727159975794000686688315348,
1251: 287455685706103555386947650491244181,
1252: 297831813033180334721514504126791124,
1253: 308578209734051855476222280888835192,
1254: 319707938216222310789920115620477565,
1255: 331234516459188101998422700026723439,
1256: 343171933722591949005782567849433641,
1257: 355534666789845852070090701405470932,
1258: 368337696765269337188595637416276068,
1259: 381596526443390734228095202493032600,
1260: 395327198269680365975835178420652411,
1261: 409546312912626108164576640399383898,
1262: 424271048467724485839916892830607059,
1263: 439519180314644983035319377172158032,
1264: 455309101649532274915393819410766690,
1265: 471659844715141371979173526935980437,
1266: 488591102752254955447569352295355812,
1267: 506123252696611256922641286254645760,
1268: 524277378646375504218896129395592376,
1269: 543075296126019045035073055561928520,
1270: 562539577173328634024088141916141596,
1271: 582693576277154906994867051360796655,
1272: 603561457194424687753064451343608383,
1273: 625168220675887416175494833282535136,
1274: 647539733131042629585359752478706350,
1275: 670702756263704072335812679441391888,
1276: 694684977710697693392039019806832594,
1277: 719515042717266582828863521396088515,
1278: 745222586883866905899271646915240282,
1279: 771838270020186251303063741763018130,
1280: 799393811143400700904158178331205389,
1281: 827922024658910558926936487548336568,
1282: 857456857763058308684876665745077292,
1283: 888033429108637280324653641355847207,
1284: 919688068775347054572190680423598070,
1285: 952458359588743164917093657911776850,
1286: 986383179832665621554422059019604497,
1287: 1021502747401614623677846147487591813,
1288: 1057858665441074072255055670604124719,
1289: 1095493969525365696982675003469664810,
1290: 1134453176424250386882487822532585142,
1291: 1174782334511180318623311370757902964,
1292: 1216529075867847432892383159101984374,
1293: 1259742670141472479018316728428818781,
1294: 1304474080213136065603158197122179375,
1295: 1350776019737370796417180820702333527,
1296: 1398703012615213588677365804960180341,
1297: 1448311454464961662889458094993182194,
1298: 1499659676156986538068572255824972432,
1299: 1552808009481139790520320395733292300,
1300: 1607818855017534550841511230454411672,
1301: 1664756752283809987147800849591201736,
1302: 1723688452234384707674372422071320679,
1303: 1784682992189681523983975379146100758,
1304: 1847811773275862853601073393199008865,
1305: 1913148640458255774876416600453369682,
1306: 1980769965254371045106648307068906619,
1307: 2050754731215233987976941410834180457,
1308: 2123184622266649887649796215921782211,
1309: 2198144114005025303125952328225613580,
1310: 2275720568045462559712283145467243327,
1311: 2356004329523040680859896842728890474,
1312: 2439088827851495409213115816339495726,
1313: 2525070680846917026164254568053937634,
1314: 2614049802327600836872111661056230165,
1315: 2706129513304814950403979441635984290,
1316: 2801416656882996994241981980679918559,
1317: 2900021716991759392273170147031719072,
1318: 3002058941076075680836616507226015622,
1319: 3107646466875142011769945929778234485,
1320: 3216906453424662618200536823961141148,
1321: 3329965216421699826558324552595808770,
1322: 3446953368095762574438358199469775528,
1323: 3568005961734486838351757966808790919,
1324: 3693262641017091556254336031236632750,
1325: 3822867794313779335421691039194332368,
1326: 3956970714114397433384120384166003416,
1327: 4095725761754986283464866437718755283,
1328: 4239292537616325490949332681096528358,
1329: 4387836056974246172531213471126988170,
1330: 4541526931687319371792477450694975225,
1331: 4700541557913558825461268913956492487,
1332: 4865062310053998559115610911870100035,
1333: 5035277741127427794082646196764289585,
1334: 5211382789787193810929017395424321210,
1335: 5393578994197824268512706677957552625,
1336: 5582074712996280787878705083147454523,
1337: 5777085353569942323599828874448120571,
1338: 5978833607890937159258923653545207827,
1339: 6187549696154203668120613167259109435,
1340: 6403471618474669930531089742522848797,
1341: 6626845414907208756853259936695984136,
1342: 6857925434061555771629308454994509373,
1343: 7096974610593182332652154711768629954,
1344: 7344264751860200848154682253520601870,
1345: 7600076834045756410267481267000412856,
1346: 7864701308055034793828023244287340980,
1347: 8138438415506002236313232141990462682,
1348: 8421598515143296812402544776496284973,
1349: 8714502420015324706702901500511538625,
1350: 9017481745765587687202719206979752339,
1351: 9330879270400591290587334955958115107,
1352: 9655049305908367725798746534773552348,
1353: 9990358082113704664098849646925432237,
1354: 10337184143168612691406936474627379320,
1355: 10695918757089402353832391602114778863,
1356: 11066966338764988954966020552846311185,
1357: 11450744886874712432979257653673465667,
1358: 11847686435168064074325478460954986607,
1359: 12258237518573265193633495987026371935,
1360: 12682859654616659385819889316805008574,
1361: 13122029840650374087829702479479965035,
1362: 13576241067401694028191547060980833568,
1363: 14046002849374084164798517831067165046,
1364: 14531841772646818920248481411605550560,
1365: 15034302060637734370093170532411179780,
1366: 15553946158411737537905952886830918329,
1367: 16091355336136399592075372322853441977,
1368: 16647130312305245611392419213169232605,
1369: 17221891897369251284144496300865473815,
1370: 17816281658437585657529146257903261665,
1371: 18430962605729818628447970674590396131,
1372: 19066619901483662703451906966061889217,
1373: 19723961592044861669045607586672623550,
1374: 20403719363889095930868650315257219250,
1375: 21106649324349767740001100592550916016,
1376: 21833532807850282420908580590825862986,
1377: 22585177208464977793681819296712788065,
1378: 23362416839659197789401547387242312544,
1379: 24166113822086183031380235679888630795,
1380: 24997159000346486985219767235597236100,
1381: 25856472889644547994140059803514309099,
1382: 26745006653306882839626895694957692242,
1383: 27663743112157144914230446319916689190,
1384: 28613697786775039130057416743650633105,
1385: 29595919973698836617070193875375888205,
1386: 30611493856665016404478212802210021309,
1387: 31661539654013410832232951778996345076,
1388: 32747214803422179685312303680676279243,
1389: 33869715185174019207110095647396061120,
1390: 35030276385193261591559928994266853030,
1391: 36230174999132974647956742131787699078,
1392: 37470729978831867653000833781535492047,
1393: 38753304022502786601002774984625192104,
1394: 40079305010057880061198034072619085310,
1395: 41450187485020176719746625583516317963,
1396: 42867454184517379844972195257339462150,
1397: 44332657618901196005888853882051385939,
1398: 45847401702584520468158717245312104000,
1399: 47413343437739346154537960139775251600,
1400: 49032194652550394774839040691532998261,
1401: 50705723795773236966373450556265512689,
1402: 52435757789401123913939450130086135644,
1403: 54224183941301948277230817879517159495,
1404: 56072951919745741389655873424027752720,
1405: 57984075791803952210030966295696158116,
1406: 59959636127664498822125654803605200455,
1407: 62001782172971294457628166694777458740,
1408: 64112734091363688056165357762141754716,
1409: 66294785279460087023332346767177823090,
1410: 68550304756601011890673498202891728627,
1411: 70881739631740035679525259959146526016,
1412: 73291617649946553739726907624791770380,
1413: 75782549821062183481895201583751205263,
1414: 78357233133132880842076215608511229415,
1415: 81018453353321656721019131504035339537,
1416: 83769087919092159661630333467319344902,
1417: 86612108922541440552472192615179632742,
1418: 89550586190851013626818983550558814889,
1419: 92587690465918960312381724727166445110,
1420: 95726696686332376146505918443171660625,
1421: 98970987374939026118276437676742560264,
1422: 102324056135379743432459471263142178485,
1423: 105789511261048976512902596439531532566,
1424: 109371079460060057837671640558228717300,
1425: 113072609699904337559514844445146843472,
1426: 116898077175609399692092533607036637857,
1427: 120851587405321266865514819340648620862,
1428: 124937380457358912643772141796859437854,
1429: 129159835312916652764103424563956670300,
1430: 133523474368721196662101633251149823925,
1431: 138032968084085429989744342641002104875,
1432: 142693139776940493084095678732486636969,
1433: 147508970573571548730224671300676243591,
1434: 152485604516930928407097683383484266510,
1435: 157628353838555246722760639034336216136,
1436: 162942704399270720489853224525723269795,
1437: 168434321304033467550147269349447360294,
1438: 174109054696419141315515890296286539118,
1439: 179972945738449034728553750103340839325,
1440: 186032232781617921513478910563182232444,
1441: 192293357735172557401982780429019456969,
1442: 198762972637879108865432799270626669004,
1443: 205447946439712986100137659510287259781,
1444: 212355372000105810413242676805207816705,
1445: 219492573309591728816879034317080350983,
1446: 226867112941909191440813277312570747145,
1447: 234486799743834826784604048875528356971,
1448: 242359696770253388472695000770509170206,
1449: 250494129472202113601016657658116885375,
1450: 258898694145869442049569648660373941152,
1451: 267582266650777119653998333871688332247,
1452: 276554011405631474170238269248906446792,
1453: 285823390670594346502222808229127105074,
1454: 295400174124997022998049389765214784995,
1455: 305294448749801797154111873648107967492,
1456: 315516629024405747970164359073870491229,
1457: 326077467447680222173319384811207626600,
1458: 336988065393447621514574974879775699372,
1459: 348259884310914705271679879631949049780,
1460: 359904757280909011630794460361074410538,
1461: 371934900939102477916959218389244857418,
1462: 384362927777754206102413138268506970021,
1463: 397201858837862893052822862772992037235,
1464: 410465136803989050790556876831592919085,
1465: 424166639514388116438037562729473373486,
1466: 438320693899488240621648045435196959242,
1467: 452942090362151303283202948578566379295,
1468: 468046097613572904390385124958730619192,
1469: 483648477979107092056857426409232236010,
1470: 499765503188744811845488653259134061244,
1471: 516413970667431889729975411863080081224,
1472: 533611220340883210895592492267492392503,
1473: 551375151973035052959106187501778547015,
1474: 569724243051777714078869714336553502625,
1475: 588677567240126095472954965375170347997,
1476: 608254813410517219620274841577537789254,
1477: 628476305280471269092869681239382035111,
1478: 649363021668417110482089106581996800736,
1479: 670936617389064931646215631627734512060,
1480: 693219444808308092528746108408911793239,
1481: 716234576078254109447577888083725273959,
1482: 740005826073621415936329176309708825539,
1483: 764557776051394742131574284792974302805,
1484: 789915798056308219059157433980611758115,
1485: 816106080095422250986408555099636706156,
1486: 843155652105778433840074131252109568468,
1487: 871092412739856974449839116812405949463,
1488: 899945156994323847635597208986502059289,
1489: 929743604708340998940330812008055415670,
1490: 960518429958522963981451968247615571768,
1491: 992301291378458055449596203783102865285,
1492: 1025124863431572512298240504372933893698,
1493: 1059022868667002481099668362066093137208,
1494: 1094030110989052198741424671895432081910,
1495: 1130182509971758083662737515471154158801,
1496: 1167517136251048459523457118438435734632,
1497: 1206072248027988195015615498189010425646,
1498: 1245887328717627537181110407053143579875,
1499: 1287003125779035759903231323132670516000,
1500: 1329461690763193888825263136701886891117,
1501: 1373306420616547671126845059808771245199,
1502: 1418582100279183135137313919163744611210,
1503: 1465334946617783561814630036179107930696,
1504: 1513612653734759530017526259861629678205,
1505: 1563464439696213993716384678301014319431,
1506: 1614941094722713228367155822930278965324,
1507: 1668095030888183105149797247519563263487,
1508: 1722980333373639710221714255936544610213,
1509: 1779652813323895051112691937493275900640,
1510: 1838170062356853750560836014387165897751,
1511: 1898591508776536523215092101916644734126,
1512: 1960978475542532205781057345396110080746,
1513: 2025394240050193548750246784190116959083,
1514: 2091904095777554301862779830720186765825,
1515: 2160575415856657801620130127396601613839,
1516: 2231477718628751807313395954393627156678,
1517: 2304682735244622286166458817442330457493,
1518: 2380264479373211819043135033180865953593,
1519: 2458299319083597933290739975588639913960,
1520: 2538866050967394665741511337736337646822,
1521: 2622045976570688763353306228619701197220,
1522: 2707922981206731940550655607258234921458,
1523: 2796583615222784382740474040856321114152,
1524: 2888117177796744121961996863481080757250,
1525: 2982615803341503976179051696005120224577,
1526: 3080174550597354460133578989992600710402,
1527: 3180891494495199523837557418419727460583,
1528: 3284867820875874297854866890890114734440,
1529: 3392207924153452428300151849140308700620,
1530: 3503019508013107340706503153715459439135,
1531: 3617413689236849218690486699230663550120,
1532: 3735505104753300028632631618647052984126,
1533: 3857412022010595043668172932897782160438,
1534: 3983256452774513571402317362452698824910,
1535: 4113164270457046596687344259862579939532,
1536: 4247265331083807518632379721321456268679,
1537: 4385693598011986873811172464601561040968,
1538: 4528587270513945762405321738705440092603,
1539: 4676088916345038581429933773569294261235,
1540: 4828345608417856657751813260670405103571,
1541: 4985509065708793590462102906287902242693,
1542: 5147735798526653777473353718656776051935,
1543: 5315187258276961029029844229698454778001,
1544: 5488029991859677773715074283837789258005,
1545: 5666435800842220652541448314024017081118,
1546: 5850581905553958890153341953182905874297,
1547: 6040651114252811450773802339294340809537,
1548: 6236831997519121462431059121804263835744,
1549: 6439319068036685669987130768251283335700,
1550: 6648312965925656816271400679772663779731,
1551: 6864020649797022030147590897007762961557,
1552: 7086655593703494823378002063833638733692,
1553: 7316437990166946592699616833531354911573,
1554: 7553594959467950148686513765206276332400,
1555: 7798360765388617440490476800142578927168,
1556: 8050977037605691145961262617379106893607,
1557: 8311693000936800120986617647413681760089,
1558: 8580765711648916968128569908862807858077,
1559: 8858460301044367459544239649173485609090,
1560: 9145050226546241655095435675456471213374,
1561: 9440817530511750873400887128525102883050,
1562: 9746053107008968945969854946579275550253,
1563: 10061056976799496323982724378320247274070,
1564: 10386138570776897699583240005533846228720,
1565: 10721617022118294111300879958656795681727,
1566: 11067821467414245473548388055474400555521,
1567: 11425091357050045737330444087123696839842,
1568: 11793776775119777282986614097061549565288,
1569: 12174238769162940693809364157051309012420,
1570: 12566849690022197996332017608789608083314,
1571: 12971993542129749223451407990577313551957,
1572: 13390066344539111423681390555352209300441,
1573: 13821476503028593889295382128265725457026,
1574: 14266645193612571525140101316505187638875,
1575: 14726006757806758281011522810861817647486,
1576: 15200009110004083021400239371051767831673,
1577: 15689114157328479953978540694207577474781,
1578: 16193798232344933888778097136641377589301,
1579: 16714552539015476523707617004948193446275,
1580: 17251883612302523293667801378616630723938,
1581: 17806313791832981004049940595952236488989,
1582: 18378381710048954709565959117356034045626,
1583: 18968642795283648606471174187975250526914,
1584: 19577669790214200898277149916663590160135,
1585: 20206053286156727802917377116665528100452,
1586: 20854402273682788549513827814948445887987,
1587: 21523344710050833153156141436233019518750,
1588: 22213528103960970088758743797991090055558,
1589: 22925620118156604193077050587843661667620,
1590: 23660309190412159054931489112539937306848,
1591: 24418305173462226026373553546995875617627,
1592: 25200339994444087406536213435901662689794,
1593: 26007168334442658312725535116810982082161,
1594: 26839568328744494665699148030346372021260,
1595: 27698342288425638399643940633635778570228,
1596: 28584317443916730715736989648170031498488,
1597: 29498346711208035625096160181520548669694,
1598: 30441309481376795323275876211869020871017,
1599: 31414112434139702720919278494304352579875,
1600: 32417690376154241824102577250721959572183,
1601: 33453007104814231206634568834252067530087,
1602: 34521056298307127650200260789840693447039,
1603: 35622862432723524773564047600591620474611,
1604: 36759481727032834297334619181982868193810,
1605: 37932003116763385216396036596083684144149,
1606: 39141549257250138871243034824146893141432,
1607: 40389277557338916599575631087245664105779,
1608: 41676381244462492794128018619459154745923,
1609: 43004090462031141893576046232131339283625,
1610: 44373673400108265833414174147846823131033,
1611: 45786437460370592180018097454654125762209,
1612: 47243730456382146639125256475201485557926,
1613: 48746941850241791637271332996842921594539,
1614: 50297504026695610706485495279896144769485,
1615: 51896893605837832676324724372468638684687,
1616: 53546632795557357169752166455397628534844,
1617: 55248290784921291361962286829338022618145,
1618: 57003485179722265948521834701738678421349,
1619: 58813883481452695155464304054870553436360,
1620: 60681204611006611632952513664174735563434,
1621: 62607220478448273296879161314388228250413,
1622: 64593757600226437608809675150800761682315,
1623: 66642698765254062321100804776702438717922,
1624: 68755984751315254218264566880232672144875,
1625: 70935616093304583685847007991159666098679,
1626: 73183654904848448867540438473174344075670,
1627: 75502226754904045590148716826986516533057,
1628: 77893522600978716067675261669847531834806,
1629: 80359800780661049649804576562965921695475,
1630: 82903389063205132690374405132401276101050,
1631: 85526686762960833261150746165714536727005,
1632: 88232166916496002397533755182876654157205,
1633: 91022378525311020523414800627504843113662,
1634: 93899948866102260607570160618726171594330,
1635: 96867585870588824684642587049077568806146,
1636: 99928080576976385190854302771818195507418,
1637: 103084309655193176038845274579543287624753,
1638: 106339238008096180814672350296895542938848,
1639: 109695921450910408688484641855278054316360,
1640: 113157509471230885841519620824589853318260,
1641: 116727248071985676199747488789041121983568,
1642: 120408482699828936375465082551662467674163,
1643: 124204661261505763907840490901149694071182,
1644: 128119337230805474780434782661196752002675,
1645: 132156172848797007097973143732608413596901,
1646: 136318942420119455804633282594364118870621,
1647: 140611535708182363299559887896839185406573,
1648: 145037961432214389489427685180617331098024,
1649: 149602350869185430852497209043356597608875,
1650: 154308961563716222079735293780517268790662,
1651: 159162181149181008424137378091161149008138,
1652: 164166531283303096726173462843072095335410,
1653: 169326671701640055015539018518705699850330,
1654: 174647404392455113639317800019372440640580,
1655: 180133677896574006306024799468201257241780,
1656: 185790591735932160859341593488427864239206,
1657: 191623400974625892978847721669762887224010,
1658: 197637520916393159778610138707329017740693,
1659: 203838531942564585384018857484505756167480,
1660: 210232184494643970555920434333513855824223,
1661: 216824404205799439501151597527348613503086,
1662: 223621297185671858108005694276757667011704,
1663: 230629155463036280733315769829856728366831,
1664: 237854462590985052006674013310829555807395,
1665: 245303899419437913541037116166052239846061,
1666: 252984350039925153650180418719145316631826,
1667: 260902907907734605017003921684746498516403,
1668: 269066882146662257820916698151184555362272,
1669: 277483804041759534527674431707495428212025,
1670: 286161433725627991209904771339900788624872,
1671: 295107767063974496251592243518106809957385,
1672: 304331042746306921569506210339059205494747,
1673: 313839749587822198745641666552447374489321,
1674: 323642634048715381224461508374001874352425,
1675: 333748707977320256428395802157949938763484,
1676: 344167256583679214774724367914264615318981,
1677: 354907846650332656774577448740278805781989,
1678: 365980334987316359577499492665661423156220,
1679: 377394877138559089794329589034333523822720,
1680: 389161936347082504011271085636055422264324,
1681: 401292292786621190557291178310378056588836,
1682: 413797053067502749043669672231562125696658,
1683: 426687660024856256094871226711613620285845,
1684: 439975902797452509721828685778957458838000,
1685: 453673927205721269316833783775783610703320,
1686: 467794246437739506976775111608393022209053,
1687: 482349752052240657962887540925835136720740,
1688: 497353725307958208396664918548576500570384,
1689: 512819848828887897371554062220903289550130,
1690: 528762218615331555088826226879544901167527,
1691: 545195356410872371074704272735369048924689,
1692: 562134222435726415975597022642148002675881,
1693: 579594228497218762288102882601473336765100,
1694: 597591251488444805746508999799665944566660,
1695: 616141647286498628873307956507246249662412,
1696: 635262265061980727342758633558885467930686,
1697: 654970462011837401470060834112028353314761,
1698: 675284118527933869908522234215965152162520,
1699: 696221653814122968723573796976021441661750,
1700: 717802041964941442478681516751205185010007,
1701: 740044828519446608929091853958115568986164,
1702: 762970147504097887787893822256219849371554,
1703: 786598738978990637725956554797278124357808,
1704: 810951967102164263980984405643613443347625,
1705: 836051838727132970358751925465426223753244,
1706: 861921022549226171951777077723669881527186,
1707: 888582868816776806015468170319304987709289,
1708: 916061429623659935353293704664261165680563,
1709: 944381479800161498529884419450242134471605,
1710: 973568538419648201851756811932637866236071,
1711: 1003648890939014757529114525804772812444576,
1712: 1034649611991404349880377024889805948451966,
1713: 1066598588850232767185892564930056790115492,
1714: 1099524545584096492698787529446425808960485,
1715: 1133457067922710638072138797746330685194571,
1716: 1168426628854604371943988173648061076656356,
1717: 1204464614977899904017040550277724793430409,
1718: 1241603353626116601935133531509635427501801,
1719: 1279876140791574929056038110412443745546155,
1720: 1319317269869626093912245397158785002901753,
1721: 1359962061247603108750056330533001022811146,
1722: 1401846892763077891420050435782921418973709,
1723: 1445009231056717653171633051674494164837538,
1724: 1489487663845762650867366119648959070605125,
1725: 1535321933144897017630429081796659362863565,
1726: 1582552969462055408849028210050341395113316,
1727: 1631222926997501215103529967929557707274660,
1728: 1681375219875327721201833943152266777825092,
1729: 1733054559437372469717283290044275542482740,
1730: 1786306992630397874710969065930279993530728,
1731: 1841179941518278501517284167616876198477309,
1732: 1897722243951848075290887164802970670035779,
1733: 1955984195429997917538913727371549522655006,
1734: 2016017592186583869120124322228807307858970,
1735: 2077875775538691593667272042037771337062872,
1736: 2141613677532831241625032098057988491948517,
1737: 2207287867926682588244859017849269988676029,
1738: 2274956602545091757332316519809900057062533,
1739: 2344679873050131347512524469147852330603290,
1740: 2416519458166178053962910323080826683013954,
1741: 2490538976402136614754617183069000726495038,
1742: 2566803940314147020741857199436825485292885,
1743: 2645381812353354350387072647528700656565179,
1744: 2726342062344598291243970336667065409029860,
1745: 2809756226643193380147979076327264594704745,
1746: 2895697969018322254247325865029474629995508,
1747: 2984243143312953802987213049129995837626487,
1748: 3075469857931627124375487934417729522202013,
1749: 3169458542208911724615579730356050273697000,
1750: 3266292014712865596629588272103919719684547,
1751: 3366055553539366839888542445766361166135204,
1752: 3468836968654792543650918885868953010691040,
1753: 3574726676346161983924385238571158169261725,
1754: 3683817775839551051322373817401051497424420,
1755: 3796206128149322537872121900182662159228241,
1756: 3911990437222503807420937006192549828899684,
1757: 4031272333444480835500888704164496363681686,
1758: 4154156459574067047582172896269352052007031,
1759: 4280750559177948266124532321685590709003370,
1760: 4411165567636502893727652799725970383582718,
1761: 4545515705795050750500358651870382988186314,
1762: 4683918576336696329734155119529513589827658,
1763: 4826495262955104262123827190438060829061153,
1764: 4973370432407778155253526316242844344573385,
1765: 5124672439532710418254508515826522600609941,
1766: 5280533435313631955425559713040649796775465,
1767: 5441089478081518530016413892489308199319929,
1768: 5606480647942507023374562583725669127988521,
1769: 5776851164524941659873115036048663114937695,
1770: 5952349508140909502130662763236950728528684,
1771: 6133128544460338166089749412557583307068767,
1772: 6319345652798518839604562697210438023241550,
1773: 6511162858120786446819766577778364926946013,
1774: 6708746966871038378408979787060247103179750,
1775: 6912269706733805859936155115580770892194054,
1776: 7121907870442710074828422368434553047727682,
1777: 7337843463751340976339671250105665526337260,
1778: 7560263857685892761905455418833343917244062,
1779: 7789361945202278758472065509114228369126600,
1780: 8025336302373932563237571980294779250756300,
1781: 8268391354240084356595173268406241855198176,
1782: 8518737545447984082077112629884273268761094,
1783: 8776591515826329476185591848477738781761689,
1784: 9042176281031049610986292577509011838783245,
1785: 9315721418408596645489064435708989370524469,
1786: 9597463258226012911089716132158337004512929,
1787: 9887645080421270408475092400425112950304770,
1788: 10186517317031728481382143156507032880864866,
1789: 10494337760463026157910800552509870425432010,
1790: 10811371777765321805152346144711499265489879,
1791: 11137892531088517813516189325593809889812108,
1792: 11474181204492965595127263976240658672733891,
1793: 11820527237297139926370474832027317722017807,
1794: 12177228564148905369732416163985994571309670,
1795: 12544591862012275060173347722472359244046903,
1796: 12922932804266987528897386291108558284524280,
1797: 13312576322123804564848753689176255125112158,
1798: 13713856873564166596625513497299706749207160,
1799: 14127118720018736045636750699617456881311725,
1800: 14552716211005418005132948684850541312590849,
1801: 14991014076953676011289439394970540421861988,
1802: 15442387730448363289492676946827168544596921,
1803: 15907223576132871507960364168750022280398562,
1804: 16385919329518164710931105850817769087241385,
1805: 16878884344951220830025131180984215659580858,
1806: 17386539953003552219964871974446413826117272,
1807: 17909319807547825412134603270711842061393357,
1808: 18447670242798154252456532648116438246904907,
1809: 19002050640597405466197703977606842321053540,
1810: 19572933808242837304672225027800498209481360,
1811: 20160806367149596270203427106156960870472824,
1812: 20766169152660030143204019897118002904900168,
1813: 21389537625315443974415368124511782893607123,
1814: 22031442293915835855052489509763576677617505,
1815: 22692429150702307814484325155610270148732358,
1816: 23373060119006260978552660565770602425866730,
1817: 24073913513719160198707702330267411589158084,
1818: 24795584514946598972622146485353975132184526,
1819: 25538685655220618058549873928821959736691905,
1820: 26303847320654738379516399526912590943781620,
1821: 27091718266436968469332058999564180929593866,
1822: 27902966147067146894819024985472934375689121,
1823: 28738278061756389082181003004910619210874204,
1824: 29598361115418134291077518460315335403586750,
1825: 30483942995692340860959609721949330792795099,
1826: 31395772566456765282571775715588003409132613,
1827: 32334620478291992350263579043602637456626234,
1828: 33301279796379969106727880491661424703794769,
1829: 34296566646329244238310747147664839490574535,
1830: 35321320878433937019039707727760782467717785,
1831: 36376406750887666110543978036746824592455791,
1832: 37462713632488269058784695792011875893039111,
1833: 38581156725384149030225659607573893303383795,
1834: 39732677808428507338475836002967756141425565,
1835: 40918246001723570069537718918088365292496141,
1836: 42138858552953206373244111655326855421732185,
1837: 43395541646119076823784928057386091817027588,
1838: 44689351233312655065605577356497222364030752,
1839: 46021373890173147491957400810472661489846635,
1840: 47392727695699507038180086415408337440470086,
1841: 48804563137103411752378288723762455918172986,
1842: 50258064040409270440055764682612968116562013,
1843: 51754448527527040549257397842950059733038281,
1844: 53294970000543912137117431914902281880953875,
1845: 54880918154001741201408795026747551723720527,
1846: 56513620015948521242261975310131861303268895,
1847: 58194441018574179427502571579696887885537742,
1848: 59924786099263589386584792985885004002385100,
1849: 61706100832922923109471297093651456522575000,
1850: 63539872596459336786702846316806859551222764,
1851: 65427631766318517268030842666066129833124679,
1852: 67370952950009825188774721810114716943378422,
1853: 69371456252574676254257996014226320491002233,
1854: 71430808578980422724679205565325409535341535,
1855: 73550724973449352362958820460243849915161295,
1856: 75732969996760532083864127998517020593740791,
1857: 77979359142591108905489195759391328910134418,
1858: 80291760293993362744249170815935430293952943,
1859: 82672095221134305875868191384112819286758200,
1860: 85122341121455964860570648618210990142492639,
1861: 87644532203446685358824902714882088097498633,
1862: 90240761315246892123800470058435668367783935,
1863: 92913181619346739765141403639335218061558813,
1864: 95664008314668029507699782676107535163671365,
1865: 98495520407358668662814112828386043342039288,
1866: 101410062531664839123433827120996801871554118,
1867: 104410046822283945831589672011997862390810762,
1868: 107497954839640363519148716631132136446924023,
1869: 110676339549566018509524250906452596245408440,
1870: 113947827358908961175629034752466582068886470,
1871: 117315120208635333752283890034504840221064086,
1872: 120780997726033548383095326244127836720276225,
1873: 124348319437674093156601079636921240241787962,
1874: 128020027044824211921357710559027384266649000,
1875: 131799146763063790207250005304405120478900361,
1876: 135688791727897158862480183289001251910301886,
1877: 139692164468205234207238255169848532611147557,
1878: 143812559449433484718637448310794816419480218,
1879: 148053365688463686582704780998822076298210405,
1880: 152418069442171341962802939167993644252844977,
1881: 156910256971726023650131079907915129924767174,
1882: 161533617384748818044426030157299715901448409,
1883: 166291945557499506406187783344043042314534878,
1884: 171189145139326194380356742395417581059236130,
1885: 176229231641671815409487530302217850452007387,
1886: 181416335613995339496338175675291780004357523,
1887: 186754705909030660706666553292223320927706878,
1888: 192248713039873061921465120214608474899151280,
1889: 197902852631451912018290889751846175017276700,
1890: 203721748969018888548080806839085873409222663,
1891: 209710158646353589075380551065506324110555541,
1892: 215872974316462949034790068311792114803360768,
1893: 222215228547627476999327377660931337519227930,
1894: 228742097787726004875938672290676073251112495,
1895: 235458906439851487440117948662414751746035425,
1896: 242371131052313431017875037233367567350390976,
1897: 249484404626207844803286441041017222801266718,
1898: 256804521043823251651497040551112296246458295,
1899: 264337439621241331244215401011574782781334700,
1900: 272089289788583262011466359201428623427767364,
1901: 280066375901447845568248481717977121765830398,
1902: 288275182187185106927480861934498895209154826,
1903: 296722377829749335448869068867067104949579464,
1904: 305414822196978537321624475491324386207138350,
1905: 314359570214253084228181897886953506729950270,
1906: 323563877888595040544848710079341268243350278,
1907: 333035207987381310882223234930566921371066351,
1908: 342781235875958450915909855966319285240611144,
1909: 352809855518564809408156722848357746339640390,
1910: 363129185647086702371268910149149152584766993,
1911: 373747576102299648025575523786476989131026713,
1912: 384673614352373402423945044973430693054218643,
1913: 395916132193550721591800039752382776657876433,
1914: 407484212638044530444951338680763930621994820,
1915: 419387196994336597778328640988515637140928750,
1916: 431634692145202999016827948773519398239274548,
1917: 444236578028937695571550278721551746219224713,
1918: 457203015329395575643972370763403591173830810,
1919: 470544453380630393038248327984084169870052370,
1920: 484271638292061317700921219995285769876393805,
1921: 498395621300264386957594139661914904785275330,
1922: 512927767353652135411965358701027725220931707,
1923: 527879763936476202951968110645920036905758794,
1924: 543263630138763896173977941441058199308011100,
1925: 559091725978980633941148481298313317618632967,
1926: 575376761986396071222827176058084413124270202,
1927: 592131809050322598728023510231907577504041350,
1928: 609370308543590994569721078158344505753246979,
1929: 627106082727829397306582084065079630894972195,
1930: 645353345448318619933615779058934561872409372,
1931: 664126713126409278261223804893870154281524038,
1932: 683441216057704415059243252710086070145621992,
1933: 703312310024435417776917212697059694728111811,
1934: 723755888230689211116144545349876787252027480,
1935: 744788293569381118983800284897623329523811384,
1936: 766426331230110600455862693324715237997598939,
1937: 788687281657286442867926694461098498097562065,
1938: 811588913868164118077309502293768840003949925,
1939: 835149499140701056072067990291237777551833530,
1940: 859387825081405748983159033075649135425638325,
1941: 884323210083634058665255574996164926064666511,
1942: 909975518187071057883524303147934812769277935,
1943: 936365174349429389500998978473009079907862954,
1944: 963513180141695685953126594506747030515761180,
1945: 991441129878565264237073831290682236831192947,
1946: 1020171227196022316757683410004293870517496706,
1947: 1049726302088348378540247976304143049122065214,
1948: 1080129828417176195331669321286587690711167057,
1949: 1111405941905549479818145590739116367242780000,
1950: 1143579458630301665664240006110545368915059329,
1951: 1176675894026428898785508782184245465533665048,
1952: 1210721482417504396219216523662601652136179376,
1953: 1245743197086563215894590527223118960072913202,
1954: 1281768770902278683167516719540860443130307320,
1955: 1318826717515654486899160825985211020969456836,
1956: 1356946353142870071117550937780046987060960843,
1957: 1396157818950341697358512735475562356104045295,
1958: 1436492104058497734745724852296636956267964954,
1959: 1477981069181214654702422049514025480619599210,
1960: 1520657470918320177914639277247113472181645153,
1961: 1564554986719042364085227429425894281463674979,
1962: 1609708240534768479916261201915809290266567989,
1963: 1656152829179975566133060952832169077820577902,
1964: 1703925349420706097654088225457498186848567210,
1965: 1753063425810487348828764073209783931216955698,
1966: 1803605739294132404035202382553315081341190088,
1967: 1855592056600414568536728473961840601327835478,
1968: 1909063260445175620937659060948648856259756235,
1969: 1964061380567012302624155966071951926644451875,
1970: 2020629625618285067432170725261207144994992239,
1971: 2078812415934808833368620144510853807585221613,
1972: 2138655417208217715431844885515291279369574680,
1973: 2200205575085644913617857845505033592721522553,
1974: 2263511150722025533817142690940119270064496250,
1975: 2328621757311014594133664064174539456980750339,
1976: 2395588397621215290008835331658621643021314292,
1977: 2464463502565134245725579502592034085209328984,
1978: 2535300970829021467547395315846813198183591546,
1979: 2608156209592513548223075037746157905702847505,
1980: 2683086176367779880674969950590007819202341357,
1981: 2760149421988673761061033114268064448054050548,
1982: 2839406134781213852952373747778159055380262422,
1983: 2920918185947567114582770377976676661508796149,
1984: 3004749176196572544459946686955919368234128060,
1985: 3090964483654736576896042159262866214940589314,
1986: 3179631313092546273793802882159493889001969611,
1987: 3270818746501886244063493400323024051287288941,
1988: 3364597795061310125684361619251416376860936489,
1989: 3461041452526908153028282986522280729367368365,
1990: 3560224750087529486464584716859554522268776125,
1991: 3662224812724162303217742306542356590926722479,
1992: 3767120917114346857096063738777247515406335526,
1993: 3874994551123597548057533501867770741416429535,
1994: 3985929474926940257994009093217001343955328335,
1995: 4100011783804831583821441379839563991285227198,
1996: 4217329972658917930562969936711305445974785514,
1997: 4337975002294315534109569503386742455494341143,
1998: 4462040367516348205694592687945941817364967127,
1999: 4589622167090968789784046573687400867942870250,
2000: 4720819175619413888601432406799959512200344166,
2001: 4855732917379000237574365609687488912697273143,
2002: 4994467742183366148074839035447416380393781644,
2003: 5137130903316893622770745464235084139384928426,
2004: 5283832637599517075572081746564260420858901705,
2005: 5434686247639634059061258993904042430607990074,
2006: 5589808186334383050291570992756471405633041387,
2007: 5749318143678144230778676663789672984169195116,
2008: 5913339135941752405965378691599572441324623941,
2009: 6081997597286587859405678030809218670282246785,
2010: 6255423473879432172551153347179787953125682826,
2011: 6433750320575743037411316728215679204642749660,
2012: 6617115400240816052275556661314890288999332009,
2013: 6805659785780163657391920602286596663406217911,
2014: 6999528464952353007567067145415164276505069670,
2015: 7198870448039506994791503590601126801607534137,
2016: 7403838878452687162912842119176262318542314409,
2017: 7614591146351445269661694564912786246445478891,
2018: 7831289005358953156344654888013498638339711692,
2019: 8054098692456299826324570548607480763080403880,
2020: 8283191051141781691732068101840743191755759916,
2021: 8518741657943308344041302580996941768179250799,
2022: 8760930952374403498169602637389577451855415964,
2023: 9009944370426700552244228695797096011740585251,
2024: 9265972481694316138437595284729122693073711400,
2025: 9529211130228034799395854632912272457677896880,
2026: 9799861579219855238744997642818047729388291567,
2027: 10078130659621135236933601810787303619515113811,
2028: 10364230922800330115415428619787879783434758914,
2029: 10658380797349150440403847607713189208549844510,
2030: 10960804750148870398245267228037581609577682339,
2031: 11271733451811500913798689538973402825112404379,
2032: 11591403946613603138135282386492611425148475178,
2033: 11920059827043660471886625110700606109457615243,
2034: 12257951413087152938966999455842406831025654415,
2035: 12605335936376788660643906067688568691477294599,
2036: 12962477729338745637101954446070534143126297085,
2037: 13329648419469265315863347103932314055721954884,
2038: 13707127128879519866370496154104287110788727040,
2039: 14095200679250350101462435045670967566714006190,
2040: 14494163802342243065803242497250145705564482929,
2041: 14904319356209789989230727462504226498494263931,
2042: 15325978547273839186092526952960232758544597811,
2043: 15759461158408637244144834830819680263402565217,
2044: 16205095783205438232082764786847977319531548455,
2045: 16663220066578357477963673318612506891057322162,
2046: 17134180951882656619355889974597586372298980947,
2047: 17618334934720173062514849536736413843694654543,
2048: 18116048323611252751541173214616030020513022685,
2049: 18627697507717313357328883548487129542980353125,
2050: 19153669231803058848943059805108758933859747374,
2051: 19694360878632389188479682121479772827588278091,
2052: 20250180758997203961018562965051517467373563574,
2053: 20821548409583589567679943310731809893410960813,
2054: 21408894898885309715106534167513145969112337635,
2055: 22012663141380091963647773040348591535494857021,
2056: 22633308220189922777870335143856096247251187948,
2057: 23271297718452433681930253947266040250043569734,
2058: 23927112059636485682887466272819725468557276242,
2059: 24601244857041242112722641487525252331485884885,
2060: 25294203272724365584159904646608138971697036406,
2061: 26006508386111487092631615069752229687889047419,
2062: 26738695572545778772495897103306702147812265676,
2063: 27491314892043320887814631666080168776331811888,
2064: 28264931488526992879603605279805458570836160570,
2065: 29060125999818842393508123538658855855869573724,
2066: 29877494978678299986437859187588252356283557915,
2067: 30717651325181215594079225685922159612710890246,
2068: 31581224730742500897001026737587458361246031363,
2069: 32468862134093174645484430948409904593113694670,
2070: 33381228189530831120385246576357623531476650368,
2071: 34319005747770990684777087747947525376490393829,
2072: 35282896349735451425203004555804514075824949148,
2073: 36273620733622647942922713748119798292462316154,
2074: 37291919355614143333586997222803939193763027250,
2075: 38338552924580739339245889549713324449360541521,
2076: 39414302951161293776274047281093717842584188891,
2077: 40519972311597190003244878215733219997449415843,
2078: 41656385826715516924455731088372893657996361228,
2079: 42824390856464396526209228476474575762774879465,
2080: 44024857910414546084950481401735302373848095782,
2081: 45258681274652091016547586287700221970008068755,
2082: 46526779655498859083237494859206365034702358134,
2083: 47830096840507894753763929606166424148960110424,
2084: 49169602377193741528342591922356853935149504975,
2085: 50546292269969157794099110029993948769746687671,
2086: 51961189695772366269783089381199090558960547606,
2087: 53415345738881696537662435419712492307334180478,
2088: 54909840145427572963129830596638040418770704515,
2089: 56445782098125235102442269204682620745124030885,
2090: 58024311011765363351557172881384457469348901699,
2091: 59646597350013928176910703744766844433767270677,
2092: 61313843464087096107973721257849778294625405081,
2093: 63027284453881919316292784641070835053831354052,
2094: 64788189052158817856342546799691255570877518150,
2095: 66597860532387544551063529093372826237515675728,
2096: 68457637640884412378329010378860869685804024262,
2097: 70368895553885073626926030071097479233359907864,
2098: 72333046860214079886074787715712944920415424984,
2099: 74351542570229833233029956235268391407949627875,
2100: 76425873151741373195807749021080021459080291165,
2101: 78557569593611742891613633197716231871513782517,
2102: 80748204497781453174729297053600127492388932998,
2103: 82999393200464827976246067679320326020971457938,
2104: 85312794923291779902869927934730036659721510375,
2105: 87690113955187845526792666366851401712801134274,
2106: 90133100865806117918203480753613859038381596324,
2107: 92643553751346063460833585063932351673594098859,
2108: 95223319513616114811576859302283546424619314506,
2109: 97874295173219406337291510865301717288885200445,
2110: 100598429217765077170980775830078597915978709260,
2111: 103397722986031225236603653787203378188231402292,
2112: 106274232089029868642533106912359104776603150690,
2113: 109230067868949174578477633685673008965957469120,
2114: 112267398896973766514395710229044460157179222920,
2115: 115388452511010134752244464747991318862444784689,
2116: 118595516394371070307305070689995677519803374830,
2117: 121890940196500635216372474879596908517840948778,
2118: 125277137196849491653446187682001921308870438795,
2119: 128756586013039456106279781429309224204637155235,
2120: 132331832354485942225817194731144948296095338913,
2121: 136005490822677526183628341619662696228169437779,
2122: 139780246759343231332496879136294914183920566235,
2123: 143658858143770305041408732118198629930850140819,
2124: 147644157540568270666807354340091712330909224000,
2125: 151739054099208903158067016467162544501125246216,
2126: 155946535606706519753573960842521384418556790909,
2127: 160269670594838620141199867367375227901178121673,
2128: 164711610503343476443764262455655533446463188624,
2129: 169275591900568786145109713871008667212574145360,
2130: 173964938763083984897646967444489323060065487907,
2131: 178783064815808295968062329270497666350416021621,
2132: 183733475934247094438727208707795835845879643176,
2133: 188819772610470713392617031395550078686410106988,
2134: 194045652484512443040038057363040342445733893240,
2135: 199414912942906199650168544999618866932966543484,
2136: 204931453786129197483756438132982529754356479553,
2137: 210599279966760972657750340621024569609658319243,
2138: 216422504400217312716806872498425178952708753752,
2139: 222405350849966070103844047835296998593257719870,
2140: 228552156889181512949138540918848061266047740791,
2141: 234867376940844824665120188180587152072518199582,
2142: 241355585398350637585388084310633650150819331465,
2143: 248021479828733108998565670865001643954560554353,
2144: 254869884260680054932039940494913967190530868955,
2145: 261905752559560083345100350260758248905652921875,
2146: 269134171891745550301357546978902318483150550307,
2147: 276560366280573537433149830945908221546675684073,
2148: 284189700256347954756384460822072399114186994724,
2149: 292027682602848348780952829894171946286185196525,
2150: 300079970202875082019467410865495625479979094694,
2151: 308352371985426287572392634796034918345831989966,
2152: 316850852977169433649870812195036854291507911207,
2153: 325581538460939500937426146405250734530774231825,
2154: 334550718244066724977417207615678241114465752975,
2155: 343764851039409631696645200323540686552303329604,
2156: 353230568962043743490045985418104968175497835998,
2157: 362954682144632903677995273534058279957414924705,
2158: 372944183474588707707117294510467908715140736065,
2159: 383206253456204090418195791785818308423831594945,
2160: 393748265201029751587449904786884268416346918520,
2161: 404577789549846859589538794509144411672022826612,
2162: 415702600329676409598230534926593885982499170401,
2163: 427130679749354783768755297437892949499654467597,
2164: 438870223937296523272831771890659665602286473475,
2165: 450929648625159134260052749493609306300370136632,
2166: 463317594981220971649101966934064855005088490212,
2167: 476042935597381937471938911243959272191670950572,
2168: 489114780633797957215706040263930987465371910798,
2169: 502542484125264022730810437527574105649622691760,
2170: 516335650453567079927347553251246871212620557984,
2171: 530504140990139261462232960508189648909724886170,
2172: 545058080913453988432836606455557467047353067377,
2173: 560007866205722361999363584087410496745060913524,
2174: 575364170833565108914383039346175332072363129225,
2175: 591137954117456209042263051672264094963902965317,
2176: 607340468294858294890172396576637459876728673686,
2177: 623983266282097051667127111749751355541610352255,
2178: 641078209640152242143041148426227499209194350336,
2179: 658637476749676716333547258428298949880301221655,
2180: 676673571200691926609848235322274189175428592431,
2181: 695199330402549141183113024435698489390907024630,
2182: 714227934419889822186067591088150189762713935508,
2183: 733772915040486600160233205517764582904605949651,
2184: 753848165080998028345195047409661205734061410010,
2185: 774467947936825933802831039011913166290856798904,
2186: 795646907382423796556925927113569848920749045025,
2187: 817400077628568283525440629036885986580578161120,
2188: 839742893643273944545131128461036809985928936965,
2189: 862691201743203249313515607587263855592485446510,
2190: 886261270462600715344592984957682094231262687955,
2191: 910469801706960959527768615813845716032362752763,
2192: 935333942198826213870111109341848015258586306792,
2193: 960871295223299296636466125655717340185883228697,
2194: 987099932681053343467853379878084516482176109430,
2195: 1014038407456819902258601282188003020164821077713,
2196: 1041705766111542406799393149921058024912789843193,
2197: 1070121561906592696806185003711836723976318646033,
2198: 1099305868168664278558814578725663660095230751347,
2199: 1129279292004177556899411779284367814322107068750,
2200: 1160062988372259455129906418328374912794875140516,
2201: 1191678674525592817234330378465180518007035567938,
2202: 1224148644828669903250292851179037002332204681842,
2203: 1257495785963229293609758350537517985043490101070,
2204: 1291743592530906765707814604565428064732892610835,
2205: 1326916183063388353539586696826007823016666575690,
2206: 1363038316450618010620081932775702626766948267742,
2207: 1400135408797883233268006240578157606704308520406,
2208: 1438233550722879835539717164127729784341377881813,
2209: 1477359525104141972742451850876428128946776467300,
2210: 1517540825292515665993072463432902551892845533240,
2211: 1558805673797653668641491334803497135876242089678,
2212: 1601183041461816724044580259727354612842328867083,
2213: 1644702667133581285344348736857245137869671730074,
2214: 1689395077854376798567156661483099222514277324220,
2215: 1735291609571106892437555774714449031725527460139,
2216: 1782424428388448478757191595009703327418571383436,
2217: 1830826552374771058174587388568897962322872702465,
2218: 1880531873935975665104704330318867749822093808655,
2219: 1931575182771919095318938056959674511017686068185,
2220: 1983992189430464568754141912398798172706580941262,
2221: 2037819549474585022525115674537508812727151594151,
2222: 2093094888278340044956073813211683523416074682898,
2223: 2149856826467952296650447653773869417501164619869,
2224: 2208145006024624371311040214176565237134381870625,
2225: 2268000117066162685610486257867691977952149636083,
2226: 2329463925324911418747662088887963091854286975547,
2227: 2392579300339947019867081675868949317697298397221,
2228: 2457390244381942643492189138307718097264928854677,
2229: 2523941922129582344692758164350149756471869195790,
2230: 2592280691116887259141942758496845583141659899537,
2231: 2662454132971310608073787558386111506684369385813,
2232: 2734511085462965511444391934177140596906494183587,
2233: 2808501675385869578994261445169376899379754972068,
2234: 2884477352292623400907075579322579400861330771315,
2235: 2962490923104486707892612022451087039141493329190,
2236: 3042596587619376453548710860694923114675620792521,
2237: 3124849974940885736970186673957557524827120772983,
2238: 3209308180852011686602310843936272621314792055526,
2239: 3296029806157884531966398832249411659082252110525,
2240: 3385074996022409471869790373849802994298808805690,
2241: 3476505480324367989101580130555189921672623462046,
2242: 3570384615059176354982401320439389024740905215964,
2243: 3666777424813166614813801947045518673161561892966,
2244: 3765750646337939759592154130429553527537766985115,
2245: 3867372773253042492891322334008521298830352179629,
2246: 3971714101905938427653556222571377434088646307540,
2247: 4078846778418982139592272233327190495676444439866,
2248: 4188844846953860716858469962505733762730156946697,
2249: 4301784299224742745702713528067084946594634381000,
2250: 4417743125292169536796493320206228992803910550343,
2251: 4536801365670538316236136117174461033288094273661,
2252: 4659041164782862580763013973003868359053553220232,
2253: 4784546825797351362566231731168417844332785838733,
2254: 4913404866881227292111965728061869527659853830530,
2255: 5045704078908103627757617096847635981526636026359,
2256: 5181535584656163391837451036356625290841516214407,
2257: 5320992899535329981545125277691916180855473998805,
2258: 5464171993882588690437588095807084889323827738187,
2259: 5611171356865613078294130300389571289206397311350,
2260: 5762092062035869673687412904560243239930531635515,
2261: 5917037834573419710379575999541430738890622626340,
2262: 6076115120266708126452900640242923623341866228338,
2263: 6239433156271728550695355451490575993085942292134,
2264: 6407104043696079137218319509378718229702705761905,
2265: 6579242822054578576274630855578948789533455298734,
2266: 6755967545644295113522674510292835122483775946206,
2267: 6937399361888054675782970897485983723264323011797,
2268: 7123662591696737970806754341094737575112103730614,
2269: 7314884811901951462222340761939935289641834289395,
2270: 7511196939811964197947649707463044206175866380723,
2271: 7712733319945142389521924617582058172801542180874,
2272: 7919631812996487219317452100595913257543028088576,
2273: 8132033887094289430962576814720449927838393960827,
2274: 8350084711405357694774361105408889911972402015300,
2275: 8573933252148757415018198504928925593185861873742,
2276: 8803732371079513461579268567498022304249933730391,
2277: 9039638926505285189617314422998964084970595438542,
2278: 9281813876900616004271298745383250743059729594527,
2279: 9530422387184993604151073155371828079705355168950,
2280: 9785633937732631891816046069641124632254214557235,
2281: 10047622436183602390848394841406802515973193043806,
2282: 10316566332127702901769041143039403233989122380996,
2283: 10592648734734255132957468343310308444321456043571,
2284: 10876057533402872254341014560334244700946683620780,
2285: 11166985521512132864360358955503173717957792328653,
2286: 11465630523345040885726361109312137419668093929920,
2287: 11772195524272142592252579142228927699835475405262,
2288: 12086888804275213526126666074714236379441857513978,
2289: 12409924074896520730686758323108856061617655222490,
2290: 12741520619700810766902679602920740106349316265795,
2291: 13081903438339372702369995825105861818651826992639,
2292: 13431303394307778991751050067148151893379620506077,
2293: 13789957366491217272065156663906255405414311071587,
2294: 14158108404593693973445004415760318309772932242370,
2295: 14536005888549817728742960090051403934327801222156,
2296: 14923905692020358321733692442892587286459907678047,
2297: 15322070350075326847761463298913968554265401515217,
2298: 15730769231170936413643835624649288938501733002618,
2299: 16150278713529481654471379166675899361510665760775,
2300: 16580882366033921211442301450921091904365926280416,
2301: 17022871133751761754598643267756804218108498650480,
2302: 17476543528205726845562009156571175360531579106807,
2303: 17942205822511650658087298129211531345495818175057,
2304: 18420172251507067091174412069974707159021665744880,
2305: 18910765216997070947078996545777114475682919623589,
2306: 19414315498247211476154846356983916621521411447697,
2307: 19931162467856441629277246980513463599759674413041,
2308: 20461654313146490770914182133145338856645809727187,
2309: 21006148263207456404192932627622104852595304280970,
2310: 21565010821742923705373368869534441911701199887419,
2311: 22138618005861522471365237940368652982888104075000,
2312: 22727355590965521614482418924663783733921186781149,
2313: 23331619361890843810727406215610806254135308857160,
2314: 23951815370456759593096244705083096637451017834880,
2315: 24588360199587493406897494649744406335205727290057,
2316: 25241681234172046294108468111219387029991510514102,
2317: 25912216938832713390963025920891990759428674050912,
2318: 26600417142777051809706408361950504454660772072685,
2319: 27306743331912438295458811467722364839525869129400,
2320: 28031668948406848928849481174161195141360108410956,
2321: 28775679697884097775242882020060349688803476984805,
2322: 29539273864446490518541231137563989837057604952179,
2323: 30322962633722685585711432023667002655631855893969,
2324: 31127270424143511960418282768032077800615961592375,
2325: 31952735226653572764265207581869821725011637243487,
2326: 32799908953071669788426324706615644528794262188810,
2327: 33669357793318419597396187557448074241909961160527,
2328: 34561662581734899786701292837993789078148269659948,
2329: 35477419172721767722086620675579581559062365395875,
2330: 36417238825934036963035091771377814636876895938849,
2331: 37381748601272582004301821355152191840543933044480,
2332: 38371591763919473464910961559285225914454949449279,
2333: 39387428199670427009917909560877277324279071654230,
2334: 40429934840823983789090419362572880622618841036000,
2335: 41499806102893531791299424581039874366426784160676,
2336: 42597754332414930108684698464207986438238414531147,
2337: 43724510266129315639709919648795164529190983190550,
2338: 44880823501827658290753362113015735891775860228025,
2339: 46067462981150790416506320013365490407603364278280,
2340: 47285217484645973326080769865489605746387338228688,
2341: 48534896139388582534016509015707084448606794509814,
2342: 49817328939485198519236927086579980055136752412153,
2343: 51133367279782285645165745517535680609133370052296,
2344: 52483884503112733276871946748564813602003527319855,
2345: 53869776461420824806590383880147822175719204551469,
2346: 55291962091114697184508819760614991511857392669436,
2347: 56751384003004060684283391440819878903446789803099,
2348: 58249009087189871171927544609837628960380623034142,
2349: 59785829133281790377677305788784327434428364970750,
2350: 61362861466328639006942053695686748622617850877171,
2351: 62981149598856648513992946515066172932792511110884,
2352: 64641763899420155681002068750650481144652897951882,
2353: 66345802278079465613952539750862814246981008871159,
2354: 68094390889230939345801166300675543634997580023495,
2355: 69888684852224948030989898005576415781403878920995,
2356: 71729868990218182977254525351745038902483193889528,
2357: 73619158587717925895914811729724245783180985354842,
2358: 75557800167287273321320320811040130784252221919060,
2359: 77547072285891979874115998945868567670402747044445,
2360: 79588286351381543804941144999617740627898062871643,
2361: 81682787459609412105690788920445375282931841060492,
2362: 83831955252709738636327407566454519669269037443061,
2363: 86037204799060994583504133500298291142599767525961,
2364: 88299987495479913719532319572840702828357104994815,
2365: 90621791992202763126914659986946872015595738278003,
2366: 93004145141224771243446359569837640488487305606833,
2367: 95448612968582727407224954007027627693270062216153,
2368: 97956801671180298878693599735216669857785613237715,
2369: 100530358638770501129135789786132580428696541463525,
2370: 103170973501725013759939661850158896906366983382795,
2371: 105880379205235666714568162057607929186246674835477,
2372: 108660353110609438642727243903401536959027659486124,
2373: 111512718124334720773264584058717478384571245088082,
2374: 114439343855613415076071522953096149591716910973500,
2375: 117442147803070664704054798350668120890654926300513,
2376: 120523096571371667803183996442776155815729810091602,
2377: 123684207118493113105268436573489685721321552781151,
2378: 126927548034415307868377394917913546501247383867613,
2379: 130255240852020056553944404306572055559539047530145,
2380: 133669461390998803240347188535274022509125836065110,
2381: 137172441135595483551688849972013947996581871778170,
2382: 140766468647028954484433593096055372616292751308832,
2383: 144453891011460794882135190497537058556764977948995,
2384: 148237115324395707667015292482470242745754168289775,
2385: 152118610212423719809411357105042520067307779240520,
2386: 156100907393235880227548485941067592747534460439448,
2387: 160186603274868212495995174730244824826286924759060,
2388: 164378360595152301854136694694118079266206458932708,
2389: 168678910102375098323537690529566365095195830119715,
2390: 173091052278175313875346442702502205694341724313429,
2391: 177617659103729195986746184184236646145304254737028,
2392: 182261675870304487388520687355584130250935690880972,
2393: 187026123035288047490867195922886699634867141186408,
2394: 191914098124819930404162679326110679178204492902970,
2395: 196928777684194703542432119373410255613845416290627,
2396: 202073419277219465790162920942761564437025278844409,
2397: 207351363535747401800832745531222095970123079470866,
2398: 212766036260635806253027202800291886071043511130893,
2399: 218320950575408346303872686615815518603736687265550,
2400: 224019709133932919957689061390552862746031758458304,
2401: 229866006383458830949778967121025947053151071434926,
2402: 235863630884390155812442175854014517889393984836232,
2403: 242016467688206145276344061824939391497289921344319,
2404: 248328500774974299762177021852107412058234599633660,
2405: 254803815551937407606287486346848530864431251682411,
2406: 261446601414692355496335282873363983668020889836360,
2407: 268261154372515934523018586706764224652758295238166,
2408: 275251879739431193944393927980843975448015734231456,
2409: 282423294892647160394499527988292633580813431968720,
2410: 289780032100044965565638185282633831588088504297253,
2411: 297326841418424633617945474627449518623223932967198,
2412: 305068593664268994544312629723329236676843814611957,
2413: 313010283458824435839645487672681448751536128120719,
2414: 321157032349342507073515697424466804962980378707300,
2415: 329514092008371775927573078641257544141430283832310,
2416: 338086847513035826131406156272669425469096435441169,
2417: 346880820706280914339971199061511110032851886967137,
2418: 355901673642125591813707043622534952223283339280101,
2419: 365155212116994575920151188842851740380508864908970,
2420: 374647389289270354779812696943359199223073776527524,
2421: 384384309389248455327267290257609074709972871788879,
2422: 394372231521736030856900123129107963761511852907062,
2423: 404617573563588459702218138566029837845857058362469,
2424: 415126916158535023731030449746058156911457360217500,
2425: 425907006811702486258611691435747829051036619210903,
2426: 436964764086304546997571902667823798077679571339689,
2427: 448307281905025750783203518734071850525930124835870,
2428: 459941833958690501858441260833172834575927050017497,
2429: 471875878224871422129752689802003581309719671216145,
2430: 484117061599156426525236728117223720907832020184888,
2431: 496673224641860608784678055946833883950031191035725,
2432: 509552406443037374969583492229383313416835733059701,
2433: 522762849608713268897451362983651906277382721179854,
2434: 536313005371342643715460083111040042096768651944785,
2435: 550211538827551788032090316191702467148009553891765,
2436: 564467334306317355502338280181042531694130943361929,
2437: 579089500870801016601654991798984624538203584674550,
2438: 594087377957141194645081615027313378657219091976058,
2439: 609470541153583610086244251156702088407546864564250,
2440: 625248808123415184021445170239142357065496320226974,
2441: 641432244675250690988723453000798446534275367015717,
2442: 658031170984308451084537723836848917759126780943929,
2443: 675056167968400361774985057979390540476824195499264,
2444: 692518083822452741394297527894579793217444427279865,
2445: 710428040715467841255717203419691810125435835218542,
2446: 728797441653931534847387578562876222605215306007682,
2447: 747637977515770665320414243823232108546943571791584,
2448: 766961634259063882272862309538971496456501841189299,
2449: 786780700309812582901493233837104883069651992252500,
2450: 807107774133183849507621375104362485942528919417094,
2451: 827955771992745105077858611205558631300937454362243,
2452: 849337935902320652619232737317794449777545949179711,
2453: 871267841775213384980863950063063429886904651528812,
2454: 893759407775650814410526929963928966861696330836200,
2455: 916826902877433240978780331677009554236212353692084,
2456: 940484955634883423732306479679700600136395142799772,
2457: 964748563171321607096873785043308907920748393645865,
2458: 989633100390417258370972350733200785584553946028102,
2459: 1015154329415899462551538855668088513315200292902465,
2460: 1041328409265241672356796753836476758668568608962817,
2461: 1068171905763073500068056689718618672673472054705623,
2462: 1095701801700212541420510934836771894810436524644206,
2463: 1123935507244352919801698227500042488236652668362464,
2464: 1152890870608594412929146690100187865796230009117415,
2465: 1182586188984146757378861272237745685156851393567877,
2466: 1213040219743698104212153283094735988868458164856735,
2467: 1244272191922094708920237946746471334658921810675089,
2468: 1276301817981140870474529866246359687648227775992726,
2469: 1309149305865493979065272921268867078953610074980355,
2470: 1342835371356799383941072744632607586619060990003342,
2471: 1377381250733383747666895193431311551421473834674537,
2472: 1412808713743003709421434478836269410607157240633931,
2473: 1449140076896329138317020116671377802568526770518725,
2474: 1486398217089027121199419785627770438512228407175000,
2475: 1524606585560504203472825372845600976263733665501642,
2476: 1563789222197560394205351099996482830581156974888244,
2477: 1603970770191409168676519057930382172908445935119463,
2478: 1645176491056723265830534175841536314124424257900655,
2479: 1687432280021576600685684487181671811367617087501755,
2480: 1730764681797368211260238937556940484156749101230455,
2481: 1775200906738034957464112810216480762332001678674799,
2482: 1820768847398085810011063048337611865735620543349686,
2483: 1867497095499222138016227017428624557231848665351291,
2484: 1915414959315545554866069359053268627009894091487255,
2485: 1964552481487597746580633524928622127514294053468578,
2486: 2014940457275725421793253569605575859047900517862975,
2487: 2066610453263518227450300026070406061787487374956619,
2488: 2119594826522328312496888837397949369108992226003579,
2489: 2173926744248147339669532102906132397617461595649235,
2490: 2229640203882390293040946390903966696602633829194840,
2491: 2286770053728415559686499093247615980043870048333375,
2492: 2345352014075897634933772608434944801289607520822444,
2493: 2405422698845462573006497019894423614036351120521629,
2494: 2467019637766297143181469675691820929552138013921170,
2495: 2530181299099750724441152937967329319658147447405249,
2496: 2594947112922264451615392923126900249342712365881980,
2497: 2661357494981285189837685277991457183899724929972336,
2498: 2729453871138152742649660700418835108908145695065284,
2499: 2799278702412287477405614444445747930301938442180000,
2500: 2870875510641352469269629800993561138276373608937244,
2501: 2944288904772419516055596903431635682611440388817684,
2502: 3019564607799532159016586951616642980389816614848623,
2503: 3096749484363431362720513648966835225350796839944705,
2504: 3175891569029590968434327113853291229809825601961265,
2505: 3257040095261100652976951554528119114719453404725007,
2506: 3340245525103334116822171147466786507458445890183988,
2507: 3425559579597749814517587789768024144026745140376550,
2508: 3513035269942590955686749126214187667970579050845937,
2509: 3602726929418680979845445364711401806180203650663725,
2510: 3694690246098950482357992748748848483474524052004611,
2511: 3788982296360781887103496312666448565688651771156677,
2512: 3885661579220719274616818998490729558629719751838590,
2513: 3984788051511562939333648375836061468352863107532895,
2514: 4086423163922351728879727101483809741806177963555690,
2515: 4190629897922231281075551233411026977189480304097898,
2516: 4297472803589713195797719954967455347047259565521535,
2517: 4407018038369349240856665212333154882125704077589469,
2518: 4519333406778376182071537408268876717047377660539309,
2519: 4634488401086431042999613202320599056013666269808095,
2520: 4752554242991993841520963249414089899868727306156151
}
def exp_sum(number):
if number < 0:
return 0
return ANSWERS[number]
| Explosive Sum | 52ec24228a515e620b0005ef | [
"Algorithms",
"Mathematics",
"Fundamentals"
] | https://www.codewars.com/kata/52ec24228a515e620b0005ef | 4 kyu |
Return the number (count) of vowels in the given string.
We will consider `a`, `e`, `i`, `o`, `u` as vowels for this Kata (but not `y`).
The input string will only consist of lower case letters and/or spaces.
| reference | def getCount(inputStr):
return sum(1 for let in inputStr if let in "aeiouAEIOU")
| Vowel Count | 54ff3102c1bad923760001f3 | [
"Strings",
"Fundamentals"
] | https://www.codewars.com/kata/54ff3102c1bad923760001f3 | 7 kyu |
You are the greatest chef on earth. No one boils eggs like you! Your restaurant is always full of guests, who love your boiled eggs. But when there is a greater order of boiled eggs, you need some time, because you have only one pot for your job. How much time do you need?
## Your Task
Implement a function, which takes a non-negative integer, representing the number of eggs to boil. It must return the time in minutes (integer), which it takes to have all the eggs boiled.
## Rules
* you can put at most 8 eggs into the pot at once
* it takes 5 minutes to boil an egg
* we assume, that the water is boiling all the time (no time to heat up)
* for simplicity we also don't consider the time it takes to put eggs into the pot or get them out of it
## Example (Input --> Output)
```
0 --> 0
5 --> 5
10 --> 10
```
| algorithms | from math import *
def cooking_time(eggs):
return 5 * ceil(eggs / 8.0)
| Boiled Eggs | 52b5247074ea613a09000164 | [
"Mathematics",
"Algorithms"
] | https://www.codewars.com/kata/52b5247074ea613a09000164 | 7 kyu |
Create a function that returns the name of the winner in a fight between two fighters.
Each fighter takes turns attacking the other and whoever kills the other first is victorious. Death is defined as having `health <= 0`.
Each fighter will be a `Fighter` object/instance. See the Fighter class below in your chosen language.
Both `health` and `damagePerAttack` (`damage_per_attack` for python) will be integers larger than `0`. You can mutate the `Fighter` objects.
Your function also receives a third argument, a string, with the name of the fighter that attacks first.
## Example:
```
declare_winner(Fighter("Lew", 10, 2), Fighter("Harry", 5, 4), "Lew") => "Lew"
Lew attacks Harry; Harry now has 3 health.
Harry attacks Lew; Lew now has 6 health.
Lew attacks Harry; Harry now has 1 health.
Harry attacks Lew; Lew now has 2 health.
Lew attacks Harry: Harry now has -1 health and is dead. Lew wins.
```
```javascript
function Fighter(name, health, damagePerAttack) {
this.name = name;
this.health = health;
this.damagePerAttack = damagePerAttack;
this.toString = function() { return this.name; }
}
```
```python
class Fighter(object):
def __init__(self, name, health, damage_per_attack):
self.name = name
self.health = health
self.damage_per_attack = damage_per_attack
def __str__(self): return "Fighter({}, {}, {})".format(self.name, self.health, self.damage_per_attack)
__repr__=__str__
```
```java
public class Fighter {
public String name;
public int health, damagePerAttack;
public Fighter(String name, int health, int damagePerAttack) {
this.name = name;
this.health = health;
this.damagePerAttack = damagePerAttack;
}
}
```
```csharp
public class Fighter {
public string Name;
public int Health, DamagePerAttack;
public Fighter(string name, int health, int damagePerAttack) {
this.Name = name;
this.Health = health;
this.DamagePerAttack = damagePerAttack;
}
}
```
```clojure
Technical note: The second fighter argument (f2) always attacks first.
(defrecord Fighter [name hp attack])
```
```cpp
class Fighter
{
private:
std::string name;
int health;
int damagePerAttack;
public:
Fighter(std::string name, int health, int damagePerAttack)
{
this->name = name;
this->health = health;
this->damagePerAttack = damagePerAttack;
}
~Fighter() { };
std::string getName()
{
return name;
}
int getHealth()
{
return health;
}
int getDamagePerAttack()
{
return damagePerAttack;
}
void setHealth(int value)
{
health = value;
}
};
```
```go
type Fighter struct {
Name string
Health int
DamagePerAttack int
}
```
| reference | def declare_winner(fighter1, fighter2, first_attacker):
cur, opp = (fighter1, fighter2) if first_attacker == fighter1 . name else (
fighter2, fighter1)
while cur . health > 0:
opp . health -= cur . damage_per_attack
cur, opp = opp, cur
return opp . name
| Two fighters, one winner. | 577bd8d4ae2807c64b00045b | [
"Games",
"Algorithms",
"Logic",
"Fundamentals"
] | https://www.codewars.com/kata/577bd8d4ae2807c64b00045b | 7 kyu |
In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number.
### Examples
``` text
Input: "1 2 3 4 5" => Output: "5 1"
Input: "1 2 -3 4 5" => Output: "5 -3"
Input: "1 9 3 4 -5" => Output: "9 -5"
```
```php
highAndLow("1 2 3 4 5"); // return "5 1"
highAndLow("1 2 -3 4 5"); // return "5 -3"
highAndLow("1 9 3 4 -5"); // return "9 -5"
```
```csharp
Kata.HighAndLow("1 2 3 4 5"); // return "5 1"
Kata.HighAndLow("1 2 -3 4 5"); // return "5 -3"
Kata.HighAndLow("1 9 3 4 -5"); // return "9 -5"
```
```fsharp
highAndLow "1 2 3 4 5" // return "5 1"
highAndLow "1 2 -3 4 5" // return "5 -3"
highAndLow "1 9 3 4 -5" // return "9 -5"
```
```javascript
highAndLow("1 2 3 4 5"); // return "5 1"
highAndLow("1 2 -3 4 5"); // return "5 -3"
highAndLow("1 9 3 4 -5"); // return "9 -5"
```
```d
highAndLow("1 2 3 4 5"); // return "5 1"
highAndLow("1 2 -3 4 5"); // return "5 -3"
highAndLow("1 9 3 4 -5"); // return "9 -5"
```
```c
high_and_low("1 2 3 4 5") // return "5 1"
high_and_low("1 2 -3 4 5") // return "5 -3"
high_and_low("1 9 3 4 -5") // return "9 -5"
```
```cpp
highAndLow("1 2 3 4 5"); // return "5 1"
highAndLow("1 2 -3 4 5"); // return "5 -3"
highAndLow("1 9 3 4 -5"); // return "9 -5"
```
```typescript
highAndLow("1 2 3 4 5"); // return "5 1"
highAndLow("1 2 -3 4 5"); // return "5 -3"
highAndLow("1 9 3 4 -5"); // return "9 -5"
```
```coffeescript
highAndLow("1 2 3 4 5") # return "5 1"
highAndLow("1 2 -3 4 5") # return "5 -3"
highAndLow("1 9 3 4 -5") # return "9 -5"
```
```python
high_and_low("1 2 3 4 5") # return "5 1"
high_and_low("1 2 -3 4 5") # return "5 -3"
high_and_low("1 9 3 4 -5") # return "9 -5"
```
```ruby
high_and_low("1 2 3 4 5") # return "5 1"
high_and_low("1 2 -3 4 5") # return "5 -3"
high_and_low("1 9 3 4 -5") # return "9 -5"
```
```crystal
high_and_low("1 2 3 4 5") # return "5 1"
high_and_low("1 2 -3 4 5") # return "5 -3"
high_and_low("1 9 3 4 -5") # return "9 -5"
```
```c
high_and_low("1 2 3 4 5", result) // result "5 1"
high_and_low("1 2 -3 4 5", result) // result "5 -3"
high_and_low("1 9 3 4 -5", result) // result "9 -5"
```
```java
highAndLow("1 2 3 4 5") // return "5 1"
highAndLow("1 2 -3 4 5") // return "5 -3"
highAndLow("1 9 3 4 -5") // return "9 -5"
```
```haskell
highAndLow "1 2 3 4 5") # return "5 1"
highAndLow "1 2 -3 4 5") # return "5 -3"
highAndLow "1 9 3 4 -5") # return "9 -5"
```
```go
HighAndLow("1 2 3 4 5") // return "5 1"
HighAndLow("1 2 -3 4 5") // return "5 -3"
HighAndLow("1 9 3 4 -5") // return "9 -5"
```
```kotlin
highAndLow("1 2 3 4 5") // return "5 1"
highAndLow("1 2 -3 4 5") // return "5 -3"
highAndLow("1 9 3 4 -5") // return "9 -5"
```
```elixir
Kata.high_and_low("1 2 3 4 5") # return "5 1"
Kata.high_and_low("1 2 -3 4 5") # return "5 -3"
Kata.high_and_low("1 9 3 4 -5") # return "9 -5"
```
```clojure
(high-and-low "1 2 3 4 5") ; return "5 1"
(high-and-low "1 2 -3 4 5") ; return "5 -3"
(high-and-low "1 9 3 4 -5") ; return "9 -5"
```
```julia
highandlow("1 2 3 4 5") # return "5 1"
highandlow("1 2 -3 4 5") # return "5 -3"
highandlow("1 9 3 4 -5") # return "9 -5"
```
```rust
high_and_low("1 2 3 4 5") // return "5 1"
high_and_low("1 2 -3 4 5") // return "5 -3"
high_and_low("1 9 3 4 -5") // return "9 -5"
```
```cobol
HighAndLow("1 2 3 4 5")
* RESULT = "5 1"
HighAndLow("1 2 -3 4 5")
* RESULT = "5 -3"
HighAndLow("1 9 3 4 -5")
* RESULT = "9 -5"
```
```scala
Sol.high_and_low("1 2 3 4 5") // return "5 1"
Sol.high_and_low("1 2 -3 4 5") // return "5 -3"
Sol.high_and_low("1 9 3 4 -5") // return "9 -5"
```
```lua
high_and_low "1 2 3 4 5" --> return "5 1"
high_and_low "1 2 -3 4 5" --> return "5 -3"
high_and_low "1 9 3 4 -5" --> return "9 -5"
```
### Notes
- All numbers are valid ```Int32```, no *need* to validate them.
- There will always be at least one number in the input string.
- Output string must be two numbers separated by a single space, and highest number is first.
| reference | def high_and_low(numbers): # z.
nn = [int(s) for s in numbers . split(" ")]
return "%i %i" % (max(nn), min(nn))
| Highest and Lowest | 554b4ac871d6813a03000035 | [
"Fundamentals",
"Strings"
] | https://www.codewars.com/kata/554b4ac871d6813a03000035 | 7 kyu |
Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number.
### Example
```javascript
createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"
```
```cpp
createPhoneNumber(int[10]{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}) // => returns "(123) 456-7890"
```
```crystal
create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns "(123) 456-7890"
```
```ruby
createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns "(123) 456-7890"
```
```coffeescript
createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns "(123) 456-7890"
```
```java
Kata.createPhoneNumber(new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}) // => returns "(123) 456-7890"
```
```dart
createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"
```
```haskell
createPhoneNumber [1,2,3,4,5,6,7,8,9,0] -- => returns "(123) 456-7890"
```
```csharp
Kata.CreatePhoneNumber(new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}) // => returns "(123) 456-7890"
```
```fsharp
createPhoneNumber [1; 2; 3; 4; 5; 6; 7; 8; 9; 0] // => returns "(123) 456-7890"
```
```python
create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns "(123) 456-7890"
```
```scala
Kata.createPhoneNumber(Seq(1, 2, 3, 4, 5, 6, 7, 8, 9, 0)) # => returns "(123) 456-7890"
```
```php
createPhoneNumber([1,2,3,4,5,6,7,8,9,0]); // => returns "(123) 456-7890"
```
```f#
createPhoneNumber [1; 2; 3; 4; 5; 6; 7; 8; 9; 0] // => returns "(123) 456-7890"
```
```clojure
(create-phone-number [1 2 3 4 5 6 7 8 9 0]) ;; => returns "(123) 456-7890"
```
```rust
create_phone_number(&[1,2,3,4,5,6,7,8,9,0]); // returns "(123) 456-7890"
```
```go
CreatePhoneNumber([10]uint{1,2,3,4,5,6,7,8,9,0}) // returns "(123) 456-7890"
```
```c
create_phone_number(phnum, (const unsigned char[]){1,2,3,4,5,6,7,8,9,0});
/* phnum <- "(123) 456-7890" */
```
```nasm
phnum: resb 15
nums: db 1,2,3,4,5,6,7,8,9,0
mov rdi, phnum
mov rsi, nums
call create_phone_number ; RAX <- phnum <- "(123) 456-7890"
```
```typescript
createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890"
```
```julia
createphonenumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # -> returns "(123) 456-7890"
```
```cfml
createPhoneNumber( [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] ) // => returns "(123) 456-7890"
```
```factor
{ 1 2 3 4 5 6 7 8 9 0 } create-phone-number ! returns "(123) 456-7890"
```
```lua
create_phone_number({ 1,2,3,4,5,6,7,8,9,0 }) -- => returns "(123) 456-7890"
```
The returned format must be correct in order to complete this challenge.
Don't forget the space after the closing parentheses!
| algorithms | def create_phone_number(n):
return "({}{}{}) {}{}{}-{}{}{}{}".format(*n)
| Create Phone Number | 525f50e3b73515a6db000b83 | [
"Arrays",
"Strings",
"Regular Expressions",
"Algorithms"
] | https://www.codewars.com/kata/525f50e3b73515a6db000b83 | 6 kyu |
Write a function that takes an array of numbers and returns the sum of the numbers. The numbers can be negative or non-integer. If the array does not contain any numbers then you should return 0.
### Examples
Input: `[1, 5.2, 4, 0, -1]`
Output: `9.2`
Input: `[]`
Output: `0`
Input: `[-2.398]`
Output: `-2.398`
### Assumptions
- You can assume that you are only given numbers.
- You cannot assume the size of the array.
- You can assume that you do get an array and if the array is empty, return 0.
~~~if:java
Tests expect accuracy of `1e-4`.
~~~
### What We're Testing
We're testing basic loops and math operations. This is for beginners who are just learning loops and math operations.
Advanced users may find this extremely easy and can easily write this in one line.
| reference | def sum_array(a):
return sum(a)
| Sum Arrays | 53dc54212259ed3d4f00071c | [
"Arrays",
"Fundamentals"
] | https://www.codewars.com/kata/53dc54212259ed3d4f00071c | 8 kyu |
The two oldest ages function/method needs to be completed. It should take an array of numbers as its argument and return the **two highest numbers within the array**. The returned value should be an array in the format `[second oldest age, oldest age]`.
The order of the numbers passed in could be any order. The array will always include at least 2 items. If there are two or more oldest age, then return both of them in array format.
**For example (Input --> Output):**
```
[1, 2, 10, 8] --> [8, 10]
[1, 5, 87, 45, 8, 8] --> [45, 87]
[1, 3, 10, 0]) --> [3, 10]
``` | algorithms | def two_oldest_ages(ages):
return sorted(ages)[- 2:]
| Two Oldest Ages | 511f11d355fe575d2c000001 | [
"Arrays",
"Algorithms"
] | https://www.codewars.com/kata/511f11d355fe575d2c000001 | 7 kyu |
Complete the function that takes a non-negative integer `n` as input, and returns a list of all the powers of `2` with the exponent ranging from `0` to `n` ( inclusive ).
## Examples
```python
n = 0 ==> [1] # [2^0]
n = 1 ==> [1, 2] # [2^0, 2^1]
n = 2 ==> [1, 2, 4] # [2^0, 2^1, 2^2]
```
```bf
n = String.fromCharCode(0) ==> String.fromCharCode(1)
n = String.fromCharCode(1) ==> String.fromCharCode(1) + String.fromCharCode(2)
n = String.fromCharCode(2) ==> String.fromCharCode(1) + String.fromCharCode(2) + String.fromCharCode(4)
```
~~~if:lambdacalc
## Encodings
`purity: LetRec`
`numEncoding: BinaryScott`
export `foldr` for your `List` encoding
~~~
~~~if:riscv
RISC-V: The function signature is:
```c
void powers_of_two(size_t n, uint64_t powers[n + 1]);
```
Write the result to `powers`. You may assume it is large enough to hold the result. You should not return anything.
~~~
~~~if:bf
- Since BF doesn't have arrays, you should output each element individually.
- Outputs will always fit within a byte
~~~
| reference | def powers_of_two(n):
return [2 * * x for x in range(n + 1)]
| Powers of 2 | 57a083a57cb1f31db7000028 | [
"Mathematics",
"Fundamentals"
] | https://www.codewars.com/kata/57a083a57cb1f31db7000028 | 8 kyu |
You are given the `length` and `width` of a 4-sided polygon. The polygon can either be a rectangle or a square.
If it is a square, return its area. If it is a rectangle, return its perimeter.
**Example(Input1, Input2 --> Output):**
```
6, 10 --> 32
3, 3 --> 9
```
**Note:** for the purposes of this kata you will assume that it is a square if its `length` and `width` are equal, otherwise it is a rectangle.
| reference | def area_or_perimeter(l, w):
return l * w if l == w else (l + w) * 2
| Area or Perimeter | 5ab6538b379d20ad880000ab | [
"Fundamentals",
"Mathematics",
"Geometry"
] | https://www.codewars.com/kata/5ab6538b379d20ad880000ab | 8 kyu |
You are given a string with results of NBA teams (see the data in "Sample Tests") separated by commas e.g:
r =
`Los Angeles Clippers 104 Dallas Mavericks 88,New York Knicks 101 Atlanta Hawks 112,Indiana Pacers 103 Memphis Grizzlies 112,
Los Angeles Clippers 100 Boston Celtics 120`.
A team name is composed of one, two or more words built with letters or digits: `Atlanta Hawks`, `Philadelphia 76ers`...
Given a string of results and the name of a team (parameter : to_find) your function `nba_cup (or nbaCup or ...) ` will return as a string
- the name of the team followed by `:` and
- the number of matches won by the team
- the number of draws
- the number of matches lost by the team
- the total number of points scored by the team
- the total number of points conceded by the team
and finally a kind of marks in our ranking system
- a team marks `3` if it is a win
- a team marks `1` if it is a draw
- a team marks `0` if it is a loss.
The return format is:
```
"Team Name:W=nb of wins;D=nb of draws;L=nb of losses;Scored=nb;Conceded=nb;Points=nb"
```
#### Remarks:
The team name `""` returns `""`.
If a team name can't be found in the given string of results you will return `"Team Name:This team didn't play!"` (See examples below).
The scores must be integers. If a score is a float number (`abc.xyz...`) you will return:
"Error(float number):the concerned string"
#### Examples:
```
nba_cup(r, "Los Angeles Clippers") -> "Los Angeles Clippers:W=1;D=0;L=1;Scored=204;Conceded=208;Points=3"
nba_cup(r, "Boston Celtics") -> "Boston Celtics:W=1;D=0;L=0;Scored=120;Conceded=100;Points=3"
nba_cup(r, "") -> ""
nba_cup(r, "Boston Celt") -> "Boston Celt:This team didn't play!"
r0="New York Knicks 101.12 Atlanta Hawks 112"
nba_cup(r0, "Atlanta Hawks") -> "Error(float number):New York Knicks 101.12 Atlanta Hawks 112"
``` | reference | import re
def nba_cup(result_sheet, team):
if not team:
return ""
wins, draws, losses, points, conced = 0, 0, 0, 0, 0
for t1, p1, t2, p2 in re . findall(r'(.+?) (\b[\d.]+\b) (.+?) (\b[\d.]+\b)(?:,|$)', result_sheet):
if '.' in p1 or '.' in p2:
return "Error(float number):{} {} {} {}" . format(t1, p1, t2, p2)
if team == t1 or team == t2:
ptsTeam, ptsOther = map(int, (p1, p2) if t1 == team else (p2, p1))
points += ptsTeam
conced += ptsOther
if ptsTeam == ptsOther:
draws += 1
elif ptsTeam < ptsOther:
losses += 1
else:
wins += 1
overAllScore = 3 * wins + draws
return ("{}:This team didn't play!" if not points and not losses else
"{}:W={};D={};L={};Scored={};Conceded={};Points={}"). format(team, wins, draws, losses, points, conced, overAllScore)
| Ranking NBA teams | 5a420163b6cfd7cde5000077 | [
"Fundamentals",
"Strings"
] | https://www.codewars.com/kata/5a420163b6cfd7cde5000077 | 6 kyu |
Given a string of digits, you should replace any digit below 5 with '0' and any digit 5 and above with '1'. Return the resulting string.
**Note: input will never be an empty string**
| reference | def fake_bin(x):
return '' . join('0' if c < '5' else '1' for c in x)
| Fake Binary | 57eae65a4321032ce000002d | [
"Fundamentals",
"Strings",
"Arrays"
] | https://www.codewars.com/kata/57eae65a4321032ce000002d | 8 kyu |
Complete the function which converts hex number (given as a string) to a decimal number. | reference | def hex_to_dec(s):
return int(s, 16)
| Hex to Decimal | 57a4d500e298a7952100035d | [
"Fundamentals"
] | https://www.codewars.com/kata/57a4d500e298a7952100035d | 8 kyu |
<p>
Write a function that receives two strings and returns n, where n is equal to the number of characters we should shift the first string forward to match the second. The check should be case sensitive.
</p>
<p>For instance, take the strings "fatigue" and "tiguefa". In this case, the first string has been rotated 5 characters forward to produce the second string, so 5 would be returned.</p>
If the second string isn't a valid rotation of the first string, the method returns -1.
<h3 class="mtn">Examples:</h3>
```
"coffee", "eecoff" => 2
"eecoff", "coffee" => 4
"moose", "Moose" => -1
"isn't", "'tisn" => 2
"Esham", "Esham" => 0
"dog", "god" => -1
```
```if:swift
For Swift, your function should return an `Int?`. So rather than returning `-1` when the second string isn't a valid rotation of the first, return `nil`.
~~~swift
shiftedDiff("coffee", "eecoff") => 2
shiftedDiff("eecoff", "coffee") => 4
shiftedDiff("moose", "Moose") => nil
shiftedDiff("isn't", "'tisn") => 2
shiftedDiff("Esham", "Esham") => 0
shiftedDiff("dog", "god") => nil
~~~
```
```if:rust
In Rust your function should return `Option<usize>`. Rather than returning `-1` when the second string isn't a valid rotation of the first, return `None`.
~~~rust
shifted_diff("coffee", "eecoff") => Some(2)
shifted_diff("eecoff", "coffee") => Some(4)
shifted_diff("moose", "Moose") => None
shifted_diff("isn't", "'tisn") => Some(2)
shifted_diff("Esham", "Esham") => Some(0)
shifted_diff("dog", "god") => None
~~~
```
| algorithms | def shifted_diff(first, second):
return (second + second). find(first) if len(first) == len(second) else - 1
| Calculate String Rotation | 5596f6e9529e9ab6fb000014 | [
"Strings",
"Arrays",
"Algorithms"
] | https://www.codewars.com/kata/5596f6e9529e9ab6fb000014 | 6 kyu |
If you finish this kata, you can try [Insane Coloured Triangles](http://www.codewars.com/kata/insane-coloured-triangles) by Bubbler, which is a ***much*** harder version of this one.
A coloured triangle is created from a row of colours, each of which is red, green or blue. Successive rows, each containing one fewer colour than the last, are generated by considering the two touching colours in the previous row. If these colours are identical, the same colour is used in the new row. If they are different, the missing colour is used in the new row. This is continued until the final row, with only a single colour, is generated.
The different possibilities are:
```
Colour here: G G B G R G B R
Becomes colour: G R B G
```
With a bigger example:
```
R R G B R G B B
R B R G B R B
G G B R G G
G R G B G
B B R R
B G R
R B
G
```
You will be given the first row of the triangle as a string and its your job to return the final colour which would appear in the bottom row as a string. In the case of the example above, you would the given `RRGBRGBB` you should return `G`.
* The input string will only contain the uppercase letters `R, G, B` and there will be at least one letter so you do not have to test for invalid input.
* If you are only given one colour as the input, return that colour.
*Adapted from the 2017 British Informatics Olympiad* | algorithms | COLORS = set("RGB")
def triangle(row):
while len(row) > 1:
row = '' . join(a if a == b else (
COLORS - {a, b}). pop() for a, b in zip(row, row[1:]))
return row
| Coloured Triangles | 5a25ac6ac5e284cfbe000111 | [
"Logic",
"Strings",
"Algorithms"
] | https://www.codewars.com/kata/5a25ac6ac5e284cfbe000111 | 7 kyu |
### A square of squares
You like building blocks. You especially like building blocks that are squares. And what you even like more, is to arrange them into a square of square building blocks!
However, sometimes, you can't arrange them into a square. Instead, you end up with an ordinary rectangle! Those blasted things! If you just had a way to know, whether you're currently working in vain… Wait! That's it! You just have to check if your number of building blocks is a _perfect square_.
### Task
Given an integral number, determine if it's a [square number](https://en.wikipedia.org/wiki/Square_number):
> In mathematics, a __square number__ or __perfect square__ is an integer that is the square of an integer; in other words, it is the product of some integer with itself.
The tests will _always_ use some integral number, so don't worry about that in dynamic typed languages.
### Examples
```
-1 => false
0 => true
3 => false
4 => true
25 => true
26 => false
```
~~~if:lambdacalc
### Encodings
purity: `LetRec`
numEncoding: `BinaryScott` ( so no negative numbers )
export deconstructor `if` for your `Boolean` encoding
~~~ | reference | import math
def is_square(n):
return n > - 1 and math . sqrt(n) % 1 == 0
| You're a square! | 54c27a33fb7da0db0100040e | [
"Fundamentals",
"Mathematics"
] | https://www.codewars.com/kata/54c27a33fb7da0db0100040e | 7 kyu |
It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You don't have to worry about strings with less than two characters.
| reference | def remove_char(s):
return s[1: - 1]
| Remove First and Last Character | 56bc28ad5bdaeb48760009b0 | [
"Strings",
"Fundamentals"
] | https://www.codewars.com/kata/56bc28ad5bdaeb48760009b0 | 8 kyu |
Write function describeList which returns "empty" if the list is empty or "singleton" if it contains only one element or "longer"" if more. | reference | def describeList(lst):
return ["empty", "singleton", "longer"][min(len(lst), 2)]
| Describe a list | 57a4a3e653ba3346bc000810 | [
"Lists",
"Fundamentals"
] | https://www.codewars.com/kata/57a4a3e653ba3346bc000810 | 7 kyu |
Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (`HH:MM:SS`)
* `HH` = hours, padded to 2 digits, range: 00 - 99
* `MM` = minutes, padded to 2 digits, range: 00 - 59
* `SS` = seconds, padded to 2 digits, range: 00 - 59
The maximum time never exceeds 359999 (`99:59:59`)
You can find some examples in the test fixtures. | algorithms | def make_readable(seconds):
hours, seconds = divmod(seconds, 60 * * 2)
minutes, seconds = divmod(seconds, 60)
return '{:02}:{:02}:{:02}' . format(hours, minutes, seconds)
| Human Readable Time | 52685f7382004e774f0001f7 | [
"Date Time",
"Mathematics",
"Algorithms"
] | https://www.codewars.com/kata/52685f7382004e774f0001f7 | 5 kyu |
The function 'fibonacci' should return an array of fibonacci numbers. The function takes a number as an argument to decide how many no. of elements to produce. If the argument is less than or equal to 0 then return empty array
Example:
```javascript
fibonacci(4) // should return [0,1,1,2]
fibonacci(-1) // should return []
```
```ruby
fibonacci(4); # should return [0,1,1,2]
fibonacci(-1); # should return []
```
```python
fibonacci(4) # should return [0,1,1,2]
fibonacci(-1) # should return []
```
| algorithms | def fibonacci(n):
if n <= 0:
return []
a = 0
b = 1
l = [0]
for i in range(n):
a, b = b, a + b
l . append(a)
return l[0: n]
| Complete Fibonacci Series | 5239f06d20eeab9deb00049b | [
"Algorithms"
] | https://www.codewars.com/kata/5239f06d20eeab9deb00049b | 6 kyu |
Complete the solution so that it reverses the string passed into it.
```
'world' => 'dlrow'
'word' => 'drow'
``` | reference | def solution(str):
return str[:: - 1]
| Reversed Strings | 5168bb5dfe9a00b126000018 | [
"Strings",
"Fundamentals"
] | https://www.codewars.com/kata/5168bb5dfe9a00b126000018 | 8 kyu |
You ask a small girl,"How old are you?" She always says, "x years old", where x is a random number between 0 and 9.
Write a program that returns the girl's age (0-9) as an integer.
Assume the test input string is always a valid string. For example, the test input may be "1 year old" or "5 years old". The first character in the string is always a number.
| reference | def get_age(age):
return int(age[0])
| Parse nice int from char problem | 557cd6882bfa3c8a9f0000c1 | [
"Fundamentals"
] | https://www.codewars.com/kata/557cd6882bfa3c8a9f0000c1 | 8 kyu |
Given a string of words, you need to find the highest scoring word.
Each letter of a word scores points according to its position in the alphabet: `a = 1, b = 2, c = 3` etc.
For example, the score of `abad` is `8` (1 + 2 + 1 + 4).
You need to return the highest scoring word as a string.
If two words score the same, return the word that appears earliest in the original string.
All letters will be lowercase and all inputs will be valid. | reference | def high(x):
return max(x . split(), key=lambda k: sum(ord(c) - 96 for c in k))
| Highest Scoring Word | 57eb8fcdf670e99d9b000272 | [
"Fundamentals",
"Strings",
"Arrays"
] | https://www.codewars.com/kata/57eb8fcdf670e99d9b000272 | 6 kyu |
Removed due to copyright infringement.
<!---
Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on.
For example, Penny drinks the third can of cola and the queue will look like this:
```
Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny
```
Write a program that will return the name of the person who will drink the `n`-th cola.
## Input:
The input data consist of an array which contains at least 1 name, and single integer `n` which may go as high as the biggest number your language of choice supports (if there's such limit, of course).
## Output / Examples:
Return the single line — the name of the person who drinks the n-th can of cola. The cans are numbered starting from 1.
~~~if-not:nasm
```rust
let names = &vec![Name::Sheldon, Name::Leonard, Name::Penny, Name::Rajesh, Name::Howard];
assert_eq!(who_is_next(names, 1), Name::Sheldon);
assert_eq!(who_is_next(names, 6), Name::Sheldon);
assert_eq!(who_is_next(names, 52), Name::Penny);
assert_eq!(who_is_next(names, 7230702951), Name::Leonard);
```
```csharp
string[] names = new string[] { "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" };
Line.WhoIsNext(names, 1) == "Sheldon"
Line.WhoIsNext(names, 52) == "Penny"
Line.WhoIsNext(names, 7230702951) == "Leonard"
```
```python
who_is_next(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 1) == "Sheldon"
who_is_next(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 52) == "Penny"
who_is_next(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 7230702951) == "Leonard"
```
```ruby
whoIsNext(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 1) == "Sheldon"
whoIsNext(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 52) == "Penny"
whoIsNext(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 7230702951) == "Leonard"
```
```javascript
whoIsNext(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 1) == "Sheldon"
whoIsNext(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 52) == "Penny"
whoIsNext(["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"], 7230702951) == "Leonard"
```
```kotlin
whoIsNext(listOf("Sheldon", "Leonard", "Penny", "Rajesh", "Howard"), 1) == "Sheldon"
whoIsNext(listOf("Sheldon", "Leonard", "Penny", "Rajesh", "Howard"), 52) == "Penny"
whoIsNext(listOf("Sheldon", "Leonard", "Penny", "Rajesh", "Howard"), 7230702951) == "Leonard"
```
```r
who_is_next(c("Sheldon", "Leonard", "Penny", "Rajesh", "Howard"), 1) == "Sheldon"
who_is_next(c("Sheldon", "Leonard", "Penny", "Rajesh", "Howard"), 52) == "Penny"
who_is_next(c("Sheldon", "Leonard", "Penny", "Rajesh", "Howard"), 10010) == "Howard"
```
```c
char* names[] = {"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"};
who_is_next(names, 5, 1) == "Sheldon"
who_is_next(names, 5, 52) == "Penny"
who_is_next(names, 5, 10010) == "Howard"
```
~~~
~~~if:nasm
```c
char* names[] = { "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" };
who_is_next(1, 5, names) == "Sheldon"
who_is_next(52, 5, names) == "Penny"
who_is_next(7230702951, 5, names) == "Leonard"
```
~~~
##### courtesy of CodeForces: https://codeforces.com/problemset/problem/82/A
---> | algorithms | def whoIsNext(names, r):
while r > 5:
r = (r - 4) / 2
return names[r - 1]
| Double Cola | 551dd1f424b7a4cdae0001f0 | [
"Algorithms",
"Mathematics",
"Logic",
"Numbers"
] | https://www.codewars.com/kata/551dd1f424b7a4cdae0001f0 | 5 kyu |
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(Input1, Input2 --> Output)
```
[1, 2, 3, 4, 5, 6], 2 --> [2, 4, 6]
```
| algorithms | def divisible_by(numbers, divisor):
return [x for x in numbers if x % divisor == 0]
| Find numbers which are divisible by given number | 55edaba99da3a9c84000003b | [
"Arrays",
"Algorithms"
] | https://www.codewars.com/kata/55edaba99da3a9c84000003b | 8 kyu |
Very simple, given a number (integer / decimal / both depending on the language), find its opposite (additive inverse).
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`.
~~~
| reference | def opposite(number):
return - number
| Opposite number | 56dec885c54a926dcd001095 | [
"Fundamentals"
] | https://www.codewars.com/kata/56dec885c54a926dcd001095 | 8 kyu |
Your task is to split the chocolate bar of given dimension `n` x `m` into small squares.
Each square is of size 1x1 and unbreakable.
Implement a function that will return minimum number of breaks needed.
For example if you are given a chocolate bar of size `2` x `1` you can split it to single squares in just one break, but for size `3` x `1` you must do two breaks.
If input data is invalid you should return 0 (as in no breaks are needed if we do not have any chocolate to split). Input will always be a non-negative integer. | algorithms | def breakChocolate(n, m):
return max(n * m - 1, 0)
| Breaking chocolate problem | 534ea96ebb17181947000ada | [
"Algorithms"
] | https://www.codewars.com/kata/534ea96ebb17181947000ada | 7 kyu |
Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
### Examples (Input -> Output):
```
* "String" -> "SSttrriinngg"
* "Hello World" -> "HHeelllloo WWoorrlldd"
* "1234!_ " -> "11223344!!__ "
```
Good Luck!
~~~if:riscv
RISC-V: The function signature is
```c
char *double_char(const char *string, char *doubled);
```
Write your result to `doubled`. You may assume it is large enough to hold the result. Return `doubled` when you are done.
~~~
| reference | def double_char(s):
return '' . join(c * 2 for c in s)
| Double Char | 56b1f01c247c01db92000076 | [
"Fundamentals",
"Strings"
] | https://www.codewars.com/kata/56b1f01c247c01db92000076 | 8 kyu |
ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but **exactly** 4 digits or exactly 6 digits.
If the function is passed a valid PIN string, return `true`, else return `false`.
## Examples (**Input --> Output)**
```
"1234" --> true
"12345" --> false
"a234" --> false
```
| reference | def validate_pin(pin):
return len(pin) in (4, 6) and pin . isdigit()
| Regex validate PIN code | 55f8a9c06c018a0d6e000132 | [
"Regular Expressions",
"Fundamentals"
] | https://www.codewars.com/kata/55f8a9c06c018a0d6e000132 | 7 kyu |
Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result.
Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0).
If the input string is empty, return an empty string.
The words in the input String will only contain valid consecutive numbers.
## Examples
```
"is2 Thi1s T4est 3a" --> "Thi1s is2 3a T4est"
"4of Fo1r pe6ople g3ood th5e the2" --> "Fo1r the2 g3ood 4of th5e pe6ople"
"" --> ""
``` | reference | def order(words):
return ' ' . join(sorted(words . split(), key=lambda w: sorted(w)))
| Your order, please | 55c45be3b2079eccff00010f | [
"Strings",
"Fundamentals"
] | https://www.codewars.com/kata/55c45be3b2079eccff00010f | 6 kyu |
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]
``` | reference | def between(a, b):
return list(range(a, b + 1))
| What is between? | 55ecd718f46fba02e5000029 | [
"Fundamentals",
"Algorithms"
] | https://www.codewars.com/kata/55ecd718f46fba02e5000029 | 8 kyu |
You have cultivated a plant, and after months of hard work, the time has come to reap the flowers of your hard work. When it was growing, you added water and fertilizer, and kept a constant temperature. It's time check how much your plant has grown.
A plant is represented horizontally, from the base to the left, to the end to the right:
```
---@---@---@
```
The stem is represented by hyphens `-`, and the flowers are represented by symbols. A plant always starts with the stem, and always ends with flowers.
Four parameters will be given. The four parameters are:
+ `seed` (string) - _determines the type of flowers generated by the plant._
+ `water` (integer) - _each unit of water extends the portion of stem between the flowers. It also gives how many times the stems + flower clusters should be repeated_
+ `fert` (integer) - _each unit of fertilizer increases the amount of flowers, grouped in clusters_
+ `temp` (integer) - _if the temperature given is in the range of 20°C and 30°C, the plant grows normally, otherwise, all the flowers die except for one flower at the end of the stem._
Given the above parameters, your task is to return a string representing the plant.
### Examples
```python
plant("@", 3, 3, 25) => "---@@@---@@@---@@@"
# Water gives the length of the stem portions between flowers
# Water also gives the total number of segments(number of times flowers + stems should be repeated)
# Fertilizer gives the length of the flower clusters.
# Temperature is in the range of 20°C and 30°C
plant("$", 4, 2, 30) => "----$$----$$----$$----$$"
plant("&", 1, 5, 20) => "-&&&&&"
plant("^", 3, 3, 35) => "---------^"
# The temperature is not in the correct range, so all flowers die, except the last one at the end.
# The stem is not affected by the temperature
```
### Notes
+ Edge conditions will not be tested, meaning parameters of water or fertilizer or temperature being zero. This will not be tested. The parameters will always be valid (no zero).
+ The temperature bounds are inclusive (20 and 30 will be included as 21, 22, 23, 24...)
Happy Coding!
| reference | def plant(seed, water, fert, temp):
return ('-' * water + seed * fert) * water if temp >= 20 and temp <= 30 else ('-' * water) * water + seed
| Harvest Festival | 606efc6a9409580033837dfb | [
"Fundamentals",
"Strings"
] | https://www.codewars.com/kata/606efc6a9409580033837dfb | 7 kyu |
When provided with a letter, return its position in the alphabet.
Input :: "a"
Ouput :: "Position of alphabet: 1"
| reference | def position(alphabet):
return "Position of alphabet: {}" . format(ord(alphabet) - 96)
| Find the position! | 5808e2006b65bff35500008f | [
"Fundamentals"
] | https://www.codewars.com/kata/5808e2006b65bff35500008f | 8 kyu |
Automatons, or Finite State Machines (FSM), are extremely useful to programmers when it comes to software design. You will be given a simplistic version of an FSM to code for a basic TCP session.
The outcome of this exercise will be to return the correct state of the TCP FSM based on the array of events given.
---------------------------------
The input array of events will consist of one or more of the following strings:
```
APP_PASSIVE_OPEN, APP_ACTIVE_OPEN, APP_SEND, APP_CLOSE, APP_TIMEOUT, RCV_SYN, RCV_ACK, RCV_SYN_ACK, RCV_FIN, RCV_FIN_ACK
```
---------------------------------
The states are as follows and should be returned in all capital letters as shown:
```
CLOSED, LISTEN, SYN_SENT, SYN_RCVD, ESTABLISHED, CLOSE_WAIT, LAST_ACK, FIN_WAIT_1, FIN_WAIT_2, CLOSING, TIME_WAIT
```
---------------------------------
The input will be an array of events. The initial state is `CLOSED`. Your job is to traverse the FSM as determined by the events, and return the proper final state as a string, all caps, as shown above.
If an event is not applicable to the current state, your code will return `"ERROR"`.
### Action of each event upon each state:
(the format is `INITIAL_STATE: EVENT -> NEW_STATE`)
```
CLOSED: APP_PASSIVE_OPEN -> LISTEN
CLOSED: APP_ACTIVE_OPEN -> SYN_SENT
LISTEN: RCV_SYN -> SYN_RCVD
LISTEN: APP_SEND -> SYN_SENT
LISTEN: APP_CLOSE -> CLOSED
SYN_RCVD: APP_CLOSE -> FIN_WAIT_1
SYN_RCVD: RCV_ACK -> ESTABLISHED
SYN_SENT: RCV_SYN -> SYN_RCVD
SYN_SENT: RCV_SYN_ACK -> ESTABLISHED
SYN_SENT: APP_CLOSE -> CLOSED
ESTABLISHED: APP_CLOSE -> FIN_WAIT_1
ESTABLISHED: RCV_FIN -> CLOSE_WAIT
FIN_WAIT_1: RCV_FIN -> CLOSING
FIN_WAIT_1: RCV_FIN_ACK -> TIME_WAIT
FIN_WAIT_1: RCV_ACK -> FIN_WAIT_2
CLOSING: RCV_ACK -> TIME_WAIT
FIN_WAIT_2: RCV_FIN -> TIME_WAIT
TIME_WAIT: APP_TIMEOUT -> CLOSED
CLOSE_WAIT: APP_CLOSE -> LAST_ACK
LAST_ACK: RCV_ACK -> CLOSED
```
!["EFSM TCP" ](http://theangelfallseries.com/img/EFSM_TCP.png)
## Examples
```
["APP_PASSIVE_OPEN", "APP_SEND", "RCV_SYN_ACK"] => "ESTABLISHED"
["APP_ACTIVE_OPEN"] => "SYN_SENT"
["APP_ACTIVE_OPEN", "RCV_SYN_ACK", "APP_CLOSE", "RCV_FIN_ACK", "RCV_ACK"] => "ERROR"
```
This kata is similar to [Design a Simple Automaton (Finite State Machine)](https://www.codewars.com/kata/design-a-simple-automaton-finite-state-machine), and you may wish to try that kata before tackling this one.
See wikipedia page [Transmission Control Protocol]( http://en.wikipedia.org/wiki/Transmission_Control_Protocol)
for further details.
See http://www.medianet.kent.edu/techreports/TR2005-07-22-tcp-EFSM.pdf page 4, for the FSM diagram used for this kata. | algorithms | STATE_TO_COMMANDS = {
'CLOSED': {
'APP_PASSIVE_OPEN': 'LISTEN',
'APP_ACTIVE_OPEN': 'SYN_SENT'
},
'LISTEN': {
'RCV_SYN': 'SYN_RCVD',
'APP_SEND': 'SYN_SENT',
'APP_CLOSE': 'CLOSED'
},
'SYN_RCVD': {
'APP_CLOSE': 'FIN_WAIT_1',
'RCV_ACK': 'ESTABLISHED'
},
'SYN_SENT': {
'RCV_SYN': 'SYN_RCVD',
'RCV_SYN_ACK': 'ESTABLISHED',
'APP_CLOSE': 'CLOSED'
},
'ESTABLISHED': {
'APP_CLOSE': 'FIN_WAIT_1',
'RCV_FIN': 'CLOSE_WAIT'
},
'FIN_WAIT_1': {
'RCV_FIN': 'CLOSING',
'RCV_FIN_ACK': 'TIME_WAIT',
'RCV_ACK': 'FIN_WAIT_2'
},
'CLOSING': {
'RCV_ACK': 'TIME_WAIT'
},
'FIN_WAIT_2': {
'RCV_FIN': 'TIME_WAIT'
},
'TIME_WAIT': {
'APP_TIMEOUT': 'CLOSED'
},
'CLOSE_WAIT': {
'APP_CLOSE': 'LAST_ACK'
},
'LAST_ACK': {
'RCV_ACK': 'CLOSED'
}
}
def traverse_TCP_states(events):
state = "CLOSED" # initial state, always
for event in events:
if event not in STATE_TO_COMMANDS[state]:
return 'ERROR'
state = STATE_TO_COMMANDS[state][event]
return state
| A Simplistic TCP Finite State Machine (FSM) | 54acc128329e634e9a000362 | [
"State Machines",
"Algorithms"
] | https://www.codewars.com/kata/54acc128329e634e9a000362 | 4 kyu |
The goal of this exercise is to convert a string to a new string where each character in the new string is `"("` if that character appears only once in the original string, or `")"` if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate.
### Examples
```
"din" => "((("
"recede" => "()()()"
"Success" => ")())())"
"(( @" => "))(("
```
### Notes
Assertion messages may be unclear about what they display in some languages. If you read `"...It Should encode XXX"`, the `"XXX"` is the expected result, not the input! | reference | def duplicate_encode(word):
return "" . join(["(" if word . lower(). count(c) == 1 else ")" for c in word . lower()])
| Duplicate Encoder | 54b42f9314d9229fd6000d9c | [
"Strings",
"Arrays",
"Fundamentals"
] | https://www.codewars.com/kata/54b42f9314d9229fd6000d9c | 6 kyu |
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Finish the solution so that it returns the sum of all the multiples of 3 or 5 **below** the number passed in.
~~~if:c,cobol,commonlisp,cpp,csharp,dart,elixir,factor,fsharp,javascript,julia,kotlin,lua,nasm,php,prolog,python,raqcket,ruby,rust,shell,swift,typescript,vb
Additionally, if the number is negative, return 0.
~~~
**Note:** If the number is a multiple of **both** 3 and 5, only count it *once*.
***Courtesy of projecteuler.net** ([Problem 1](https://projecteuler.net/problem=1))*
| algorithms | def solution(number):
return sum(x for x in range(number) if x % 3 == 0 or x % 5 == 0)
| Multiples of 3 or 5 | 514b92a657cdc65150000006 | [
"Mathematics",
"Algorithms"
] | https://www.codewars.com/kata/514b92a657cdc65150000006 | 6 kyu |
A *[Hamming number][1]* is a positive integer of the form 2<sup>*i*</sup>3<sup>*j*</sup>5<sup>*k*</sup>, for some non-negative integers *i,* *j,* and *k.*
Write a function that computes the *n<sup>th</sup>* smallest Hamming number.
Specifically:
- The first smallest Hamming number is 1 = 2<sup>0</sup>3<sup>0</sup>5<sup>0</sup>
- The second smallest Hamming number is 2 = 2<sup>1</sup>3<sup>0</sup>5<sup>0</sup>
- The third smallest Hamming number is 3 = 2<sup>0</sup>3<sup>1</sup>5<sup>0</sup>
- The fourth smallest Hamming number is 4 = 2<sup>2</sup>3<sup>0</sup>5<sup>0</sup>
- The fifth smallest Hamming number is 5 = 2<sup>0</sup>3<sup>0</sup>5<sup>1</sup>
The 20 smallest Hamming numbers are given in the Example test fixture.
Your code should be able to compute the first `5 000` ( LC: `400`, Clojure: `2 000`, Haskell: `12 691`, NASM, C, D, C++, Go and Rust: `13 282` ) Hamming numbers without timing out.
[1]:https://en.wikipedia.org/wiki/Regular_number | algorithms | def hamming(n):
bases = [2, 3, 5]
expos = [0, 0, 0]
hamms = [1]
for _ in range(1, n):
next_hamms = [bases[i] * hamms[expos[i]] for i in range(3)]
next_hamm = min(next_hamms)
hamms . append(next_hamm)
for i in range(3):
expos[i] += int(next_hamms[i] == next_hamm)
return hamms[- 1]
| Hamming Numbers | 526d84b98f428f14a60008da | [
"Number Theory",
"Algorithms"
] | https://www.codewars.com/kata/526d84b98f428f14a60008da | 4 kyu |
Write a function that checks if a given string (case insensitive) is a [palindrome](https://en.wikipedia.org/wiki/Palindrome).
A palindrome is a word, number, phrase, or other sequence of symbols that reads the same backwards as forwards, such as `madam` or `racecar`. | reference | def is_palindrome(s):
s = s . lower()
return s == s[:: - 1]
| Is it a palindrome? | 57a1fd2ce298a731b20006a4 | [
"Fundamentals"
] | https://www.codewars.com/kata/57a1fd2ce298a731b20006a4 | 8 kyu |
### Description:
Groups of characters decided to make a battle. Help them to figure out which group is more powerful. Create a function that will accept 2 strings and return the one who's stronger.
### Rules:
* Each character have its own power: `A = 1, B = 2, ... Y = 25, Z = 26`
* Strings will consist of uppercase letters only
* Only two groups to a fight.
* Group whose total power (`A + B + C + ...`) is bigger wins.
* If the powers are equal, it's a tie.
### Examples:
```cobol
* "ONE", "TWO" -> "TWO"`
* "ONE", "NEO" -> "Tie!"
```
### Related kata:
- [Battle of the characters (Medium)](https://www.codewars.com/kata/595e9f258b763bc2d2000032) | algorithms | def battle(x, y):
# Compute x score using Unicode
x_value = sum(ord(char) - 64 for char in x)
# Compute y score using Unicode
y_value = sum(ord(char) - 64 for char in y)
if x_value < y_value:
return y
if x_value > y_value:
return x
return "Tie!"
| Battle of the characters (Easy) | 595519279be6c575b5000016 | [
"Algorithms"
] | https://www.codewars.com/kata/595519279be6c575b5000016 | 7 kyu |
# 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. Your function only needs to return the result, what is shown between parentheses in the example below is how you reach that result and it's not part of it, see the sample tests.
For example **(Input -> Output)**:
```
2 -> 3 (1 + 2)
8 -> 36 (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8)
``` | reference | def summation(num):
return sum(range(1, num + 1))
| Grasshopper - Summation | 55d24f55d7dd296eb9000030 | [
"Fundamentals",
"Mathematics"
] | https://www.codewars.com/kata/55d24f55d7dd296eb9000030 | 8 kyu |
## Messi's Goal Total
Use variables to find the sum of the goals Messi scored in 3 competitions
## Information
Messi goal scoring statistics:
Competition | Goals
-----|------
La Liga | 43
Champions League | 10
Copa del Rey | 5
## Task
1) Create these three variables and store the appropriate values using the table above:
~~~if:python,ruby,rust,prolog
- `la_liga_goals`
- `champions_league_goals`
- `copa_del_rey_goals`
2) Create a fourth variable named `total_goals` that stores the sum of all of Messi's goals for this year.
~~~
~~~if:javascript,coffeescript,csharp,swift,java
- `laLigaGoals`
- `championsLeagueGoals`
- `copaDelReyGoals`
2) Create a fourth variable named `totalGoals` that stores the sum of all of Messi's goals for this year.
~~~
| reference | la_liga_goals = 43
champions_league_goals = 10
copa_del_rey_goals = 5
total_goals = la_liga_goals + champions_league_goals + copa_del_rey_goals
| Grasshopper - Messi Goals | 55ca77fa094a2af31f00002a | [
"Fundamentals"
] | https://www.codewars.com/kata/55ca77fa094a2af31f00002a | 8 kyu |
Can you find the needle in the haystack?
Write a function `findNeedle()` that takes an `array` full of junk but containing one `"needle"`
After your function finds the needle it should return a message (as a string) that says:
`"found the needle at position "` plus the `index` it found the needle, so:
**Example(Input --> Output)**
```
["hay", "junk", "hay", "hay", "moreJunk", "needle", "randomJunk"] --> "found the needle at position 5"
```
**Note: In COBOL, it should return** `"found the needle at position 6"` | reference | def find_needle(haystack):
return f'found the needle at position { haystack . index ( "needle" )} '
| A Needle in the Haystack | 56676e8fabd2d1ff3000000c | [
"Arrays",
"Fundamentals"
] | https://www.codewars.com/kata/56676e8fabd2d1ff3000000c | 8 kyu |
Complete the function `scramble(str1, str2)` that returns `true` if a portion of ```str1``` characters can be rearranged to match ```str2```, otherwise returns ```false```.
**Notes:**
* Only lower case letters will be used (a-z). No punctuation or digits will be included.
* Performance needs to be considered.
```if:c
* Input strings s1 and s2 are null terminated.
```
## Examples
```python
scramble('rkqodlw', 'world') ==> True
scramble('cedewaraaossoqqyt', 'codewars') ==> True
scramble('katas', 'steak') ==> False
```
| algorithms | def scramble(s1, s2):
for c in set(s2):
if s1 . count(c) < s2 . count(c):
return False
return True
| Scramblies | 55c04b4cc56a697bb0000048 | [
"Strings",
"Performance",
"Algorithms"
] | https://www.codewars.com/kata/55c04b4cc56a697bb0000048 | 5 kyu |
You're at the zoo... all the meerkats look weird. Something has gone terribly wrong - someone has gone and switched their heads and tails around!
Save the animals by switching them back. You will be given an array which will have three values (tail, body, head). It is your job to re-arrange the array so that the animal is the right way round (head, body, tail).
Same goes for all the other arrays/lists that you will get in the tests: you have to change the element positions with the same exact logics
Simples!
~~~if:riscv
RISC-V: The function signature is
```c
void fix_the_meerkat(void *meerkat, size_t size);
```
`meerkat` is an array of unknown type, but it always has exactly 3 elements (tail, body, head). `size` is the size (in bytes) of each element in the array. Swap the tail and head of `meerkat` in place. You do not need to return anything.
~~~
| algorithms | def fix_the_meerkat(arr):
return arr[:: - 1]
| My head is at the wrong end! | 56f699cd9400f5b7d8000b55 | [
"Arrays",
"Lists",
"Algorithms"
] | https://www.codewars.com/kata/56f699cd9400f5b7d8000b55 | 8 kyu |
Your task is to remove all duplicate words from a string, leaving only single (first) words entries.
Example:
Input:
'alpha beta beta gamma gamma gamma delta alpha beta beta gamma gamma gamma delta'
Output:
'alpha beta gamma delta'
| algorithms | def remove_duplicate_words(s):
return ' ' . join(dict . fromkeys(s . split()))
| Remove duplicate words | 5b39e3772ae7545f650000fc | [
"Strings",
"Regular Expressions",
"Algorithms"
] | https://www.codewars.com/kata/5b39e3772ae7545f650000fc | 7 kyu |
After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you.
You will need a rental car in order for you to get around in your vacation. The manager of the car rental makes you some good offers.
Every day you rent the car costs $40. If you rent the car for 7 or more days, you get $50 off your total. Alternatively, if you rent the car for 3 or more days, you get $20 off your total.
Write a code that gives out the total amount for different days(d).
| reference | def rental_car_cost(d):
result = d * 40
if d >= 7:
result -= 50
elif d >= 3:
result -= 20
return result
| Transportation on vacation | 568d0dd208ee69389d000016 | [
"Fundamentals"
] | https://www.codewars.com/kata/568d0dd208ee69389d000016 | 8 kyu |
The function is not returning the correct values. Can you figure out why?
Example (**Input** --> **Output** ):
```
3 --> "Earth"
``` | bug_fixes | def get_planet_name(id):
return {
1: "Mercury",
2: "Venus",
3: "Earth",
4: "Mars",
5: "Jupiter",
6: "Saturn",
7: "Uranus",
8: "Neptune",
}. get(id, None)
| Get Planet Name By ID | 515e188a311df01cba000003 | [
"Debugging"
] | https://www.codewars.com/kata/515e188a311df01cba000003 | 8 kyu |
This is the simple version of Shortest Code series. If you need some challenges, please try the [challenge version](http://www.codewars.com/kata/56f8a648ba792a778a0000b9).
### Task:
Find out "B"(Bug) in a lot of "A"(Apple).
There will always be one bug in apple, not need to consider the situation that without bug or more than one bugs.
input: string Array ```apple```
output: Location of "B", ```[x,y]```
### Series:
- [Bug in Apple](http://www.codewars.com/kata/56fe97b3cc08ca00e4000dc9)
- [Father and Son](http://www.codewars.com/kata/56fe9a0c11086cd842000008)
- [Jumping Dutch act](http://www.codewars.com/kata/570bcd9715944a2c8e000009)
- [Planting Trees](http://www.codewars.com/kata/5710443187a36a9cee0005a1)
- [Give me the equation](http://www.codewars.com/kata/56fe9b65cc08cafbc5000de3)
- [Find the murderer](http://www.codewars.com/kata/570f3fc5b29c702c5500043e)
- [Reading a Book](http://www.codewars.com/kata/570ca6a520c69f39dd0016d4)
- [Eat watermelon](http://www.codewars.com/kata/570df12ce6e9282a7d000947)
- [Special factor](http://www.codewars.com/kata/570e5d0b93214b1a950015b1)
- [Guess the Hat](http://www.codewars.com/kata/570ef7a834e61306da00035b)
- [Symmetric Sort](http://www.codewars.com/kata/5705aeb041e5befba20010ba)
- [Are they symmetrical?](http://www.codewars.com/kata/5705cc3161944b10fd0004ba)
- [Max Value](http://www.codewars.com/kata/570771871df89cf59b000742)
- [Trypophobia](http://www.codewars.com/kata/56fe9ffbc25bf33fff000f7c)
- [Virus in Apple](http://www.codewars.com/kata/5700af83d1acef83fd000048)
- [Balance Attraction](http://www.codewars.com/kata/57033601e55d30d3e0000633)
- [Remove screws I](http://www.codewars.com/kata/5710a50d336aed828100055a)
- [Remove screws II](http://www.codewars.com/kata/5710a8fd336aed00d9000594)
- [Regular expression compression](http://www.codewars.com/kata/570bae4b0237999e940016e9)
- [Collatz Array(Split or merge)](http://www.codewars.com/kata/56fe9d579b7bb6b027000001)
- [Tidy up the room](http://www.codewars.com/kata/5703ace6e55d30d3e0001029)
- [Waiting for a Bus](http://www.codewars.com/kata/57070eff924f343280000015) | games | def sc(apple):
for i in apple:
for j in i:
if j == "B":
return [apple . index(i), i . index(j)]
| Coding 3min: Bug in Apple | 56fe97b3cc08ca00e4000dc9 | [
"Puzzles",
"Games"
] | https://www.codewars.com/kata/56fe97b3cc08ca00e4000dc9 | 7 kyu |
Write a function to split a string and convert it into an array of words.
### Examples (Input ==> Output):
```
"Robin Singh" ==> ["Robin", "Singh"]
"I love arrays they are my favorite" ==> ["I", "love", "arrays", "they", "are", "my", "favorite"]
```
```if:c
Words will be separated by exactly one space, without leading or trailing spaces.
There will only be letters and spaces in the input string.
```
| reference | def string_to_array(string):
return string . split(" ")
| Convert a string to an array | 57e76bc428d6fbc2d500036d | [
"Arrays",
"Strings",
"Fundamentals"
] | https://www.codewars.com/kata/57e76bc428d6fbc2d500036d | 8 kyu |
Write a function that accepts two square (`NxN`) matrices (two dimensional arrays), and returns the product of the two. Only square matrices will be given.
How to multiply two square matrices:
We are given two matrices, A and B, of size 2x2 (note: tests are not limited to 2x2). Matrix C, the solution, will be equal to the product of A and B. To fill in cell `[0][0]` of matrix C, you need to compute: `A[0][0] * B[0][0] + A[0][1] * B[1][0]`.
More general: To fill in cell `[n][m]` of matrix C, you need to first multiply the elements in the nth row of matrix A by the elements in the mth column of matrix B, then take the sum of all those products. This will give you the value for cell `[m][n]` in matrix C.
## Example
```
A B C
|1 2| x |3 2| = | 5 4|
|3 2| |1 1| |11 8|
```
Detailed calculation:
```
C[0][0] = A[0][0] * B[0][0] + A[0][1] * B[1][0] = 1*3 + 2*1 = 5
C[0][1] = A[0][0] * B[0][1] + A[0][1] * B[1][1] = 1*2 + 2*1 = 4
C[1][0] = A[1][0] * B[0][0] + A[1][1] * B[1][0] = 3*3 + 2*1 = 11
C[1][1] = A[1][0] * B[0][1] + A[1][1] * B[1][1] = 3*2 + 2*1 = 8
```
Link to Wikipedia explaining matrix multiplication (look at the square matrix example):
http://en.wikipedia.org/wiki/Matrix_multiplication
A more visual explanation of matrix multiplication: http://matrixmultiplication.xyz
~~~if:c
**Note:** In **C**, the dimensions of both square matrices `n` will be passed into your function. However, since the dimensions of your returned "matrix" is expected to be the same as that of the inputs, you will not need to keep track of the dimensions of your matrix in another variable.
~~~ | algorithms | from numpy import matrix
def matrix_mult(a, b):
return (matrix(a) * matrix(b)). tolist()
| Square Matrix Multiplication | 5263a84ffcadb968b6000513 | [
"Matrix",
"Linear Algebra",
"Algorithms"
] | https://www.codewars.com/kata/5263a84ffcadb968b6000513 | 5 kyu |
Complete the solution so that the function will break up camel casing, using a space between words.
### Example
```
"camelCasing" => "camel Casing"
"identifier" => "identifier"
"" => ""
``` | reference | def solution(s):
return '' . join(' ' + c if c . isupper() else c for c in s)
| Break camelCase | 5208f99aee097e6552000148 | [
"Strings",
"Fundamentals"
] | https://www.codewars.com/kata/5208f99aee097e6552000148 | 6 kyu |
Write a class `Block` that creates a block (Duh..)
## Requirements
The constructor should take an array as an argument,
this will contain 3 integers of the form `[width, length, height]` from which the `Block` should be created.
Define these methods:
```python
`get_width()` return the width of the `Block`
`get_length()` return the length of the `Block`
`get_height()` return the height of the `Block`
`get_volume()` return the volume of the `Block`
`get_surface_area()` return the surface area of the `Block`
```
```ruby
`get_width()` return the width of the `Block`
`get_length()` return the length of the `Block`
`get_height()` return the height of the `Block`
`get_volume()` return the volume of the `Block`
`get_surface_area()` return the surface area of the `Block`
```
```java
`getWidth()` return the width of the `Block`
`getLength()` return the length of the `Block`
`getHeight()` return the height of the `Block`
`getVolume()` return the volume of the `Block`
`getSurfaceArea()` return the surface area of the `Block`
```
```javascript
`getWidth()` return the width of the `Block`
`getLength()` return the length of the `Block`
`getHeight()` return the height of the `Block`
`getVolume()` return the volume of the `Block`
`getSurfaceArea()` return the surface area of the `Block`
```
```coffeescript
`getWidth()` return the width of the `Block`
`getLength()` return the length of the `Block`
`getHeight()` return the height of the `Block`
`getVolume()` return the volume of the `Block`
`getSurfaceArea()` return the surface area of the `Block`
```
```haskell
`getWidth()` return the width of the `Block`
`getLength()` return the length of the `Block`
`getHeight()` return the height of the `Block`
`getVolume()` return the volume of the `Block`
`getSurfaceArea()` return the surface area of the `Block`
```
```csharp
`GetWidth()` return the width of the `Block`
`GetLength()` return the length of the `Block`
`GetHeight()` return the height of the `Block`
`GetVolume()` return the volume of the `Block`
`GetSurfaceArea()` return the surface area of the `Block`
```
```rust
new -> initialize the `Block` from the provided array of u32
// all the methods must return a u32
get_width() -> width of the `Block`
get_length() -> length of the `Block`
get_height() -> height of the `Block`
get_volume() -> volume of the `Block`
get_surface_area() -> surface area of the `Block`
```
## Examples
```python
b = Block([2,4,6]) -> create a `Block` object with a width of `2` a length of `4` and a height of `6`
b.get_width() -> return 2
b.get_length() -> return 4
b.get_height() -> return 6
b.get_volume() -> return 48
b.get_surface_area() -> return 88
```
```javascript
let b = new Block([2,4,6]) -> creates a `Block` object with a width of `2` a length of `4` and a height of `6`
b.getWidth() // -> 2
b.getLength() // -> 4
b.getHeight() // -> 6
b.getVolume() // -> 48
b.getSurfaceArea() // -> 88
```
```coffeescript
b = new Block [2,4,6] # creates a `Block` object with width of `2`,
# length of `4`, and height of `6`
b.getWidth() # 2
b.getLength() # 4
b.getHeight() # 6
b.getVolume() # 48
b.getSurfaceArea() # 88
```
```ruby
b = Block.new([2,4,6]) -> create a `Block` object with a width of `2` a length of `4` and a height of `6`
b.get_width() -> return 2
b.get_length() -> return 4
b.get_height() -> return 6
b.get_volume() -> return 48
b.get_surface_area() -> return 88
```
```haskell
b = Block([2,4,6]) -> create a `Block` object with a width of `2` a length of `4` and a height of `6`
```
```csharp
Block b = new Block(new int[]{2,4,6}) -> creates a `Block` object with a width of `2` a length of `4` and a height of `6`
b.GetWidth() // -> 2
b.GetLength() // -> 4
b.GetHeight() // -> 6
b.GetVolume() // -> 48
b.GetSurfaceArea() // -> 88
```
```java
Block b = new Block(new int[]{2,4,6}) -> creates a `Block` object with a width of `2` a length of `4` and a height of `6`
b.getWidth() // -> 2
b.getLength() // -> 4
b.getHeight() // -> 6
b.getVolume() // -> 48
b.getSurfaceArea() // -> 88
```
```rust
let b = Block::new(&[2,4,6]) -> create a `Block` object with a width of `2` a length of `4` and a height of `6`
b.get_width() -> return 2
b.get_length() -> return 4
b.get_height() -> return 6
b.get_volume() -> return 48
b.get_surface_area() -> return 88
```
Note: no error checking is needed
Any feedback would be much appreciated
| reference | from operator import mul
class Block (object):
def __init__(self, dimensions):
self . dimensions = dimensions
def get_width(self):
return self . dimensions[0]
def get_length(self):
return self . dimensions[1]
def get_height(self):
return self . dimensions[2]
def get_volume(self):
return reduce(mul, self . dimensions)
def get_surface_area(self):
w, l, h = self . dimensions
return 2 * (w * l + l * h + w * h)
| Building blocks | 55b75fcf67e558d3750000a3 | [
"Object-oriented Programming",
"Fundamentals"
] | https://www.codewars.com/kata/55b75fcf67e558d3750000a3 | 7 kyu |
Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present).
For example,
```javascript
[true, true, true, false,
true, true, true, true ,
true, false, true, false,
true, false, false, true ,
true, true, true, true ,
false, false, true, true]
```
```crystal
[true, true, true, false,
true, true, true, true ,
true, false, true, false,
true, false, false, true ,
true, true, true, true ,
false, false, true, true]
```
```python
[True, True, True, False,
True, True, True, True ,
True, False, True, False,
True, False, False, True ,
True, True, True, True ,
False, False, True, True]
```
```csharp
[true, true, true, false,
true, true, true, true ,
true, false, true, false,
true, false, false, true ,
true, true, true, true ,
false, false, true, true]
```
```c
{ true, true, true, false,
true, true, true, true,
true, false, true, false,
true, false, false, true,
true, true, true, true,
false, false, true, true }
```
```cpp
[true, true, true, false,
true, true, true, true ,
true, false, true, false,
true, false, false, true ,
true, true, true, true ,
false, false, true, true]
```
```haskell
[True, True, True, False,
True, True, True, True ,
True, False, True, False,
True, False, False, True ,
True, True, True, True ,
False, False, True, True]
```
```elixir
[true, true, true, false,
true, true, true, true ,
true, false, true, false,
true, false, false, true ,
true, true, true, true ,
false, false, true, true]
```
```rust
&[true, true, true, false,
true, true, true, true ,
true, false, true, false,
true, false, false, true ,
true, true, true, true ,
false, false, true, true]
```
```scala
Array(
true, true, true, false,
true, true, true, true,
true, false, true, false,
true, false, false, true,
true, true, true, true,
false, false, true, true
)
```
```racket
;for racket in this kata,
;only values that are exactly #t count as sheep.
;any other value is not a sheep.
(count-sheeps '(#t #t #t #f #t #t 1
#t #f #f #f #f #f #f
#t #f #t #t #t #t #t
#t #t #f #t #t #t 5))
```
```factor
{ t t t f
t t t t
t f t f
t f f t
t t t t
f f t t }
```
```bf
"tttftttttftftfftttttfftt"
```
The correct answer would be `17`.
Hint: Don't forget to check for bad values like `null`/`undefined`
```if:bf
In BF, true is represented as the letter 't' (ASCII 116), while false is represented as the letter 'f' (ASCII 102)
Input streams will be terminated with a null character
```
| reference | def count_sheeps(arrayOfSheeps):
return arrayOfSheeps . count(True)
| Counting sheep... | 54edbc7200b811e956000556 | [
"Arrays",
"Fundamentals"
] | https://www.codewars.com/kata/54edbc7200b811e956000556 | 8 kyu |
You are given a node that is the beginning of a linked list. This list contains a dangling piece and a loop. Your objective is to determine the length of the loop.
For example in the following picture the size of the dangling piece is 3 and the loop size is 12:
<img width='320px' src='data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyOTcuMjUgMzE0LjQyIj48ZyBmaWxsPSIjRUMwMDhDIj48cGF0aCBkPSJNNTAuMTQgNDkuMzJsLTMuMzMtNy45My0uODIgMy4wOC0xMi42My0xMi42My0uNzEuNyAxMi42NCAxMi42NC0zLjA4Ljgxek04MC45MSA4MC4wOWwtMy4zMy03LjkyLS44MSAzLjA3LTEyLjY0LTEyLjYzLS43LjcxIDEyLjYzIDEyLjYzLTMuMDguODJ6TTExMi4xIDExMS4yOGwtMy4zMy03LjkyLS44MiAzLjA3TDk1LjMyIDkzLjhsLS43LjcxIDEyLjYzIDEyLjYzLTMuMDguODF6TTE1My43NCAxMDEuODdsLTguNTkuMDkgMi41NCAxLjkyLTIwLjQ3IDguNjEuMzkuOTIgMjAuNDYtOC42MS0uNCAzLjE2ek0yMDAuNjggMTAyLjcybC03LjUxLTQuMTkgMS4yNSAyLjkyLTIxLjQ5LTIuNjEtLjEzLjk5IDIxLjUgMi42Mi0xLjkyIDIuNTN6TTI0Mi41NSAxMjcuNjhsLTQuNDItNy4zOC0uMzcgMy4xNi0xOC42NS0xMy45OC0uNi44IDE4LjY1IDEzLjk4LTIuOTMgMS4yNHpNMjY2LjIyIDE2OS45OGwtLjE1LTguNi0xLjkgMi41Ni04LjgxLTIwLjUzLS45MS4zOSA4LjggMjAuNTMtMy4xNi0uMzh6TTI2OS42NiAxODguOTlsLS45OS0uMTQtMyAyMS4zLTIuNS0xLjk3IDIuMTEgOC4zNCA0LjMzLTcuNDMtMi45NSAxLjJ6TTI1OC41MSAyMzUuMThsLS44LS42LTE0LjU0IDE5LjI5LTEuMjQtMi45My0yLjE5IDguMzEgNy4zOS00LjQtMy4xNi0uMzh6TTIyNC4zNCAyNzEuN2wtLjM5LS45Mi0xOS45NiA4LjM1LjQxLTMuMTYtNi4wOCA2LjA4IDguNTktLjA4LTIuNTMtMS45MnpNMTc4LjE5IDI4NC4yOGwtMjEuMDYtMi42MiAxLjkzLTIuNTMtOC4zIDIuMjQgNy40OSA0LjIxLTEuMjQtMi45MyAyMS4wNiAyLjYyek0xMzIuNTEgMjczLjU0bC0xOC4xOS0xMy43NyAyLjk0LTEuMjMtOC4zMS0yLjIyIDQuMzggNy40LjM5LTMuMTYgMTguMTggMTMuNzh6TTk2LjkzIDIzOS45MWwtOC4xOS0xOS42NiAzLjE2LjQxLTYuMDYtNi4wOS4wNSA4LjU5IDEuOTMtMi41MyA4LjE5IDE5LjY3ek04OC42OSAxNzUuNTdsLTIuMjUtOC4zLTQuMjEgNy40OSAyLjkzLTEuMjRMODIuNiAxOTRsMSAuMTIgMi41NS0yMC40OHpNMTExLjM4IDEyNS4zOWwtNy40IDQuMzggMy4xNi4zOS0xMy41NSAxNy45My43OS42IDEzLjU2LTE3LjkzIDEuMjMgMi45NHoiLz48L2c+PGcgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIj48Y2lyY2xlIGZpbGw9IiNBQUYiIHN0cm9rZT0iIzQxNDA0MiIgY3g9IjI2Ny42OSIgY3k9IjE3OS40NSIgcj0iOS41OSIvPjxjaXJjbGUgZmlsbD0iI0FBRiIgc3Ryb2tlPSIjNDE0MDQyIiBjeD0iMjYyIiBjeT0iMjI2LjM4IiByPSI5LjU5Ii8+PGNpcmNsZSBmaWxsPSIjQUFGIiBzdHJva2U9IiM0MTQwNDIiIGN4PSIyMzIuMzIiIGN5PSIyNjUuNjIiIHI9IjkuNTkiLz48Y2lyY2xlIGZpbGw9IiNBQUYiIHN0cm9rZT0iIzQxNDA0MiIgY3g9IjE4OC4xNiIgY3k9IjI4My45OSIgcj0iOS41OSIvPjxjaXJjbGUgZmlsbD0iI0FBRiIgc3Ryb2tlPSIjNDE0MDQyIiBjeD0iMTQxLjM5IiBjeT0iMjc4LjIxIiByPSI5LjU5Ii8+PGNpcmNsZSBmaWxsPSIjQUFGIiBzdHJva2U9IiM0MTQwNDIiIGN4PSIxMDIuMjYiIGN5PSIyNDguNTciIHI9IjkuNTkiLz48Y2lyY2xlIGZpbGw9IiNBQUYiIHN0cm9rZT0iIzQxNDA0MiIgY3g9IjgzLjkiIGN5PSIyMDQuNDIiIHI9IjkuNTkiLz48Y2lyY2xlIGZpbGw9IiNBQUYiIHN0cm9rZT0iIzQxNDA0MiIgY3g9Ijg5LjY4IiBjeT0iMTU3LjY1IiByPSI5LjU5Ii8+PGNpcmNsZSBmaWxsPSIjQUFGIiBzdHJva2U9IiM0MTQwNDIiIGN4PSIxMTkuMzEiIGN5PSIxMTguNTIiIHI9IjkuNTkiLz48Y2lyY2xlIGZpbGw9IiNBQUYiIHN0cm9rZT0iIzQxNDA0MiIgY3g9IjE2My40NyIgY3k9IjEwMC4xNSIgcj0iOS41OSIvPjxjaXJjbGUgZmlsbD0iI0FBRiIgc3Ryb2tlPSIjNDE0MDQyIiBjeD0iMjEwLjIzIiBjeT0iMTA1LjkzIiByPSI5LjU5Ii8+PGNpcmNsZSBmaWxsPSIjQUFGIiBzdHJva2U9IiM0MTQwNDIiIGN4PSIyNDkuMzMiIGN5PSIxMzUuNTMiIHI9IjkuNTkiLz48Y2lyY2xlIGZpbGw9IiNBQUYiIHN0cm9rZT0iIzQxNDA0MiIgY3g9IjI2Ny42OSIgY3k9IjE3OS40NSIgcj0iOS41OSIvPjxjaXJjbGUgZmlsbD0iI0FGQSIgc3Ryb2tlPSIjMDAwIiBjeD0iMjYuMzYiIGN5PSIyNS41NSIgcj0iOS41OSIvPjxjaXJjbGUgZmlsbD0iI0FGQSIgc3Ryb2tlPSIjMDAwIiBjeD0iNTYuOTEiIGN5PSI1Ni4xIiByPSI5LjU5Ii8+PGNpcmNsZSBmaWxsPSIjQUZBIiBzdHJva2U9IiMwMDAiIGN4PSI4OC4wNiIgY3k9Ijg3LjI1IiByPSI5LjU5Ii8+PC9nPjxwYXRoIGQ9Ik0xMjAuMyAxMjIuNTFoLTEuN3YtNS40NWgtMi4xMXYtMS4yOGMxLjE5LjAyIDIuMjgtLjM4IDIuNDYtMS42N2gxLjM2djguNHpNMTYwLjk1IDk5LjQzYy0uMDYtMS45MiAxLjAzLTMuMzkgMy4wNS0zLjM5IDEuNTQgMCAyLjg4Ljk4IDIuODggMi42MyAwIDEuMjYtLjY3IDEuOTYtMS41IDIuNTQtLjgzLjU5LTEuODEgMS4wNy0yLjQyIDEuOTNoMy45N3YxLjQ2aC02LjE2Yy4wMS0xLjk0IDEuMi0yLjc3IDIuNjUtMy43NS43NC0uNSAxLjc1LTEuMDIgMS43Ni0yLjA1IDAtLjc5LS41My0xLjMtMS4yNi0xLjMtMS4wMSAwLTEuMzMgMS4wNC0xLjMzIDEuOTNoLTEuNjR6TTIwOS42NSAxMDQuNzRjLjczLjA2IDEuNzktLjA4IDEuNzktMS4wNCAwLS43MS0uNTYtMS4xMi0xLjE5LTEuMTItLjg1IDAtMS4zMS42NC0xLjI5IDEuNWgtMS42MmMuMDYtMS43MSAxLjE3LTIuOSAyLjktMi45IDEuMzQgMCAyLjgyLjgzIDIuODIgMi4zMyAwIC43OS0uNCAxLjUtMS4xOCAxLjcxdi4wMmMuOTIuMiAxLjQ5Ljk3IDEuNDkgMS45MSAwIDEuNzYtMS40NyAyLjc2LTMuMTIgMi43Ni0xLjg4IDAtMy4xNS0xLjEzLTMuMTItMy4wNmgxLjYyYy4wNC45MS40OSAxLjY2IDEuNDggMS42Ni43NyAwIDEuMzctLjUzIDEuMzctMS4zMiAwLTEuMjctMS4xMi0xLjI1LTEuOTQtMS4yNXYtMS4yek0yNDkuNTcgMTM3LjJoLTMuNTV2LTEuNTZsMy42NS00Ljg5aDEuNTJ2NS4wNWgxLjEydjEuNGgtMS4xMnYxLjk0aC0xLjYydi0xLjk0em0wLTQuMzJoLS4wNGwtMi4xNyAyLjkyaDIuMjF2LTIuOTJ6TTI3MC40NSAxNzYuNDhoLTMuNDdsLS4zNCAxLjkxLjAyLjAyYy40Ni0uNDcuOTgtLjY1IDEuNjQtLjY1IDEuNjUgMCAyLjU5IDEuMjggMi41OSAyLjg1IDAgMS43My0xLjQzIDMuMDYtMy4xMiAzLjAyLTEuNjMgMC0zLjA5LS45LTMuMTItMi42NmgxLjdjLjA4Ljc0LjY0IDEuMjYgMS4zOCAxLjI2Ljg5IDAgMS40NS0uNzggMS40NS0xLjYyIDAtLjg4LS41NC0xLjU3LTEuNDUtMS41Ny0uNjEgMC0uOTUuMjItMS4yOC42N2gtMS41NGwuODMtNC42NGg0LjY5djEuNDF6TTI2My4xNiAyMjQuODljLS4xMS0uNTYtLjU0LTEuMDQtMS4xMy0xLjA0LTEuMjQgMC0xLjU2IDEuNjItMS42MSAyLjU1bC4wMi4wMmMuNDctLjY2IDEuMDgtLjk0IDEuODktLjk0LjcyIDAgMS40NS4zNCAxLjkzLjg2LjQ0LjUyLjY1IDEuMjEuNjUgMS44NyAwIDEuNzEtMS4xOSAzLjA3LTIuOTQgMy4wNy0yLjU0IDAtMy4yMy0yLjIyLTMuMjMtNC4zNCAwLTIuMDUuOTEtNC4zOSAzLjMtNC4zOSAxLjQ1IDAgMi41My44NSAyLjcyIDIuMzNoLTEuNnptLTIuNTggMy40NGMwIC43OC41IDEuNTYgMS4zNSAxLjU2LjgyIDAgMS4yOC0uNzggMS4yOC0xLjU0IDAtLjc5LS40MS0xLjU4LTEuMjgtMS41OC0uOTEgMC0xLjM1LjczLTEuMzUgMS41NnpNMjM1LjAzIDI2Mi44NGMtMS43NiAxLjU0LTIuNzIgNC42OS0yLjc1IDYuOTNoLTEuODJjLjE5LTIuNDggMS4yMi00Ljg5IDIuODItNi44MWgtMy45OHYtMS41OGg1LjczdjEuNDZ6TTE4OC4wMSAyODAuMjNjMi4wOSAwIDIuODEgMS40NCAyLjgxIDIuMjUgMCAuODMtLjQzIDEuNS0xLjIyIDEuNzZ2LjAyYzEgLjIzIDEuNTcgMSAxLjU3IDIuMDUgMCAxLjc2LTEuNTggMi42NC0zLjE0IDIuNjQtMS42MiAwLTMuMTktLjgyLTMuMTktMi42MyAwLTEuMDcuNi0xLjgyIDEuNTgtMi4wNnYtLjAyYy0uODItLjIzLTEuMjQtLjktMS4yNC0xLjczIDAtMS41IDEuNDctMi4yOCAyLjgzLTIuMjh6bS4wMiA3LjQ1Yy44MiAwIDEuNDQtLjU4IDEuNDQtMS40MiAwLS44LS42NS0xLjM0LTEuNDQtMS4zNC0uODMgMC0xLjQ5LjQ3LTEuNDkgMS4zMyAwIC44Ny42NyAxLjQzIDEuNDkgMS40M3ptLS4wMi0zLjljLjcgMCAxLjI2LS4zOCAxLjI2LTEuMSAwLS40My0uMi0xLjE2LTEuMjYtMS4xNi0uNjggMC0xLjI4LjQyLTEuMjggMS4xNiAwIC43My42IDEuMSAxLjI4IDEuMXpNMTQwLjk5IDI4MC4yNmMuMTEuNTYuNTQgMS4wNCAxLjEzIDEuMDQgMS4yNCAwIDEuNTYtMS42MiAxLjYxLTIuNTVsLS4wMi0uMDJjLS40Ny42Ni0xLjA4Ljk0LTEuOS45NC0uNzIgMC0xLjQ1LS4zNC0xLjkzLS44Ni0uNDQtLjUyLS42NS0xLjIxLS42NS0xLjg3IDAtMS43MSAxLjE5LTMuMDcgMi45NC0zLjA3IDIuNTQgMCAzLjIzIDIuMjIgMy4yMyA0LjM0IDAgMi4wNS0uOTEgNC4zOS0zLjMgNC4zOS0xLjQ1IDAtMi41My0uODUtMi43Mi0yLjMzaDEuNjF6bTIuNTgtMy40NGMwLS43OC0uNS0xLjU2LTEuMzYtMS41Ni0uODIgMC0xLjI4Ljc4LTEuMjggMS41NCAwIC43OS40MSAxLjU4IDEuMjggMS41OC45MSAwIDEuMzYtLjczIDEuMzYtMS41NnpNOTkuNDcgMjUyLjk0aC0xLjd2LTUuNDVoLTIuMTF2LTEuMjhjMS4xOS4wMyAyLjI4LS4zOCAyLjQ2LTEuNjdoMS4zNnY4LjR6TTEwNC43NiAyNDQuMzdjMS42OCAwIDMuMDkgMS4wNSAzLjA5IDQuMzMgMCAzLjM1LTEuNDIgNC40LTMuMDkgNC40LTEuNjYgMC0zLjA3LTEuMDUtMy4wNy00LjQgMC0zLjI3IDEuNDItNC4zMyAzLjA3LTQuMzN6bTAgNy4zM2MxLjM5IDAgMS4zOS0yLjA1IDEuMzktMyAwLS44OCAwLTIuOTMtMS4zOS0yLjkzLTEuMzcgMC0xLjM3IDIuMDUtMS4zNyAyLjkzLjAxLjk1LjAxIDMgMS4zNyAzek04MS42NSAyMDguMThoLTEuN3YtNS40NWgtMi4xMXYtMS4yOGMxLjE5LjAyIDIuMjgtLjM4IDIuNDYtMS42N2gxLjM2djguNHpNODguMzIgMjA4LjE4aC0xLjd2LTUuNDVoLTIuMTF2LTEuMjhjMS4xOS4wMiAyLjI4LS4zOCAyLjQ2LTEuNjdoMS4zNnY4LjR6TTg3LjMxIDE2MS4zOGgtMS43di01LjQ1SDgzLjV2LTEuMjhjMS4xOS4wMiAyLjI4LS4zOCAyLjQ2LTEuNjdoMS4zNnY4LjR6TTg5LjcyIDE1Ni4yMWMtLjA2LTEuOTIgMS4wMy0zLjM5IDMuMDUtMy4zOSAxLjU0IDAgMi44OC45OCAyLjg4IDIuNjMgMCAxLjI2LS42NyAxLjk2LTEuNSAyLjU0LS44My41OS0xLjgxIDEuMDctMi40MiAxLjkzaDMuOTd2MS40NmgtNi4xNmMuMDEtMS45NCAxLjItMi43NyAyLjY1LTMuNzUuNzQtLjUgMS43NS0xLjAyIDEuNzYtMi4wNSAwLS43OS0uNTMtMS4zLTEuMjYtMS4zLTEuMDEgMC0xLjMzIDEuMDQtMS4zMyAxLjkzaC0xLjY0ek0yNS41NSAyMC44N2gxLjkzbDMuMiA4LjU2aC0xLjk2bC0uNjUtMS45MWgtMy4ybC0uNjcgMS45MWgtMS45bDMuMjUtOC41NnptLS4xOCA1LjI1aDIuMjJsLTEuMDgtMy4xNGgtLjAybC0xLjEyIDMuMTR6TTUzLjc2IDUxLjk5aDQuMDNjMS42MyAwIDIuNzMuNTMgMi43MyAyLjEyIDAgLjg0LS40MiAxLjQzLTEuMTYgMS43OSAxLjA0LjMgMS41NyAxLjEgMS41NyAyLjE3IDAgMS43NC0xLjQ4IDIuNDgtMy4wMiAyLjQ4aC00LjE1di04LjU2em0xLjg4IDMuNDZoMS45MWMuNjYgMCAxLjE1LS4zIDEuMTUtMS4wMiAwLS44Mi0uNjItLjk4LTEuMjktLjk4aC0xLjc2djJ6bTAgMy42NGgyLjAxYy43NCAwIDEuMzktLjI0IDEuMzktMS4xMyAwLS44OC0uNTUtMS4yMi0xLjM1LTEuMjJoLTIuMDV2Mi4zNXpNOTAuNDMgODUuODhjLS4xMi0uODUtLjk0LTEuNS0xLjg3LTEuNS0xLjY5IDAtMi4zMyAxLjQ0LTIuMzMgMi45NCAwIDEuNDMuNjQgMi44NyAyLjMzIDIuODcgMS4xNSAwIDEuOC0uNzkgMS45NC0xLjkyaDEuODJjLS4xOSAyLjEzLTEuNjcgMy41LTMuNzcgMy41LTIuNjUgMC00LjIxLTEuOTgtNC4yMS00LjQ1IDAtMi41NCAxLjU2LTQuNTIgNC4yMS00LjUyIDEuODggMCAzLjQ3IDEuMSAzLjY5IDMuMDhoLTEuODF6Ii8+PC9zdmc+' />
```ruby
# Use the `next' method to get the following node.
node.next
```
```javascript
// Use the `getNext' method or 'next' property to get the following node.
node.getNext()
node.next
```
```python
# Use the `next' attribute to get the following node
node.next
```
```java
// Use the `getNext()` method to get the following node.
node.getNext()
```
```haskell
-- use the `next :: Node a -> Node a` function to get the following node
```
```cs
# Use the `next' method to get the following node.
node.next
```
```c
// Use the `next` field to get the following node.
Node* nextNode = nodePtr->next;
```
```cpp
// Use the `getNext()` method to get the following node.
nodePtr->getNext()
```
~~~if:php
Use the `Node::getNext()` instance method to get the following node.
```php
$node->getNext();
```
~~~
~~~if:kotlin
Use the `Node.next` to get the next following node.
```kotlin
node.next
```
~~~
Notes:
* do NOT mutate the nodes!
* in some cases there may be only a loop, with no dangling piece
> Thanks to shadchnev, I broke all of the methods from the Hash class.
> Don't miss dmitry's article in the discussion after you pass the Kata !! | algorithms | def loop_size(node):
turtle, rabbit = node . next, node . next . next
# Find a point in the loop. Any point will do!
# Since the rabbit moves faster than the turtle
# and the kata guarantees a loop, the rabbit will
# eventually catch up with the turtle.
while turtle != rabbit:
turtle = turtle . next
rabbit = rabbit . next . next
# The turtle and rabbit are now on the same node,
# but we know that node is in a loop. So now we
# keep the turtle motionless and move the rabbit
# until it finds the turtle again, counting the
# nodes the rabbit visits in the mean time.
count = 1
rabbit = rabbit . next
while turtle != rabbit:
count += 1
rabbit = rabbit . next
# voila
return count
| Can you get the loop ? | 52a89c2ea8ddc5547a000863 | [
"Algorithms",
"Linked Lists",
"Performance"
] | https://www.codewars.com/kata/52a89c2ea8ddc5547a000863 | 5 kyu |
Deoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T').
Ribonucleic acid, RNA, is the primary messenger molecule in cells. RNA differs slightly from DNA its chemical structure and contains no Thymine. In RNA Thymine is replaced by another nucleic acid Uracil ('U').
Create a function which translates a given DNA string into RNA.
For example:
```
"GCAT" => "GCAU"
```
The input string can be of arbitrary length - in particular, it may be empty. All input is guaranteed to be valid, i.e. each input string will only ever consist of `'G'`, `'C'`, `'A'` and/or `'T'`. | reference | def DNAtoRNA(dna):
return dna . replace('T', 'U')
| DNA to RNA Conversion | 5556282156230d0e5e000089 | [
"Fundamentals",
"Strings"
] | https://www.codewars.com/kata/5556282156230d0e5e000089 | 8 kyu |
We are diligently pursuing our elusive operative, **Matthew Knight**, who also goes by the alias **Roy Miller**. He employs a nomadic lifestyle to evade detection, constantly moving from one location to another, with each of his journeys following a perplexing and non-standard sequence of **itineraries**. Our mission is to *decipher the routes* he will undertake during each of his voyages.
## Task
You've been provided with an array of itinerary `routes`, decipher the **precise destinations** he will visit in the correct sequence according to his meticulously planned itineraries.
## Example
Based on the provided routes:
```
[ [USA, BRA], [JPN, PHL], [BRA, UAE], [UAE, JPN] ]
```
The correct sequence of destinations is:
```
"USA, BRA, UAE, JPN, PHL"
```
**Note:**
* You can safely assume that there will be *no duplicate locations* with distinct `routes`.
* All `routes` provided will have *non-empty itineraries*.
* There will always be *at least one (1)* route connecting one waypoint to another.
| algorithms | def find_routes(routes: list) - > str:
d = dict(routes)
res = list(d . keys() - d . values())
while res[- 1] in d:
res . append(d[res[- 1]])
return ', ' . join(res)
| Follow that Spy | 5899a4b1a6648906fe000113 | [
"Algorithms"
] | https://www.codewars.com/kata/5899a4b1a6648906fe000113 | 6 kyu |
In mathematics, the factorial of integer 'n' is written as 'n!'.
It is equal to the product of n and every integer preceding it.
For example: **5! = 1 x 2 x 3 x 4 x 5 = 120**
Your mission is simple: write a function that takes an integer 'n' and returns 'n!'.
You are guaranteed an integer argument. For any values outside the positive range, return `null`, `nil` or `None` .
**Note:** 0! is always equal to 1. Negative values should return null;
For more on Factorials : http://en.wikipedia.org/wiki/Factorial
| algorithms | import math
def factorial(n):
if n < 0:
return None
return math . factorial(n)
| Factorial Factory | 528e95af53dcdb40b5000171 | [
"Recursion",
"Mathematics",
"Algorithms"
] | https://www.codewars.com/kata/528e95af53dcdb40b5000171 | 7 kyu |
## Welcome to the Codewars Bar!
Codewars Bar recommends you drink 1 glass of water per standard drink so you're not hungover tomorrow morning.
Your fellow coders have bought you several drinks tonight in the form of a string. Return a string suggesting how many glasses of water you should drink to not be hungover.
## Examples
```
"1 beer" --> "1 glass of water"
because you drank one standard drink
"1 shot, 5 beers, 2 shots, 1 glass of wine, 1 beer" --> "10 glasses of water"
because you drank ten standard drinks
```
Note:
To keep the things simple, we'll consider that any "numbered thing" in the string is a drink. Even `"1 bear"` -> `"1 glass of water"`; or `"1 chainsaw and 2 pools"` -> `"3 glasses of water"`...
| reference | def hydrate(drink_string):
c = sum(int(c) for c in drink_string if c . isdigit())
return "{} {} of water" . format(c, 'glass') if c == 1 else "{} {} of water" . format(c, 'glasses')
| Responsible Drinking | 5aee86c5783bb432cd000018 | [
"Fundamentals"
] | https://www.codewars.com/kata/5aee86c5783bb432cd000018 | 7 kyu |
Wolves have been reintroduced to Great Britain. You are a sheep farmer, and are now plagued by wolves which pretend to be sheep. Fortunately, you are good at spotting them.
Warn the sheep in front of the wolf that it is about to be eaten. Remember that you are standing **at the front of the queue** which is at the end of the array:
```
[sheep, sheep, sheep, sheep, sheep, wolf, sheep, sheep] (YOU ARE HERE AT THE FRONT OF THE QUEUE)
7 6 5 4 3 2 1
```
If the wolf is the closest animal to you, return `"Pls go away and stop eating my sheep"`. Otherwise, return `"Oi! Sheep number N! You are about to be eaten by a wolf!"` where `N` is the sheep's position in the queue.
**Note:** there will always be exactly one wolf in the array.
### Examples
Input: `["sheep", "sheep", "sheep", "wolf", "sheep"]`
Output: `"Oi! Sheep number 1! You are about to be eaten by a wolf!"`
Input: `["sheep", "sheep", "wolf"]`
Output: `"Pls go away and stop eating my sheep"`
| reference | def warn_the_sheep(queue):
n = len(queue) - queue . index('wolf') - 1
return f'Oi! Sheep number { n } ! You are about to be eaten by a wolf!' if n else 'Pls go away and stop eating my sheep'
| A wolf in sheep's clothing | 5c8bfa44b9d1192e1ebd3d15 | [
"Fundamentals",
"Arrays"
] | https://www.codewars.com/kata/5c8bfa44b9d1192e1ebd3d15 | 8 kyu |
Take an array and remove every second element from the array. Always keep the first element and start removing with the next element.
### Example:
```if-not:c
`["Keep", "Remove", "Keep", "Remove", "Keep", ...]` --> `["Keep", "Keep", "Keep", ...]`
```
```if:c
~~~c
size_t length = 5;
remove_every_other(&length, {1, 2, 3, 4, 5});
// --> {1, 3, 5}
~~~
```
None of the arrays will be empty, so you don't have to worry about that!
| reference | def remove_every_other(my_list):
return my_list[:: 2]
| Removing Elements | 5769b3802ae6f8e4890009d2 | [
"Lists",
"Arrays",
"Fundamentals"
] | https://www.codewars.com/kata/5769b3802ae6f8e4890009d2 | 8 kyu |
## Terminal game move function
In this game, the hero moves from left to right. The player rolls the dice and moves the number of spaces indicated by the dice **two times**.
~~~if-not:sql
Create a function for the terminal game that takes the current position of the hero and the roll (1-6) and return the new position.
~~~
~~~if:sql
In SQL, you will be given a table `moves` with columns `position` and `roll`. Return a table which uses the current position of the hero and the roll (1-6) and returns the new position in a column `res`.
~~~
### Example:
```python
move(3, 6) should equal 15
```
```if:bf
### BF:
Since this is an 8kyu kata, you are provided a modified runBF function, numericRunBF, that automatically parses input and output for your ease.
See the sample test cases to see what I mean: You can simply input two numbers and get a number as output (unless you're doing something wrong), so it should be convenient for you to modify the tests as you wish.
Oh, and you won't have to worry about overflow, the correct answer will never be higher than 255. :)
```
| reference | def move(position, roll):
return position + 2 * roll
| Grasshopper - Terminal game move function | 563a631f7cbbc236cf0000c2 | [
"Fundamentals"
] | https://www.codewars.com/kata/563a631f7cbbc236cf0000c2 | 8 kyu |
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.
Furthermore this percent of loss increases of `0.5` percent
at the end of every two months.
Our man finds it difficult to make all these calculations.
**Can you help him?**
How many months will it take him to save up enough money to buy the car he wants, and how much money will he have left over?
**Parameters and return of function:**
```
parameter (positive int or float, guaranteed) start_price_old (Old car price)
parameter (positive int or float, guaranteed) start_price_new (New car price)
parameter (positive int or float, guaranteed) saving_per_month
parameter (positive float or int, guaranteed) percent_loss_by_month
nbMonths(2000, 8000, 1000, 1.5) should return [6, 766] or (6, 766)
```
#### Detail of the above example:
```
end month 1: percent_loss 1.5 available -4910.0
end month 2: percent_loss 2.0 available -3791.7999...
end month 3: percent_loss 2.0 available -2675.964
end month 4: percent_loss 2.5 available -1534.06489...
end month 5: percent_loss 2.5 available -395.71327...
end month 6: percent_loss 3.0 available 766.158120825...
return [6, 766] or (6, 766)
```
where `6` is the number of months at **the end of which** he can buy the new car and `766` is the nearest integer to `766.158...` (rounding `766.158` gives `766`).
**Note:**
Selling, buying and saving are normally done at end of month.
Calculations are processed at the end of each considered month
but if, by chance from the start, the value of the old car is bigger than the value of the new one or equal there is no saving to be made, no need to wait so he can at the beginning of the month buy the new car:
```
nbMonths(12000, 8000, 1000, 1.5) should return [0, 4000]
nbMonths(8000, 8000, 1000, 1.5) should return [0, 0]
```
We don't take care of a deposit of savings in a bank:-)
| reference | def nbMonths(oldCarPrice, newCarPrice, saving, loss):
months = 0
budget = oldCarPrice
while budget < newCarPrice:
months += 1
if months % 2 == 0:
loss += 0.5
oldCarPrice *= (100 - loss) / 100
newCarPrice *= (100 - loss) / 100
budget = saving * months + oldCarPrice
return [months, round(budget - newCarPrice)]
| Buying a car | 554a44516729e4d80b000012 | [
"Fundamentals",
"Mathematics"
] | https://www.codewars.com/kata/554a44516729e4d80b000012 | 6 kyu |
# Find the missing letter
Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array.
~~~if:factor
In the case of factor, your array of letters will be a string.
~~~
You will always get an valid array. And it will be always exactly one letter be missing. The length of the array will always be at least 2.<br>
The array will always contain letters in only one case.
Example:
~~~if-not:swift,factor
```
['a','b','c','d','f'] -> 'e'
['O','Q','R','S'] -> 'P'
```
~~~
~~~if:factor
```factor
"abcdf" -> CHAR: e
"OQRS" -> CHAR: P
```
~~~
```if:swift
["a","b","c","d","f"] -> "e"
["O","Q","R","S"] -> "P"
```
(Use the English alphabet with 26 letters!)
Have fun coding it and please don't forget to vote and rank this kata! :-)
I have also created other katas. Take a look if you enjoyed this kata! | algorithms | def find_missing_letter(chars):
n = 0
while ord(chars[n]) == ord(chars[n + 1]) - 1:
n += 1
return chr(1 + ord(chars[n]))
| Find the missing letter | 5839edaa6754d6fec10000a2 | [
"Mathematics",
"Algorithms"
] | https://www.codewars.com/kata/5839edaa6754d6fec10000a2 | 6 kyu |
Write a function that removes the spaces from the string, then return the resultant string.
Examples:
```
Input -> Output
"8 j 8 mBliB8g imjB8B8 jl B" -> "8j8mBliB8gimjB8B8jlB"
"8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd" -> "88Bifk8hB8BB8BBBB888chl8BhBfd"
"8aaaaa dddd r " -> "8aaaaaddddr"
```
~~~if:bf
The input string will be terminated with a null character `\0`.
~~~
~~~if:c,nasm
For C and Nasm, you must return a new dynamically allocated string.
~~~
| reference | def no_space(x):
return x . replace(' ', '')
| Remove String Spaces | 57eae20f5500ad98e50002c5 | [
"Fundamentals",
"Strings"
] | https://www.codewars.com/kata/57eae20f5500ad98e50002c5 | 8 kyu |