Skip to content

Commit

Permalink
Merge pull request #362 from iKostanOrg/kyu7
Browse files Browse the repository at this point in the history
Kyu7
  • Loading branch information
ikostan authored Jul 22, 2024
2 parents c215f79 + 3c97988 commit a8e639e
Show file tree
Hide file tree
Showing 32 changed files with 263 additions and 154 deletions.
15 changes: 8 additions & 7 deletions kyu_7/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
## 7 kyu - Beginner
# 7 kyu - Beginner

<div align="center">
<img width="30%" height="30%" src="https://github.com/ikostan/codewars/blob/master/img/copy-rank-kyu.png" hspace="10">
</div>
![RANK](https://github.com/ikostan/codewars/blob/master/img/copy-rank-kyu.png)

### Honor
## Honor

Honor represents the level of respect a user has earned from the community, based on their skill and contributions. Honor is earned fastest through creating kata, crafting great solutions, and constructive comments.
Honor represents the level of respect a user has earned from the community,
based on their skill and contributions. Honor is earned fastest through
creating kata, crafting great solutions, and constructive comments.

### Earning Ranks

You can advance through the ranks by completing kata at or above your rank - the harder the kata the faster you advance.
You can advance through the ranks by completing kata at or above your
rank - the harder the kata the faster you advance.

### List of Completed Kata (Python 3)
<!-- markdownlint-disable MD013 -->
Expand Down
15 changes: 11 additions & 4 deletions kyu_7/always_perfect/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
## Always perfect
# Always perfect

While surfing in web I found interesting math problem called "Always perfect". That means if you add 1 to the product of four consecutive numbers the answer is ALWAYS a perfect square. For example we have: 1,2,3,4 and the product will be 1X2X3X4=24. If we add 1 to the product that would become 25, since the result number is a perfect square the square root of 25 would be 5.
While surfing in web I found interesting math problem called "Always perfect".
That means if you add 1 to the product of four consecutive numbers the answer
is ALWAYS a perfect square. For example we have: 1,2,3,4 and the product will
be 1X2X3X4=24. If we add 1 to the product that would become 25, since the result
number is a perfect square the square root of 25 would be 5.

So now lets write a function which takes numbers separated by commas in string format and returns the number which is a perfect square and the square root of that number.
So now lets write a function which takes numbers separated by commas in string
format and returns the number which is a perfect square and the square root of
that number.

If string contains other characters than number or it has more or less than 4 numbers separated by comma function returns "incorrect input".
If string contains other characters than number or it has more or less than 4
numbers separated by comma function returns "incorrect input".

If string contains 4 numbers but not consecutive it returns "not consecutive".

Expand Down
7 changes: 4 additions & 3 deletions kyu_7/basic_math_add_or_subtract/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## Basic Math (Add or Subtract)
# Basic Math (Add or Subtract)

In this kata, you will do addition and subtraction on a given string. The return value must be also a string.
In this kata, you will do addition and subtraction on a given string.
The return value must be also a string.

Note: the input will not be empty.

### Examples
## Examples

```text
"1plus2plus3plus4" --> "10"
Expand Down
8 changes: 5 additions & 3 deletions kyu_7/beginner_series_sum_of_numbers/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## Beginner Series #3 Sum of Numbers
# Beginner Series #3 Sum of Numbers

Given two integers **a** and **b**, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return **a** or **b**.
Given two integers **a** and **b**, which can be positive or negative,
find the sum of all the numbers between including them too and return it.
If the two numbers are equal return **a** or **b**.

**Note:** a and b are not ordered!

### Examples
## Examples

```bash
get_sum(1, 0) == 1 // 1 + 0 = 1
Expand Down
11 changes: 7 additions & 4 deletions kyu_7/disemvowel_trolls/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
## Disemvowel Trolls
# Disemvowel Trolls

Trolls are attacking your comment section!

A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat.
A common way to deal with this situation is to remove all of the
vowels from the trolls' comments, neutralizing the threat.

Your task is to write a function that takes a string and return a new string with all vowels removed.
Your task is to write a function that takes a string and return
a new string with all vowels removed.

For example, the string "This website is for losers LOL!" would become "Ths wbst s fr lsrs LL!".
For example, the string "This website is for losers LOL!" would
become "Ths wbst s fr lsrs LL!".

**Note:** for this kata **y** isn't considered a vowel.

Expand Down
25 changes: 16 additions & 9 deletions kyu_7/easy_line/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
## Easy Line
# Easy Line

In the drawing below we have a part of the Pascal's triangle, lines are numbered from zero (top).
In the drawing below we have a part of the Pascal's triangle, lines
are numbered from zero (top).

We want to calculate the sum of the squares of the binomial coefficients on a given line with a function called easyline (or easyLine or easy-line).
We want to calculate the sum of the squares of the binomial coefficients
on a given line with a function called easyline (or easyLine or easy-line).

Can you write a program which calculate `easyline(n)` where n is the line number?
Can you write a program which calculate `easyline(n)` where n is
the line number?

The function will take `n (with: n>= 0)` as parameter and will return the sum of the squares of the binomial coefficients on line `n`.
The function will take `n (with: n>= 0)` as parameter and will return
the sum of the squares of the binomial coefficients on line `n`.

### Examples
## Examples

```text
easyline(0) => 1
Expand All @@ -19,11 +23,14 @@ easyline(50) => 100891344545564193334812497256

[Reference](http://mathworld.wolfram.com/BinomialCoefficient.html)

<img src="https://github.com/ikostan/codewars/tree/master/kyu_7/easy_line/eUGaNvIm.jpg" alt="alternative text"><br/>
![eUGaNvIm](https://github.com/ikostan/codewars/tree/master/kyu_7/easy_line/eUGaNvIm.jpg)

### Note
## Note

In Javascript, Coffeescript, Typescript, C++, PHP, C, R, Nim, Fortran to get around the fact that we have no big integers the function easyLine(n) will in fact return `round(log(easyline(n)))` and not the `easyline(n)` of the other languages.
In Javascript, Coffeescript, Typescript, C++, PHP, C, R, Nim, Fortran
to get around the fact that we have no big integers the function
easyLine(n) will in fact return `round(log(easyline(n)))` and not
the `easyline(n)` of the other languages.

```text
easyLine(0) => 0
Expand Down
10 changes: 7 additions & 3 deletions kyu_7/factorial/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## Factorial
# Factorial

In mathematics, the factorial of a non-negative integer `n`, denoted by `n!`, is the product of all positive integers less than or equal to `n`. For example: `5! = 5 * 4 * 3 * 2 * 1 = 120`. By convention the value of `0!` is `1`.
In mathematics, the factorial of a non-negative integer `n`,
denoted by `n!`, is the product of all positive integers less
than or equal to `n`. For example: `5! = 5 * 4 * 3 * 2 * 1 = 120`.
By convention the value of `0!` is `1`.

Write a function to calculate factorial for a given input. If input is below `0` or above `12` throw an exception of type ValueError (Python).
Write a function to calculate factorial for a given input. If input
is below `0` or above `12` throw an exception of type ValueError (Python).

[Source](https://www.codewars.com/kata/54ff0d1f355cfd20e60001fc/train/python)
11 changes: 6 additions & 5 deletions kyu_7/fill_the_hard_disk_drive/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
## Computer problem series #1
# Computer problem series #1

### Fill the Hard Disk Drive
## Fill the Hard Disk Drive

Your task is to determine how many files of the copy queue you will be able to save into your Hard Disk Drive.
Your task is to determine how many files of the copy queue you
will be able to save into your Hard Disk Drive.

### Input
## Input

* Array of file sizes (0 <= s <= 100)
* Capacity of the HD (0 <= c <= 500)

### Output
## Output

* Number of files that can be fully saved in the HD

Expand Down
13 changes: 8 additions & 5 deletions kyu_7/find_the_longest_gap/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## Find the longest gap
# Find the longest gap

A binary gap within a positive number `num` is any sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of `num`.
A binary gap within a positive number `num` is any sequence of
consecutive zeros that is surrounded by ones at both ends in the
binary representation of `num`.

**For example:**

<!-- markdownlint-disable MD013 -->
> `9` has binary representation `1001` and contains a binary gap of length `2`.
>
> `529` has binary representation `1000010001` and contains two binary gaps: one of length `4` and one of length `3`.
Expand All @@ -12,8 +14,9 @@ A binary gap within a positive number `num` is any sequence of consecutive zeros
>
> `15` has binary representation `1111` and has 0 binary gaps.
Write `function gap(num)` that, given a positive num, returns the length of its longest binary gap.
Write `function gap(num)` that, given a positive num, returns
the length of its longest binary gap.

The function should return `0` if num doesn't contain a binary gap.

<!-- markdownlint-enable MD013 -->
[Source](https://www.codewars.com/kata/55b86beb1417eab500000051/train/python)
7 changes: 5 additions & 2 deletions kyu_7/formatting_decimal_places_1/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Formatting decimal places #1
# Formatting decimal places #1

Each floating-point number should be formatted that only the first two decimal places are returned. You don't need to check whether the input is a valid number because only valid numbers are used in the tests.
Each floating-point number should be formatted that only the
first two decimal places are returned. You don't need to check
whether the input is a valid number because only valid numbers
are used in the tests.

Don't round the numbers! Just cut them after two decimal places!

Expand Down
8 changes: 5 additions & 3 deletions kyu_7/fun_with_lists_length/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## Fun with lists: length
# Fun with lists: length

Implement the method length, which accepts a linked list (head), and returns the length of the list.
Implement the method length, which accepts a linked list
(head), and returns the length of the list.

For example: Given the list: `1 -> 2 -> 3 -> 4`, length should return 4.
For example: Given the list: `1 -> 2 -> 3 -> 4`, length should
return 4.

The linked list is defined as follows:

Expand Down
5 changes: 3 additions & 2 deletions kyu_7/help_bob_count_letters_and_digits/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## Help Bob count letters and digits
# Help Bob count letters and digits

Bob is a lazy man.

He needs you to create a method that can determine how many letters and digits are in a given string.
He needs you to create a method that can determine how
many letters and digits are in a given string.

Example:

Expand Down
7 changes: 5 additions & 2 deletions kyu_7/isograms/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Isograms
# Isograms

An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an `isogram`. Ignore letter case.
An isogram is a word that has no repeating letters, consecutive
or non-consecutive. Implement a function that determines whether
a string that contains only letters is an isogram. Assume the empty
string is an `isogram`. Ignore letter case.

```text
is_isogram("Dermatoglyphics" ) == true
Expand Down
13 changes: 9 additions & 4 deletions kyu_7/jaden_casing_strings/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
## Jaden Casing Strings
# Jaden Casing Strings

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. When writing on Twitter, he is known for almost always capitalizing every word.
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. When writing
on Twitter, he is known for almost always capitalizing every word.

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.
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
## Example

Not Jaden-Cased: "How can mirrors be real if our eyes aren't real"

Expand Down
2 changes: 1 addition & 1 deletion kyu_7/make_class/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Make Class
# Make Class

I don't like writing classes like this:

Expand Down
14 changes: 7 additions & 7 deletions kyu_7/maximum_multiple/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
## Maximum Multiple
# Maximum Multiple

### Task
## Task

Given a Divisor and a Bound, Find the largest integer N, Such That,

### Conditions
## Conditions

* N is divisible by divisor
* N is less than or equal to bound
* N is greater than 0.

### Notes
## Notes

* The parameters (divisor, bound) passed to the function are only positve values.
* It's guaranteed that a divisor is Found .

### Input > Output Examples

## Input > Output Examples
<!-- markdownlint-disable MD013 -->
```text
> maxMultiple (2,7) ==> return (6)
Expand All @@ -34,5 +34,5 @@ Given a Divisor and a Bound, Find the largest integer N, Such That,
`(185)` is divisible by `(37)`, `(185)` is less than or equal to bound `(200)`, and `(185)` is > `0`.
```

<!-- markdownlint-enable MD013 -->
[Source](https://www.codewars.com/kata/5aba780a6a176b029800041c/train/python)
7 changes: 4 additions & 3 deletions kyu_7/password_validator/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## Password validator
# Password validator

### Description
## Description

Your job is to create a simple password validation function, as seen on many websites.
Your job is to create a simple password validation function,
as seen on many websites.

The rules for a valid password are as follows:

Expand Down
2 changes: 1 addition & 1 deletion kyu_7/powers_of_3/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Powers of 3
# Powers of 3

Given a positive integer N, return the largest integer k such that 3^k < N.

Expand Down
21 changes: 14 additions & 7 deletions kyu_7/pull_your_words_together_man/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
## Pull your words together, man
# Pull your words together, man

Your friend Robbie has successfully created an AI that is capable of communicating in English!
Your friend Robbie has successfully created an AI that is
capable of communicating in English!

Robbie's almost done with the project, however the machine's output isn't working as expected. Here's a sample of a sentence that it outputs:
Robbie's almost done with the project, however the machine's
output isn't working as expected. Here's a sample of a sentence
that it outputs:

```text
> ["this","is","a","sentence"]
```

Every time that it tries to say a sentence, instead of formatting it in normal English orthography, it just outputs a list of words.
Every time that it tries to say a sentence, instead of formatting
it in normal English orthography, it just outputs a list of words.

Robbie has pulled multiple all-nighters to get this project finished, and he needs some beauty sleep. So, he wants you to write the last part of his code, a sentencify function, which takes the output that the machine gives, and formats it into proper English orthography.
Robbie has pulled multiple all-nighters to get this project finished,
and he needs some beauty sleep. So, he wants you to write the last part
of his code, a sentencify function, which takes the output that the
machine gives, and formats it into proper English orthography.

**Your function should:**

Expand All @@ -20,11 +27,11 @@ Robbie has pulled multiple all-nighters to get this project finished, and he nee
4. Do no other manipulation on the words.

Here are a few examples of what your function should do:

<!-- markdownlint-disable MD013 -->
```bash
["i", "am", "an", "AI"] => "I am an AI."
["FIELDS","of","CORN","are","to","be","sown"] => "FIELDS of CORN are to be sown."
["i'm","afraid","I","can't","let","you","do","that"] => "I'm afraid I can't let you do that."
```

<!-- markdownlint-enable MD013 -->
[Source](https://www.codewars.com/kata/59ad7d2e07157af687000070/train/python)
Loading

0 comments on commit a8e639e

Please sign in to comment.