A letter for a diamond!
Given a single letter, print a diamond starting with 'A' with the supplied letter at the widest point. This kata like many others is intended to be solved by applying Test-Driven Development (TDD).
Example for 'A':
A
Example for 'B':
A B B A
Example for 'C':
A B B C C B B A
Use my Diamond program in command line as following.
mvn clean package -Pstandalone # to build it once
java -jar target/diamond-kata-0.1.0-SNAPSHOT-shaded.jar F # to run it as many times as you want
You will get this result.
A B B C C D D E E F F E E D D C C B B A
My Diamond program works for uppercase letters as for lowercase letters. For example, the diamond printed for 'c':
a b b c c b b a
Also use it as a Java library with Maven.
<dependency>
<groupId>com.github.xapn</groupId>
<artifactId>diamond-kata</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
And get any diamond you want like that.
import diamond.Diamond;
class Example {
public static void main(String[] args) {
String diamond = Diamond.of("X");
}
}
The Diamond program is distributed under the GNU GPLv3 license. The GPLv3 license is included in the LICENSE.txt file. More information about this license is available at GNU.org.