Skip to content

Commit 0a4c043

Browse files
authored
Merge branch 'main' into kata/57db78d3b43dfab59c001abe
Signed-off-by: Capt. Cutlass <5120290+ParanoidUser@users.noreply.github.com>
2 parents 11f6153 + eb4961e commit 0a4c043

File tree

25 files changed

+287
-18
lines changed

25 files changed

+287
-18
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ jobs:
5252
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5353

5454
- name: Setup Java
55-
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
55+
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
5656
with:
5757
distribution: temurin
5858
java-version: 17
5959

6060
- name: Setup Gradle
61-
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4
61+
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4
6262

6363
- name: Test project
6464
run: |
@@ -68,6 +68,7 @@ jobs:
6868
--build-cache \
6969
--no-daemon \
7070
--scan \
71+
--no-problems-report \
7172
-DforkCount=${{ needs.fork.outputs.job_count }} \
7273
-DforkSid=${{ matrix.job_sid }}
7374
@@ -77,7 +78,7 @@ jobs:
7778
tar czfT artifacts.tar.gz artifacts
7879
7980
- name: Upload fork artifacts
80-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
81+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
8182
with:
8283
name: fork-${{ matrix.job_sid }}
8384
retention-days: 1
@@ -106,13 +107,13 @@ jobs:
106107
run: for f in fork-*/artifacts.tar.gz; do tar xf $f && rm $f; done
107108

108109
- name: Setup Java
109-
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
110+
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
110111
with:
111112
distribution: temurin
112113
java-version: 17
113114

114115
- name: Setup Gradle
115-
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4
116+
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4
116117
with:
117118
add-job-summary-as-pr-comment: always
118119

@@ -124,6 +125,7 @@ jobs:
124125
--build-cache \
125126
--no-daemon \
126127
--scan \
128+
--no-problems-report \
127129
-Pversion=${{ format('{0}+{1}', env.VERSION, github.RUN_NUMBER) }} \
128130
-Dsonar.host.url=https://sonarcloud.io \
129131
-Dsonar.token=${{ secrets.SONAR_TOKEN }} \

.github/workflows/update-gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Fetch wrapper version
2121
run: |
2222
URL=$(grep 'distributionUrl' "./gradle/wrapper/gradle-wrapper.properties")
23-
echo "WRAPPER_VERSION=$(echo $URL | sed -n 's/.*gradle-\([0-9]*\.[0-9]*\)-\(bin\|all\)\.zip.*/\1/p')" >> $GITHUB_ENV
23+
echo "WRAPPER_VERSION=$(echo $URL | sed -n 's/.*gradle-\([0-9]*\.[0-9]*\(\.[0-9]*\)*\)-\(bin\|all\)\.zip.*/\1/p')" >> $GITHUB_ENV
2424
2525
- name: Fetch latest version
2626
run: |

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Codewars Handbook ☕️🚀
22

33
[![Views statistics +1 👀](https://img.shields.io/badge/dynamic/xml?color=success&label=views&query=//*[name()=%27text%27][3]&url=https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FParanoidUser%2Fcodewars-handbook)](https://hits.seeyoufarm.com/api/count/graph/dailyhits.svg?url=https://github.com/ParanoidUser/codewars-handbook)
4-
[![Completed kata 👌](https://img.shields.io/badge/completed%20kata-69.0%25-red.svg)](https://www.codewars.com/kata/search/java?xids=completed)
4+
[![Completed kata 👌](https://img.shields.io/badge/completed%20kata-69.2%25-red.svg)](https://www.codewars.com/kata/search/java?xids=completed)
55
[![CI pipeline 🛠](https://img.shields.io/github/actions/workflow/status/ParanoidUser/codewars-handbook/build.yml?branch=main)](https://github.com/ParanoidUser/codewars-handbook/actions/workflows/build.yml)
66
[![Quality gate 🔎](https://img.shields.io/sonar/alert_status/codewars-handbook?server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=codewars-handbook)
77
[![Let's have a chat! 📞](https://img.shields.io/gitter/room/ParanoidUser/codewars-handbook?color=49c39e)](https://gitter.im/ParanoidUser/codewars-handbook)
@@ -25,7 +25,7 @@ slug.
2525

2626
| [1 kyu](/kata/1-kyu/index.md) | [2 kyu](/kata/2-kyu/index.md) | [3 kyu](/kata/3-kyu/index.md) | [4 kyu](/kata/4-kyu/index.md) | [5 kyu](/kata/5-kyu/index.md) | [6 kyu](/kata/6-kyu/index.md) | [7 kyu](/kata/7-kyu/index.md) | [8 kyu](/kata/8-kyu/index.md) | [beta](/kata/beta/index.md) | [retired](/kata/retired/index.md) |
2727
|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:---------------------------:|:---------------------------------:|
28-
| 0 | 1 | 2 | 26 | 48 | 440 | 600 | 224 | 56 | 82 |
28+
| 0 | 1 | 2 | 26 | 48 | 440 | 603 | 226 | 56 | 82 |
2929

3030
**Note:** The source code is written in Java 17 and may use language features that are incompatible
3131
with Java 8, 11.

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
# https://docs.gradle.org/current/userguide/build_environment.html
33
# Specifies the JVM arguments used for the daemon process.
44
# The setting is particularly useful for tweaking memory settings.
5-
org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
5+
org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
6+
org.gradle.configuration-cache.parallel=true

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
commons-lang3 = "3.17.0"
33
lombok = "1.18.36"
44
mockito = "5.2.0"
5-
junit = "5.11.3"
6-
junit-launcher = "1.11.3"
5+
junit = "5.11.4"
6+
junit-launcher = "1.11.4"
77
awaitility = "4.2.2"
88
sonarqube = "6.0.1.5171"
99

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
21
import static org.junit.jupiter.api.Assertions.assertEquals;
32

43
import java.time.LocalDate;
5-
import java.time.Year;
64
import org.junit.jupiter.api.Test;
75

86
class KataTest {
@@ -11,7 +9,9 @@ void sample() {
119
var birthday = LocalDate.now();
1210
assertEquals("You are 2 days old", Kata.ageInDays(birthday.minusDays(2).getYear(), birthday.minusDays(2).getMonthValue(), birthday.minusDays(2).getDayOfMonth()));
1311

14-
String expected = String.format("You are %d days old", Year.of(birthday.getYear()).length());
15-
assertEquals(expected, Kata.ageInDays(birthday.minusYears(1).getYear(), birthday.minusYears(1).getMonthValue(), birthday.minusYears(1).getDayOfMonth()));
12+
var pastYear = birthday.minusYears(1);
13+
boolean leapDay = birthday.getMonthValue() > 2 && birthday.isLeapYear() || birthday.getMonthValue() < 3 && pastYear.isLeapYear();
14+
String expected = String.format("You are %d days old", leapDay ? 366 : 365);
15+
assertEquals(expected, Kata.ageInDays(pastYear.getYear(), pastYear.getMonthValue(), pastYear.getDayOfMonth()));
1616
}
17-
}
17+
}

kata/7-kyu/fizz-buzz/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# [Fizz Buzz](https://www.codewars.com/kata/fizz-buzz "https://www.codewars.com/kata/5300901726d12b80e8000498")
2+
3+
Return an array containing the numbers from 1 to N, where N is the parameter value.
4+
5+
Replace certain values however if any of the following conditions are met:
6+
7+
* If the value is a multiple of 3: use the value "Fizz" instead
8+
* If the value is a multiple of 5: use the value "Buzz" instead
9+
* If the value is a multiple of 3 & 5: use the value "FizzBuzz" instead
10+
11+
N will never be less than 1.
12+
13+
Method calling example:
14+
15+
```
16+
FizzBuzzArray.fizzBuzz(3) --> ["1", "2", "Fizz"]
17+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import static java.util.stream.IntStream.rangeClosed;
2+
3+
interface FizzBuzzArray {
4+
static String[] fizzBuzz(int n) {
5+
return rangeClosed(1, n).mapToObj(i -> i % 15 < 1 ? "FizzBuzz" : i % 3 < 1 ? "Fizz" : i % 5 < 1 ? "Buzz" : i + "").toArray(String[]::new);
6+
}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import org.junit.jupiter.api.Test;
2+
3+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
4+
5+
class FizzBuzzArrayTest {
6+
@Test
7+
void sample() {
8+
assertArrayEquals(new String[]{"1"}, FizzBuzzArray.fizzBuzz(1));
9+
assertArrayEquals(new String[]{"1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"},
10+
FizzBuzzArray.fizzBuzz(15));
11+
}
12+
}

0 commit comments

Comments
 (0)