Skip to content

Commit 01a866e

Browse files
authored
Add matching brackets exercise (#113)
1 parent ba40d7c commit 01a866e

File tree

15 files changed

+9647
-55
lines changed

15 files changed

+9647
-55
lines changed

config.json

Lines changed: 90 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@
1515
"indent_size": 2,
1616
"highlightjs_language": "wasm"
1717
},
18-
"files": {
19-
"solution": [],
20-
"test": [],
21-
"example": [],
22-
"exemplar": []
23-
},
2418
"test_runner": {
2519
"average_run_time": 16
2620
},
21+
"files": {
22+
"solution": [
23+
"%{kebab_slug}.wat"
24+
],
25+
"test": [
26+
"%{kebab_slug}.spec.js"
27+
],
28+
"example": [
29+
".meta/proof.ci.wat"
30+
]
31+
},
2732
"exercises": {
28-
"concept": [],
2933
"practice": [
3034
{
3135
"slug": "darts",
@@ -34,223 +38,254 @@
3438
"practices": [],
3539
"prerequisites": [],
3640
"difficulty": 3
37-
}, {
41+
},
42+
{
3843
"slug": "hello-world",
3944
"name": "Hello World",
4045
"uuid": "8eae71ff-c56c-4f1c-affa-47c88fadfab8",
4146
"practices": [],
4247
"prerequisites": [],
4348
"difficulty": 1
44-
}, {
49+
},
50+
{
4551
"slug": "collatz-conjecture",
4652
"name": "Collatz Conjecture",
4753
"uuid": "84a5d81b-f410-42d8-a7a1-d740d3957830",
4854
"practices": [],
4955
"prerequisites": [],
5056
"difficulty": 3
51-
}, {
57+
},
58+
{
5259
"slug": "square-root",
5360
"name": "Square Root",
5461
"uuid": "fe3e2504-d952-4295-a3f8-c61c61621f98",
5562
"practices": [],
5663
"prerequisites": [],
5764
"difficulty": 4
58-
}, {
65+
},
66+
{
5967
"slug": "grains",
6068
"name": "Grains",
6169
"uuid": "67d810e3-1784-43f2-a56f-64ab496cb42f",
6270
"practices": [],
6371
"prerequisites": [],
6472
"difficulty": 5
65-
}, {
73+
},
74+
{
6675
"slug": "difference-of-squares",
6776
"name": "Difference of Squares",
6877
"uuid": "943f4eee-a1c6-4011-a014-515be8b1dc65",
6978
"practices": [],
7079
"prerequisites": [],
7180
"difficulty": 3
72-
}, {
81+
},
82+
{
7383
"slug": "leap",
7484
"name": "Leap",
7585
"uuid": "d0573ad4-ef4d-42bf-97b8-268e2377feb4",
7686
"practices": [],
7787
"prerequisites": [],
7888
"difficulty": 1
79-
}, {
89+
},
90+
{
8091
"slug": "resistor-color",
8192
"name": "Resistor Color",
8293
"uuid": "0751e431-d3a7-44bc-8718-4bc10baec4ca",
8394
"practices": [],
8495
"prerequisites": [],
8596
"difficulty": 4
86-
}, {
97+
},
98+
{
8799
"slug": "reverse-string",
88100
"name": "Reverse String",
89101
"uuid": "1ea9b20b-6a9d-43b2-b781-1206744ca4c1",
90102
"practices": [],
91103
"prerequisites": [],
92104
"difficulty": 2
93-
}, {
105+
},
106+
{
94107
"slug": "two-fer",
95108
"name": "Two Fer",
96109
"uuid": "f1d7f95e-e8c1-464a-99ab-c5a1395cb9a4",
97110
"practices": [],
98111
"prerequisites": [],
99112
"difficulty": 1
100-
}, {
113+
},
114+
{
101115
"slug": "bank-account",
102116
"name": "Bank Account",
103117
"uuid": "c8f71259-13b0-4e89-acf1-4cfe16b31718",
104118
"practices": [],
105119
"prerequisites": [],
106120
"difficulty": 1
107-
}, {
121+
},
122+
{
108123
"slug": "circular-buffer",
109124
"name": "Circular Buffer",
110125
"uuid": "db61cc68-40d8-47a7-838e-508784153a10",
111126
"practices": [],
112127
"prerequisites": [],
113128
"difficulty": 8
114-
}, {
129+
},
130+
{
115131
"slug": "acronym",
116132
"name": "Acronym",
117133
"uuid": "086ecf2c-9356-4d09-9391-0ae4035a34f1",
118134
"practices": [],
119135
"prerequisites": [],
120136
"difficulty": 2
121-
}, {
137+
},
138+
{
122139
"slug": "all-your-base",
123140
"name": "All Your Base",
124141
"uuid": "e201215c-169c-487c-8b50-47fa6a395906",
125142
"practices": [],
126143
"prerequisites": [],
127144
"difficulty": 5
128-
}, {
145+
},
146+
{
129147
"slug": "binary-search",
130148
"name": "Binary Search",
131149
"uuid": "7c569e5d-bb00-44b8-8adc-34253790c19b",
132150
"practices": [],
133151
"prerequisites": [],
134152
"difficulty": 6
135-
}, {
153+
},
154+
{
136155
"slug": "triangle",
137156
"name": "Triangle",
138157
"uuid": "ed3ca73a-a0f0-46b8-8013-8b6d20758c8f",
139158
"practices": [],
140159
"prerequisites": [],
141160
"difficulty": 2
142-
}, {
161+
},
162+
{
143163
"slug": "nucleotide-count",
144164
"name": "Nucleotide Count",
145165
"uuid": "dbb13cbe-fea4-4aec-879f-15cda81f5a27",
146166
"practices": [],
147167
"prerequisites": [],
148168
"difficulty": 1
149-
}, {
169+
},
170+
{
150171
"slug": "armstrong-numbers",
151172
"name": "Armstrong Numbers",
152173
"uuid": "8dff76c0-68a7-4181-859c-8e86cc1d3be4",
153174
"practices": [],
154175
"prerequisites": [],
155176
"difficulty": 1
156-
}, {
177+
},
178+
{
157179
"slug": "rna-transcription",
158180
"name": "Rna Transcription",
159181
"uuid": "c54c9479-5ee1-43fa-906c-5f3a6c041485",
160182
"practices": [],
161183
"prerequisites": [],
162184
"difficulty": 3
163-
}, {
185+
},
186+
{
164187
"slug": "raindrops",
165188
"name": "Raindrops",
166189
"uuid": "5bb7a61c-c942-4d80-87fb-a06fed959854",
167190
"practices": [],
168191
"prerequisites": [],
169192
"difficulty": 3
170-
}, {
193+
},
194+
{
171195
"slug": "hamming",
172196
"name": "Hamming",
173197
"uuid": "257096af-21dc-47ed-a00f-dd17a7d03c76",
174198
"practices": [],
175199
"prerequisites": [],
176200
"difficulty": 2
177-
}, {
201+
},
202+
{
178203
"slug": "eliuds-eggs",
179204
"name": "Eliud's Eggs",
180205
"uuid": "233fde6a-79d9-4d90-8f94-2a0519352a5c",
181206
"practices": [],
182207
"prerequisites": [],
183208
"difficulty": 4
184-
}, {
209+
},
210+
{
185211
"slug": "pangram",
186212
"name": "Pangram",
187213
"uuid": "53d9f022-03df-464f-8838-c8aaff76fa0c",
188214
"practices": [],
189215
"prerequisites": [],
190216
"difficulty": 2
191-
}, {
217+
},
218+
{
192219
"slug": "rotational-cipher",
193220
"name": "Rotational Cipher",
194-
"uuid" : "039a7a86-d954-4bb6-a144-93b2eb17b016",
195-
"practices" : [],
221+
"uuid": "039a7a86-d954-4bb6-a144-93b2eb17b016",
222+
"practices": [],
196223
"prerequisites": [],
197224
"difficulty": 4
198-
}, {
225+
},
226+
{
199227
"slug": "sieve",
200228
"name": "Sieve of Eratosthenes",
201-
"uuid" : "99498715-4615-4aa8-83a7-6cb0a32bd721",
202-
"practices" : [],
229+
"uuid": "99498715-4615-4aa8-83a7-6cb0a32bd721",
230+
"practices": [],
231+
"prerequisites": [],
232+
"difficulty": 6
233+
},
234+
{
235+
"slug": "matching-brackets",
236+
"name": "Matching Brackets",
237+
"uuid": "45892c58-05f0-4dc4-ac7d-99babf8d3006",
238+
"practices": [],
203239
"prerequisites": [],
204240
"difficulty": 6
205241
}
206242
]
207243
},
208-
"concepts": [],
209244
"key_features": [
210245
{
211-
"icon": "fun",
212246
"title": "Simple Syntax",
213-
"content": "Simpler than native assembly languages, offering a good onramp to systems programming."
247+
"content": "Simpler than native assembly languages, offering a good onramp to systems programming.",
248+
"icon": "fun"
214249
},
215250
{
216-
"icon": "fast",
217251
"title": "Fast",
218-
"content": "Optimized for fast (just-in-time) compilation to native code and raw execution speed."
252+
"content": "Optimized for fast (just-in-time) compilation to native code and raw execution speed.",
253+
"icon": "fast"
219254
},
220255
{
221-
"icon": "cross-platform",
222256
"title": "Cross-platform",
223-
"content": "Libraries reuse across languages and ecosystems. Executables run on desktops and servers."
257+
"content": "Libraries reuse across languages and ecosystems. Executables run on desktops and servers.",
258+
"icon": "cross-platform"
224259
},
225260
{
226-
"icon": "community",
227261
"title": "Designed by a committee",
228-
"content": "A vendor-neutral W3C standard with numerous contributors from research labs and industry."
262+
"content": "A vendor-neutral W3C standard with numerous contributors from research labs and industry.",
263+
"icon": "community"
229264
},
230265
{
231-
"icon": "evolving",
232266
"title": "Ever-evolving",
233-
"content": "While a core MVP is production-ready, numerous proposals will expand WebAssembly in the future."
267+
"content": "While a core MVP is production-ready, numerous proposals will expand WebAssembly in the future.",
268+
"icon": "evolving"
234269
},
235270
{
236-
"icon": "interop",
237271
"title": "JavaScript Interopability",
238-
"content": "WebAssembly is a first-class citizen of the web with excellent interoperability with JavaScript."
272+
"content": "WebAssembly is a first-class citizen of the web with excellent interoperability with JavaScript.",
273+
"icon": "interop"
239274
}
240275
],
241276
"tags": [
277+
"execution_mode/compiled",
242278
"paradigm/imperative",
243279
"paradigm/procedural",
244-
"typing/static",
245-
"typing/weak",
246-
"execution_mode/compiled",
247-
"platform/windows",
248-
"platform/mac",
249-
"platform/linux",
250-
"platform/ios",
251280
"platform/android",
281+
"platform/ios",
282+
"platform/linux",
283+
"platform/mac",
252284
"platform/web",
285+
"platform/windows",
253286
"runtime/wasmtime",
287+
"typing/static",
288+
"typing/weak",
254289
"used_for/artificial_intelligence",
255290
"used_for/backends",
256291
"used_for/cross_platform_development",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Reserved Memory
2+
3+
Bytes 64-319 of the linear memory are reserved for the input string.
4+
5+
The input string can be modified in place if desired.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Instructions
2+
3+
Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched and nested correctly.
4+
Any other characters should be ignored.
5+
For example, `"{what is (42)}?"` is balanced and `"[text}"` is not.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Introduction
2+
3+
You're given the opportunity to write software for the Bracketeer™, an ancient but powerful mainframe.
4+
The software that runs on it is written in a proprietary language.
5+
Much of its syntax is familiar, but you notice _lots_ of brackets, braces and parentheses.
6+
Despite the Bracketeer™ being powerful, it lacks flexibility.
7+
If the source code has any unbalanced brackets, braces or parentheses, the Bracketeer™ crashes and must be rebooted.
8+
To avoid such a scenario, you start writing code that can verify that brackets, braces, and parentheses are balanced before attempting to run it on the Bracketeer™.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"root": true,
3+
"extends": "@exercism/eslint-config-javascript",
4+
"env": {
5+
"jest": true
6+
},
7+
"overrides": [
8+
{
9+
"files": [
10+
"*.spec.js"
11+
],
12+
"excludedFiles": [
13+
"custom.spec.js"
14+
],
15+
"extends": "@exercism/eslint-config-javascript/maintainers"
16+
}
17+
]
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"authors": [
3+
"kahgoh"
4+
],
5+
"files": {
6+
"solution": [
7+
"matching-brackets.wat"
8+
],
9+
"test": [
10+
"matching-brackets.spec.js"
11+
],
12+
"example": [
13+
".meta/proof.ci.wat"
14+
]
15+
},
16+
"blurb": "Make sure the brackets and braces all match.",
17+
"source": "Ginna Baker"
18+
}

0 commit comments

Comments
 (0)