-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: kata description * docs: sync progress * feat: kata/c-is-for-codewars --------- Co-authored-by: ParanoidUser <5120290+ParanoidUser@users.noreply.github.com>
- Loading branch information
1 parent
163b5ce
commit 73f155a
Showing
5 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# [C is for Codewars](https://www.codewars.com/kata/c-is-for-codewars "https://www.codewars.com/kata/675dc1d3830826975c58a09d") | ||
|
||
#### Task: | ||
|
||
Build a string representing a capital letter C of a given size out of 'C' characters. | ||
|
||
#### Examples: | ||
|
||
`generate_C(1)` should return this string: | ||
|
||
``` | ||
CCCCC | ||
C | ||
C | ||
C | ||
CCCCC | ||
``` | ||
|
||
`generate_C(2)` should be | ||
|
||
``` | ||
CCCCCCCCCC | ||
CCCCCCCCCC | ||
CC | ||
CC | ||
CC | ||
CC | ||
CC | ||
CC | ||
CCCCCCCCCC | ||
CCCCCCCCCC | ||
``` | ||
|
||
and so on. The string returned by `generate_C(size)` should have `5*size` lines, following the format above. <code>size</code> is a positive | ||
integer <code>≤ 2000.</code> | ||
|
||
Note that extra spaces after the C's in any line are incorrect. And the last line should not terminate with "\n". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import static java.util.stream.Collectors.joining; | ||
import static java.util.stream.IntStream.range; | ||
|
||
interface GenerateC { | ||
static String generateC(int size) { | ||
return range(0, 5 * size).mapToObj(r -> "C".repeat(size * (r < size || r > 4 * size - 1 ? 5 : 1))).collect(joining("\n")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class SolutionTest { | ||
@Test | ||
void sample() { | ||
assertEquals(""" | ||
CCCCC | ||
C | ||
C | ||
C | ||
CCCCC""", GenerateC.generateC(1)); | ||
|
||
assertEquals(""" | ||
CCCCCCCCCC | ||
CCCCCCCCCC | ||
CC | ||
CC | ||
CC | ||
CC | ||
CC | ||
CC | ||
CCCCCCCCCC | ||
CCCCCCCCCC""", GenerateC.generateC(2) | ||
); | ||
|
||
assertEquals(""" | ||
CCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCC | ||
CCC | ||
CCC | ||
CCC | ||
CCC | ||
CCC | ||
CCC | ||
CCC | ||
CCC | ||
CCC | ||
CCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCC""", GenerateC.generateC(3) | ||
); | ||
|
||
assertEquals(""" | ||
CCCCCCCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCCCCCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCC | ||
CCCCCCCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCCCCCCC | ||
CCCCCCCCCCCCCCCCCCCC""", GenerateC.generateC(4) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters