Skip to content

Commit 8a6d24a

Browse files
committed
Add reverse-string
1 parent 09e701e commit 8a6d24a

File tree

7 files changed

+103
-0
lines changed

7 files changed

+103
-0
lines changed

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@
8282
"practices": [],
8383
"prerequisites": [],
8484
"difficulty": 2
85+
},
86+
{
87+
"slug": "reverse-string",
88+
"name": "Reverse String",
89+
"uuid": "963aeaed-a2d5-40e5-8f04-f17f404b5304",
90+
"practices": [],
91+
"prerequisites": [],
92+
"difficulty": 2
8593
}
8694
]
8795
},
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Instructions
2+
3+
Reverse a string
4+
5+
For example:
6+
input: "cool"
7+
output: "looc"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"authors": [
3+
"BNAndras"
4+
],
5+
"files": {
6+
"solution": [
7+
"reverse_string.gd"
8+
],
9+
"test": [
10+
"reverse_string_test.gd"
11+
],
12+
"example": [
13+
".meta/example.gd"
14+
]
15+
},
16+
"blurb": "Reverse a string.",
17+
"source": "Introductory challenge to reverse an input string",
18+
"source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb"
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
func reverse(str):
2+
var result = ""
3+
for i in range(str.length() - 1, -1, -1):
4+
result += str[i]
5+
return result
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[c3b7d806-dced-49ee-8543-933fd1719b1c]
13+
description = "an empty string"
14+
15+
[01ebf55b-bebb-414e-9dec-06f7bb0bee3c]
16+
description = "a word"
17+
18+
[0f7c07e4-efd1-4aaa-a07a-90b49ce0b746]
19+
description = "a capitalized word"
20+
21+
[71854b9c-f200-4469-9f5c-1e8e5eff5614]
22+
description = "a sentence with punctuation"
23+
24+
[1f8ed2f3-56f3-459b-8f3e-6d8d654a1f6c]
25+
description = "a palindrome"
26+
27+
[b9e7dec1-c6df-40bd-9fa3-cd7ded010c4c]
28+
description = "an even-sized word"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
func reverse(str):
2+
pass
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
func test_empty_string(solution_script):
2+
var str = ""
3+
var expected = ""
4+
return [expected, solution_script.reverse(str)]
5+
6+
7+
func test_a_word(solution_script):
8+
var str = "robot"
9+
var expected = "tobor"
10+
return [expected, solution_script.reverse(str)]
11+
12+
13+
func test_a_capitalized_word(solution_script):
14+
var str = "Ramen"
15+
var expected = "nemaR"
16+
return [expected, solution_script.reverse(str)]
17+
18+
19+
func test_a_sentence_with_punctuation(solution_script):
20+
var str = "I'm hungry!"
21+
var expected = "!yrgnuh m'I"
22+
return [expected, solution_script.reverse(str)]
23+
24+
25+
func test_a_palindrome(solution_script):
26+
var str = "racecar"
27+
var expected = "racecar"
28+
return [expected, solution_script.reverse(str)]
29+
30+
31+
func test_an_even_sized_word(solution_script):
32+
var str = "drawer"
33+
var expected = "reward"
34+
return [expected, solution_script.reverse(str)]

0 commit comments

Comments
 (0)