Skip to content

Commit 5238091

Browse files
authored
Add reverse-string exercise (#498)
1 parent dab8f7f commit 5238091

File tree

13 files changed

+133
-0
lines changed

13 files changed

+133
-0
lines changed

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@
114114
"difficulty": 2,
115115
"topics": null
116116
},
117+
{
118+
"slug": "reverse-string",
119+
"name": "Reverse String",
120+
"uuid": "58c93fbe-5c57-41d0-9085-6007a488aaca",
121+
"practices": [],
122+
"prerequisites": [],
123+
"difficulty": 2
124+
},
117125
{
118126
"slug": "rna-transcription",
119127
"name": "RNA Transcription",
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.ml"
8+
],
9+
"test": [
10+
"test.ml"
11+
],
12+
"example": [
13+
".meta/example.ml"
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let reverse_string str =
2+
let len = String.length str in
3+
String.init len (fun i -> str.[len - 1 - i])
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
default: clean test
2+
3+
test:
4+
dune runtest
5+
6+
clean:
7+
dune clean
8+
9+
.PHONY: clean
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(executable
2+
(name test)
3+
(libraries base ounit2))
4+
5+
(alias
6+
(name runtest)
7+
(deps (:x test.exe))
8+
(action (run %{x})))
9+
10+
(alias
11+
(name buildtest)
12+
(deps (:x test.exe)))
13+
14+
(env
15+
(dev
16+
(flags (:standard -warn-error -A))))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(lang dune 1.1)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let reverse_string _ =
2+
failwith "'reverse_string' is missing"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
val reverse_string : string -> string

0 commit comments

Comments
 (0)