Skip to content

Commit a653766

Browse files
* docs: kata description * feat: kata/substituting-variables-into-strings-padded-numbers --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
1 parent 4c46a7f commit a653766

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

kata/7-kyu/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@
375375
- [Overflowing with joy](overflowing-with-joy "55186c0f4149dd08a7000006")
376376
- [Page replacement algorithms: FIFO](page-replacement-algorithms-fifo "62d34faad32b8c002a17d6d9")
377377
- [Palindrome chain length](palindrome-chain-length "525f039017c7cd0e1a000a26")
378-
- [Pandemia 🌡️](pandemia "# [Pandemia 🌡5e2596a9ad937f002e510435")
378+
- [Pandemia 🌡️](pandemia "5e2596a9ad937f002e510435")
379379
- [Parallel resistors](parallel-resistors "5723b111101f5f905f0000a5")
380380
- [Partial Word Searching](partial-word-searching "54b81566cd7f51408300022d")
381381
- [Parts of a list](parts-of-a-list "56f3a1e899b386da78000732")
@@ -513,6 +513,7 @@
513513
- [String prefix and suffix](string-prefix-and-suffix "5ce969ab07d4b7002dcaa7a1")
514514
- [Strong Number (Special Numbers Series #2)](strong-number-special-numbers-series-number-2 "5a4d303f880385399b000001")
515515
- [Subcuboids](subcuboids "5b9e29dc1d5ed219910000a7")
516+
- [Substituting Variables Into Strings: Padded Numbers](substituting-variables-into-strings-padded-numbers "51c89385ee245d7ddf000001")
516517
- [Substring fun](substring-fun "565b112d09c1adfdd500019c")
517518
- [Suitcase packing](suitcase-packing "5c556845d7e0334c74698706")
518519
- [Sum a list but ignore any duplicates](sum-a-list-but-ignore-any-duplicates "5993fb6c4f5d9f770c0000f2")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# [Substituting Variables Into Strings: Padded Numbers](https://www.codewars.com/kata/substituting-variables-into-strings-padded-numbers "https://www.codewars.com/kata/51c89385ee245d7ddf000001")
2+
3+
Complete the solution so that it returns a formatted string. The return value should equal "Value is VALUE" where value is a 5 digit padded
4+
number.
5+
6+
Example:
7+
8+
```
9+
solution(5); // should return "Value is 00005"
10+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Kata {
2+
static String solution(int value) {
3+
return String.format("Value is %05d", value);
4+
}
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 Tests {
7+
@ParameterizedTest
8+
@CsvSource(textBlock = """
9+
0, Value is 00000
10+
5, Value is 00005
11+
109, Value is 00109
12+
1204, Value is 01204
13+
""")
14+
void sample(int n, String expected) {
15+
assertEquals(expected, Kata.solution(n));
16+
}
17+
}

0 commit comments

Comments
 (0)