Skip to content

Commit 9349762

Browse files
committed
added reverse string exercise to track
1 parent a49222a commit 9349762

8 files changed

Lines changed: 97 additions & 0 deletions

File tree

‎config.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
"unlocked_by": null,
1313
"uuid": "f77dc7e3-35a8-4300-a7c8-2c1765e9644d"
1414
},
15+
{
16+
"core": false,
17+
"difficulty": 1,
18+
"slug": "reverse-string",
19+
"topics": [
20+
"strings"
21+
],
22+
"unlocked_by": null,
23+
"uuid": "2c8afeed-480e-41f3-ad58-590fa8f88029"
24+
},
1525
{
1626
"core": true,
1727
"difficulty": 1,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ReverseString {
2+
3+
String reverse(String inputString) {
4+
return new StringBuffer(inputString).reverse().toString();
5+
}
6+
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.1

‎exercises/reverse-string/README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Reverse String
2+
3+
For example: input: "cool" output: "looc"
4+
5+
# Running the tests
6+
7+
You can run all the tests for an exercise by entering
8+
9+
```sh
10+
$ gradle test
11+
```
12+
13+
in your terminal.
14+
15+
## Submitting Incomplete Solutions
16+
17+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apply plugin: "java"
2+
apply plugin: "eclipse"
3+
apply plugin: "idea"
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
testCompile "junit:junit:4.12"
11+
}
12+
test {
13+
testLogging {
14+
exceptionFormat = 'full'
15+
events = ["passed", "failed", "skipped"]
16+
}
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ReverseString {
2+
3+
String reverse() {
4+
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5+
}
6+
7+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import org.junit.Ignore;
2+
import org.junit.Test;
3+
4+
import static org.junit.Assert.assertEquals;
5+
6+
public class ReverseStringTest {
7+
8+
@Test
9+
public void testAnEmptyString() {
10+
assertEquals("", new ReverseString().reverse(""));
11+
}
12+
13+
@Ignore("Remove to run test")
14+
@Test
15+
public void testAWord() {
16+
assertEquals("tobor", new ReverseString().reverse("robot"));
17+
}
18+
19+
@Ignore("Remove to run test")
20+
@Test
21+
public void testACapitalizedWord() {
22+
assertEquals("nemaR", new ReverseString().reverse("Ramen"));
23+
}
24+
25+
@Ignore("Remove to run test")
26+
@Test
27+
public void testASentenceWithPunctuation() {
28+
assertEquals("!yrgnuh m'I", new ReverseString().reverse("I'm hungry!"));
29+
}
30+
31+
@Ignore("Remove to run test")
32+
@Test
33+
public void testAPalindrome() {
34+
assertEquals("racecar", new ReverseString().reverse("racecar"));
35+
}
36+
37+
}

‎exercises/settings.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ include 'pythagorean-triplet'
5959
include 'queen-attack'
6060
include 'raindrops'
6161
include 'rectangles'
62+
include 'reverse-string'
6263
include 'rna-transcription'
6364
include 'robot-name'
6465
include 'robot-simulator'

0 commit comments

Comments
 (0)