Skip to content

Commit 88bc5f1

Browse files
* docs: kata description * docs: sync progress * feat: kata/build-alien-virus-estimator --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
1 parent f084ace commit 88bc5f1

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 | 439 | 600 | 224 | 55 | 82 |
28+
| 0 | 1 | 2 | 26 | 48 | 439 | 600 | 224 | 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.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# [Build Alien Virus Estimator](https://www.codewars.com/kata/build-alien-virus-estimator "https://www.codewars.com/kata/675851e0ebd55559d1082d24")
2+
3+
A deadly alien virus has escaped from a remote swamp lab, where it was first analyzed. You have to determine their count, so that further
4+
action can be taken. The only catch is that they multiply rapidly.
5+
6+
The crazed professor can only tell you 3 things:
7+
8+
- How many units have escaped
9+
- By how much they increase every minute
10+
- How many minutes have passed
11+
12+
You have to return the # of virus units out there. If the # of units is not deterministic, return -1.
13+
14+
Note: The virus count have been referred to as "units".
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface AlienVirusEstimator {
2+
static long findVirusUnits(long unitsEscaped, long increasePerMinute, long minutesPassed) {
3+
return Math.max(--minutesPassed * increasePerMinute + unitsEscaped, -1);
4+
}
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import static org.junit.jupiter.api.Assertions.assertEquals;
2+
3+
import org.junit.jupiter.params.ParameterizedTest;
4+
import org.junit.jupiter.params.provider.CsvSource;
5+
6+
class AlienVirusEstimatorTest {
7+
@ParameterizedTest
8+
@CsvSource(textBlock = """
9+
2, 4, 3, 10
10+
4, 2, 10, 22
11+
7, -5, 8, -1
12+
""")
13+
void sample(long escaped, long spread, long minutes, long units) {
14+
assertEquals(units, AlienVirusEstimator.findVirusUnits(escaped, spread, minutes));
15+
}
16+
}

kata/beta/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [Basic Arabic-To-Roman Numerals (1 to 999)](basic-arabic-to-roman-numerals-1-to-999)
77
- [Beginner friendly: remove the letter o](beginner-friendly-remove-the-letter-o)
88
- [Brackets Checker](brackets-checker)
9+
- [Build Alien Virus Estimator](build-alien-virus-estimator)
910
# C
1011
- [CaMeLcAsInG](camelcasing)
1112
- [Change for pizza](change-for-pizza)

0 commit comments

Comments
 (0)