Skip to content

Commit

Permalink
refactor: address code inspection problems (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParanoidUser committed Aug 3, 2023
1 parent 7eeaa4c commit 03cad08
Show file tree
Hide file tree
Showing 33 changed files with 65 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
interface EightiesKids4 {
static String markSpot(float n) {
return n > 0 && n % 2 > 0 && n % (int) n == 0 ? range(0, (int) n)
.map(i -> i = 2 * (i < n / 2 ? (int) n - i : i + 1))
.map(i -> 2 * (i < n / 2 ? (int) n - i : i + 1))
.mapToObj(i -> new StringBuilder(" ".repeat(i))
.replace((int) n * 2 - i, (int) n * 2 - i + 1, "X")
.replace(i - 2, i - 1, "X")
.replace(i - 1, i, "\n")
.toString()).collect(joining()) : "?";
}
}
}
2 changes: 1 addition & 1 deletion kata/6-kyu/arrange-matrix-by-diagonals-omg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Take the characters in that order, and place them back in so that you can read t

The diagonals run from bottom left to top right.

The first diagonal starts at element[0][0].
The first diagonal starts at `element[0][0]`.


## Note:
Expand Down
2 changes: 1 addition & 1 deletion kata/6-kyu/bad-hashing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The hashing standard works as follows on a string:
* Convert every character to its ascii code
* Lexicographically sort the list by its value descending (don't worry about stability)
* Add the index of the value to the ascii code.
e.g the first value, 0 is added, second value 1, and so on
e.g. the first value, 0 is added, second value 1, and so on
* Take modulo 16 of each value
* Change each value into a hexadecimal value 0-F
* Return the string in uppercase
Expand Down
4 changes: 2 additions & 2 deletions kata/6-kyu/cat-kata-part-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ In this first example, there is only one cat, so your function should return Tru
"------------",
"------------"], 10
```
In this second example, Mustache Cat is at the point yard[1][3] and Raoul is at the point yard[4][7] -- a distance of 5, so because the distance between these two points is smaller than the specified minimum distance of 6, there will be trouble, and your function should return False.
In this second example, Mustache Cat is at the point `yard[1][3]` and Raoul is at the point `yard[4][7]` -- a distance of 5, so because the distance between these two points is smaller than the specified minimum distance of 6, there will be trouble, and your function should return False.
```
["------------",
"---M--------",
Expand All @@ -37,7 +37,7 @@ In this second example, Mustache Cat is at the point yard[1][3] and Raoul is at
"-------R----",
"------------"], 6
```
In this third example, Lou is at yard[0][11], Raoul is at yard[1][2], and Mustache Cat at yard[5][2]. The distance between Lou and Raoul is 9.05538513814, the distance between Raoul and Mustache Cat is 4, and the distance between Mustache Cat and Lou is 10.295630141 -- all greater than or equal to the specified minimum distance of 4, so the three cats will nap peacefully, and your function should return True.
In this third example, Lou is at `yard[0][11]`, Raoul is at `yard[1][2]`, and Mustache Cat at `yard[5][2]`. The distance between Lou and Raoul is 9.05538513814, the distance between Raoul and Mustache Cat is 4, and the distance between Mustache Cat and Lou is 10.295630141 -- all greater than or equal to the specified minimum distance of 4, so the three cats will nap peacefully, and your function should return True.
```
["-----------L",
"--R---------",
Expand Down
2 changes: 1 addition & 1 deletion kata/6-kyu/change-case/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Change case](https://www.codewars.com/kata/change-case "https://www.codewars.com/kata/591cac98a6007e87d900013a")

In a word document, there is a button called Change case in Home tab where you can change the capitalization or case of selected text in a document.
In a Word document, there is a button called Change case in Home tab where you can change the capitalization or case of selected text in a document.

## Task

Expand Down
6 changes: 3 additions & 3 deletions kata/6-kyu/color-choice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ The formula to compute `m = n choose x` is: `m = n! / (x! * (n - x)!)`
where ! is the factorial operator.

You are a renowned poster designer and painter. You are asked to provide 6 posters
all having the same design each in 2 colors. Posters must all have a different color combination and you have the choice of 4 colors: red, blue, yellow, green.
all having the same design each in 2 colors. Posters must all have a different color combination, and you have the choice of 4 colors: red, blue, yellow, green.
How many colors can you choose for each poster?

The answer is two since `4 choose 2 = 6`. The combinations will be:
{red, blue}, {red, yellow}, {red, green}, {blue, yellow}, {blue, green}, {yellow, green}.

Now same question but you have 35 posters to provide and 7 colors available. How many colors for each poster?
Now same question, but you have 35 posters to provide and 7 colors available. How many colors for each poster?
If you take combinations `7 choose 2` you will get 21 with the above formula.
But 21 schemes aren't enough for 35 posters. If you take `7 choose 5` combinations you will get 21 too.
Fortunately if you take `7 choose 3` or `7 choose 4` combinations you get 35 and so each poster will have a different combination of
3 colors or 5 colors. You will take 3 colors because it's less expensive.

Hence the problem is:
Hence, the problem is:

knowing `m` (number of posters to design),
knowing `n` (total number of available colors),
Expand Down
18 changes: 9 additions & 9 deletions kata/6-kyu/financing-plan-on-planet-xy140z-n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ How much money would I have at the end of my financing plan on planet XY140Z-n?



-- |Su|Mo|Tu|We|Th|Fr|Sa|
--|--|--|--|--|--|--|--|
W6 | | | | | | |12|
W5 | | | | | |10|11|
W4 | | | | |8 |9 |10|
W3 | | | |6 |7 |8 |9 |
W2 | | |4 |5 |6 |7 |8 |
W1 | |2 |3 |4 |5 |6 |7 |
W0 |0 |1 |2 |3 |4 |5 |6 |
| -- | Su | Mo | Tu | We | Th | Fr | Sa |
|----|----|----|----|----|----|----|----|
| W6 | | | | | | | 12 |
| W5 | | | | | | 10 | 11 |
| W4 | | | | | 8 | 9 | 10 |
| W3 | | | | 6 | 7 | 8 | 9 |
| W2 | | | 4 | 5 | 6 | 7 | 8 |
| W1 | | 2 | 3 | 4 | 5 | 6 | 7 |
| W0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 |

## Example

Expand Down
2 changes: 1 addition & 1 deletion kata/6-kyu/fixme-hello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ When the same attribute is assigned multiple times the `hello` method shows it o
* `Hello. My name is Batman.`

## Task
Fix the code so we can all go home early.
Fix the code, so we can all go home early.
2 changes: 1 addition & 1 deletion kata/6-kyu/grill-it/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A grille cipher was a technique for encrypting a plaintext by writing it onto a
## Task

Write a function that accepts two inputs: `message` and `code` and returns hidden message decrypted from `message` using the `code`.
The `code` is a nonnegative integer and it decrypts in binary the `message`.
The `code` is a nonnegative integer, and it decrypts in binary the `message`.

```
grille("abcdef", 5) => "df"
Expand Down
2 changes: 1 addition & 1 deletion kata/6-kyu/grill-it/main/GrillIt.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
interface GrillIt {
static String grille(String msg, int code) {
return msg.length() > 0 ? grille(msg.substring(0, msg.length() - 1), code / 2) + (code % 2 > 0 ? msg.charAt(msg.length() - 1) : "") : "";
return !msg.isEmpty() ? grille(msg.substring(0, msg.length() - 1), code / 2) + (code % 2 > 0 ? msg.charAt(msg.length() - 1) : "") : "";
}
}
4 changes: 2 additions & 2 deletions kata/6-kyu/string-pyramid/main/Pyramid.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static String watchPyramidFromTheSide(String characters) {
.append(" ".repeat(i))
.append('\n');
}
return side.length() > 0 ? side.deleteCharAt(side.length() - 1).toString() : characters;
return !side.isEmpty() ? side.deleteCharAt(side.length() - 1).toString() : characters;
}

static String watchPyramidFromAbove(String characters) {
Expand All @@ -37,7 +37,7 @@ static String watchPyramidFromAbove(String characters) {
}
above.append("\n");
}
return above.length() > 0 ? above.deleteCharAt(above.length() - 1).toString() : characters;
return !above.isEmpty() ? above.deleteCharAt(above.length() - 1).toString() : characters;
}

static int countVisibleCharactersOfThePyramid(String characters) {
Expand Down
4 changes: 2 additions & 2 deletions kata/6-kyu/tank-truck/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# [Tank Truck](https://www.codewars.com/kata/tank-truck "https://www.codewars.com/kata/55f3da49e83ca1ddae0000ad")

To introduce the problem think to my neighbor who drives a tanker truck.
The level indicator is down and he is worried
The level indicator is down, and he is worried
because he does not know if he will be able to make deliveries.
We put the truck on a horizontal ground and measured the height of the liquid in the tank.

Expand All @@ -11,7 +11,7 @@ the total volume is `vt` (h, d, vt are positive or null integers).
You can assume that `h` <= `d`.

Could you calculate the remaining volume of the liquid?
Your function `tankvol(h, d, vt)` returns an integer which is the truncated result (e.g floor)
Your function `tankvol(h, d, vt)` returns an integer which is the truncated result (e.g. floor)
of your float calculation.

Examples:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ static String sendMessage(String message) {
low = !low;
}
var key = keymap[Character.toUpperCase(c) - ' '];
keys.append(keys.length() > 0 && keys.charAt(keys.length() - 1) == key.charAt(0) ? " " : "").append(key);
keys.append(!keys.isEmpty() && keys.charAt(keys.length() - 1) == key.charAt(0) ? " " : "").append(key);
}
return keys.toString();
}
}
}
2 changes: 1 addition & 1 deletion kata/6-kyu/two-sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Write a function that takes an array of numbers (integers for the tests) and a t

For the purposes of this kata, some tests may have multiple answers; any valid solutions will be accepted.

The input will always be valid (numbers will be an array of length 2 or greater, and all of the items will be numbers; target will always be the sum of two different items from that array).
The input will always be valid (numbers will be an array of length 2 or greater, and all the items will be numbers; target will always be the sum of two different items from that array).

```
twoSum([1, 2, 3], 4) == {0, 2}
Expand Down
8 changes: 4 additions & 4 deletions kata/6-kyu/up-and-down/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ The length of "after" is smaller than the length of "arrived". Let us move them
The length of "after" is greater than the length of "two" ->`"be arrived two after My so"`

The length of "after" is greater than the length of "My". Good!
Finally the length of "My" and "so" are the same, nothing to do.
Finally, the length of "My" and "so" are the same, nothing to do.
At the end of the process, the substrings s(i) verify:

`length s(0) <= length s(1) >= length s(2) <= length s(3) >= length (s4) <= length (s5)`

Hence given a string s of substrings `s(i)` the function `arrange` **with the previous process**
Hence, given a string s of substrings `s(i)` the function `arrange` **with the previous process**
should return a *unique* string `t` having the property (P).

It is kind of roller coaster or up and down.
When you have property (P), to make the result more "up and down" visible t(0), t(2), ...
will be lower cases and the others upper cases.
will be lowed cases and the others upper cases.

```
arrange("after be arrived two My so") should return "be ARRIVED two AFTER my SO"
Expand All @@ -44,7 +44,7 @@ arrange("after be arrived two My so") should return "be ARRIVED two AFTER my SO"
## Notes:

- The string `"My after be arrived so two"` has the property (P) but can't be obtained by
the **described process** so it won't be accepted as a result. The property (P)
the **described process,** so it won't be accepted as a result. The property (P)
doesn't give unicity by itself.
- Process: go from left to right, move only consecutive strings when needed.
- For the first fixed tests the needed number of moves to get property (P)
Expand Down
18 changes: 9 additions & 9 deletions kata/7-kyu/functions-of-integers-on-cartesian-plane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ where n is a given integer (n >= 1, guaranteed) and x, y are integers.

In the table below you can see the value of the function f with n = 6.

---|*0* |*1*|*2*|*3*|*4*|*5*|*6*|
-- |--|--|--|--|--|--|--|
*6*|- |1 |2 |3 |4 |5 |6 |
*5*|- |1 |2 |3 |4 |5 |5 |
*4*|- |1 |2 |3 |4 |4 |4 |
*3*|- |1 |2 |3 |3 |3 |3 |
*2*|- |1 |2 |2 |2 |2 |2 |
*1*|- |1 |1 |1 |1 |1 |1 |
*0*|- |- |- |- |- |- |- |
| --- | *0* | *1* | *2* | *3* | *4* | *5* | *6* |
|-----|-----|-----|-----|-----|-----|-----|-----|
| *6* | - | 1 | 2 | 3 | 4 | 5 | 6 |
| *5* | - | 1 | 2 | 3 | 4 | 5 | 5 |
| *4* | - | 1 | 2 | 3 | 4 | 4 | 4 |
| *3* | - | 1 | 2 | 3 | 3 | 3 | 3 |
| *2* | - | 1 | 2 | 2 | 2 | 2 | 2 |
| *1* | - | 1 | 1 | 1 | 1 | 1 | 1 |
| *0* | - | - | - | - | - | - | - |

The task is to calculate the sum of f(x, y), g(x, y) and h(x, y) for all integers x and y such that (1 <= x <= n, 1 <= y <= n).

Expand Down
2 changes: 1 addition & 1 deletion kata/7-kyu/mystery-colors/main/Color.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ enum Color {
PURPLE,
WHITE,
BLACK
}
}
4 changes: 2 additions & 2 deletions kata/7-kyu/mystery-colors/main/MysteryColorAnalyzer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.util.List;

public interface MysteryColorAnalyzer {
interface MysteryColorAnalyzer {
/**
* This method will determine how many distinct colors are in the given list
*
Expand All @@ -21,4 +21,4 @@ public interface MysteryColorAnalyzer {
* @return number of occurrence of the color in the list
*/
int colorOccurrence(List<Color> mysteryColors, Color color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public int numberOfDistinctColors(List<Color> mysteryColors) {
public int colorOccurrence(List<Color> mysteryColors, Color color) {
return (int) mysteryColors.stream().filter(color::equals).count();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ void duplicateColors() {
assertEquals(0, analyzer.colorOccurrence(duplicate, Color.WHITE));
assertEquals(1, analyzer.colorOccurrence(duplicate, Color.BLACK));
}
}
}
4 changes: 2 additions & 2 deletions kata/7-kyu/replace-every-nth/main/Kata.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ static String replaceNth(String text, int n, char oldValue, char newValue) {
for (int i = 0; n > 0 && i < text.length(); i++) {
result.append(text.charAt(i) == oldValue && ++c % n == 0 ? newValue : text.charAt(i));
}
return result.length() > 0 ? result.toString() : text;
return !result.isEmpty() ? result.toString() : text;
}
}
}
2 changes: 1 addition & 1 deletion kata/8-kyu/did-she-say-hallo/test/SolutionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void sample() {
assertTrue(Kata.validateHello("salut"));
assertTrue(Kata.validateHello("hallo, salut"));
assertTrue(Kata.validateHello("hombre! Hola!"));
assertTrue(Kata.validateHello("Hallo, wie geht\'s dir?"));
assertTrue(Kata.validateHello("Hallo, wie geht's dir?"));
assertTrue(Kata.validateHello("AHOJ!"));
assertTrue(Kata.validateHello("czesc"));
assertTrue(Kata.validateHello("Ahoj"));
Expand Down
6 changes: 3 additions & 3 deletions kata/8-kyu/quadrants/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# [Quadrants](https://www.codewars.com/kata/quadrants "https://www.codewars.com/kata/643af0fa9fa6c406b47c5399")

# Task
Given a point in a [Euclidean plane](//en.wikipedia.org/wiki/Euclidean_plane) (`x` and `y`), return the quadrant the point exists in: `1`, `2`, `3` or `4` (integer). `x` and `y` are non-zero integers, therefore the given point never lies on the axes.
Given a point in a [Euclidean plane](https://en.wikipedia.org/wiki/Euclidean_plane) (`x` and `y`), return the quadrant the point exists in: `1`, `2`, `3` or `4` (integer). `x` and `y` are non-zero integers, therefore the given point never lies on the axes.

# Examples
```
Expand All @@ -12,10 +12,10 @@ Given a point in a [Euclidean plane](//en.wikipedia.org/wiki/Euclidean_plane) (`
(19, -56) => 4
```
# Reference
<center>
<div style="text-align: center;">
<img style="background:white" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Cartesian_coordinates_2D.svg/300px-Cartesian_coordinates_2D.svg.png" title="Quadrants">
<i>Quadrants</i>
</center>
</div>

There are four quadrants:
1. First quadrant, the quadrant in the top-right, contains all points with positive X and Y
Expand Down
2 changes: 1 addition & 1 deletion kata/beta/beginner-friendly-remove-the-letter-o/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Beginner friendly: remove the letter o](https://www.codewars.com/kata/beginner-friendly-remove-the-letter-o "https://www.codewars.com/kata/58d3dd53b0fe8c9ac10000b3")

Create a function `removeO` to remove all of the letters `o` in a string.
Create a function `removeO` to remove all the letters `o` in a string.

There's no need to worry about uppercase letters.

Expand Down
6 changes: 3 additions & 3 deletions kata/beta/brackets-checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

The greatest enemy of all programmers is ";".
Very often we forgot about this symbol.
Also we can forgot about closing brackets (If we don't use IDE that closes brackets for us).
Also, we can forget about closing brackets (If we don't use IDE that closes brackets for us).

Task: to make a method wich will checks if the brackets "(","{","[" have a couple ")","}","].
Task: to make a method which will check if the brackets "(","{","[" have a couple ")","}","]".

For example: "(hello evrybody)" -> true;
For example: "(hello everybody)" -> true;

"} - bracket" -> false;

Expand Down
2 changes: 1 addition & 1 deletion kata/beta/change-for-pizza/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

My friend Sergio visits a pizzeria every Tuesday and buys a pizza. Sergio always gives a 200 hryvnias banknote, but the pizza's price is always less than 200 hryvnias.

The prices sometimes changes and the pizzeria needs a special program to calculate the amount of money they need to return. The pizzeria's owner studied qbasic in college so he wrote javascript as qbasic. Please, help him and fix a function that calculates the change for pizza.
The prices sometimes changes and the pizzeria needs a special program to calculate the amount of money they need to return. The pizzeria's owner studied qbasic in college, so he wrote javascript as qbasic. Please, help him and fix a function that calculates the change for pizza.
2 changes: 1 addition & 1 deletion kata/beta/check-the-tire-pressure/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Check the tire pressure](https://www.codewars.com/kata/check-the-tire-pressure "https://www.codewars.com/kata/56e1bae4f693fe1f8e000cd8")

Yesterday when you drove on motorway your wheel came off. You barely survived. After that you decided to buy a new wheel and it already had a tire on it. So now you need to check pressure on the tire.
Yesterday when you drove on motorway your wheel came off. You barely survived. After that you decided to buy a new wheel, and it already had a tire on it. So now you need to check pressure on the tire.

The optimal pressure is 220; Anything below it or above it is either too low or too high.

Expand Down
2 changes: 1 addition & 1 deletion kata/beta/count-the-likes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Kata.evalLikes(new String[] {"THIS", "IS", "LIKE", "TERRIBLE"}) // ==> true;
Kata.evalLikes(new String[] {"likely", "story"}) // ==> false;
```

Your solution must be case-insensitive but you do not need to worry about punctuation (the device you have been fitted with automatically filters this out).
Your solution must be case-insensitive, but you do not need to worry about punctuation (the device you have been fitted with automatically filters this out).
2 changes: 1 addition & 1 deletion kata/beta/flip-it/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Flip it](https://www.codewars.com/kata/flip-it "https://www.codewars.com/kata/56576f15a00ccb1c8f000088")

Welcome! To the world of robots.
You need to create your own simple robot and make your robot tell you the reverse of every word you tell to the robot.Eg. If you say "hello" to your robot, your robot will say "olleh". That's it! Simple
You need to create your own simple robot and make your robot tell you the reverse of every word you tell to the robot. E.g. If you say "hello" to your robot, your robot will say "olleh". That's it! Simple
2 changes: 1 addition & 1 deletion kata/beta/letter-to-ascii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This kata is very simple.

You will be given a character and you will convert it to its corresponding number.
You will be given a character, and you will convert it to its corresponding number.

Ex. 'a' = 97

Expand Down
2 changes: 1 addition & 1 deletion kata/beta/mode-count/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

In statistic is known the term mode. The mode of a set of data values is the value that appears most often. For example suppose the set of data values are {1,2,2,3}. There are three number inside the data set: 1, 2, and 3. Number 1 appears once, 2 appears twice, and 3 appears once. That mean number 2 appears most often so the mode is 2.

Sometime we can find that the most often more than one number here the example
Sometimes we can find that the most often more than one number here the example
```
Data set = {2,2,2,3,3,3,4,5,6}
Mode result = {2,3}
Expand Down
2 changes: 1 addition & 1 deletion kata/beta/range-merging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*range*: an integer range denoted by [a, b], with a and b both included.

**Challenge**
Given a **list/array** of even length, whose each pair of number is representing a range, return a sorted list of ranges in the same format, with all overlapping or contiguous ranges **merged**.
Given a **list/array** of even length, where each pair of number is representing a range, return a sorted list of ranges in the same format, with all overlapping or contiguous ranges **merged**.

**Examples**

Expand Down
Loading

0 comments on commit 03cad08

Please sign in to comment.