Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,27 @@ check-exercise-files:
fi; \
\
# 2. Check if the content matches (ignoring name/version) \
diff -q -I '"name":' -I '"version":' "$$source" "$$target" > /dev/null || { \
echo "ERROR: $$target does not match template $$source."; \
diff -u -I '"name":' -I '"version":' "$$source" "$$target" | head -n 20; \
exit 1; \
}; \
if [ "$$file" != ".meta/testTemplate.js" ]; then \
diff -q -I '"name":' -I '"version":' "$$source" "$$target" > /dev/null || { \
echo "ERROR: $$target does not match template $$source."; \
diff -u -I '"name":' -I '"version":' "$$source" "$$target" | head -n 20; \
exit 1; \
}; \
fi; \
done; \
done
@echo "All exercises contain all required files and are in sync."

add-test-template:
@cp templates/testTemplate.js exercises/practice/$(EXERCISE)/.meta/testTemplate.js

# copy all relevant files for a single exercise - test template, config etc.
copy-exercise-files:
@cp package.json exercises/practice/$(EXERCISE)/package.json
@cp package-lock.json exercises/practice/$(EXERCISE)/package-lock.json
@cp templates/rescript.json exercises/practice/$(EXERCISE)/rescript.json
@cp templates/.gitignore exercises/practice/$(EXERCISE)/.gitignore
@cp LICENSE exercises/practice/$(EXERCISE)/LICENSE
@cp templates/testTemplate.js exercises/practice/$(EXERCISE)/.meta/testTemplate.js

# sync all files for each exercise directory
sync-exercise-files:
Expand Down
1 change: 1 addition & 0 deletions bin/add-practice-exercise
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ exercise_dir="exercises/practice/${slug}"
files=$(jq -r --arg dir "${exercise_dir}" '.files | to_entries | map({key: .key, value: (.value | map("'"'"'" + $dir + "/" + . + "'"'"'") | join(" and "))}) | from_entries' "${exercise_dir}/.meta/config.json")

make copy-exercise-files EXERCISE="${slug}"
make add-test-template EXERCISE="${slug}"

cat << NEXT_STEPS

Expand Down
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
"prerequisites": [],
"difficulty": 1
},
{
"slug": "acronym",
"name": "Acronym",
"uuid": "175a3fc7-2d00-4d42-b4a5-4e8d894603d9",
"practices": [],
"prerequisites": [],
"difficulty": 2
},
{
"slug": "two-fer",
"name": "Two-Fer",
Expand Down
17 changes: 17 additions & 0 deletions exercises/practice/acronym/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Instructions

Convert a phrase to its acronym.

Techies love their TLA (Three Letter Acronyms)!

Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).

Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input.

For example:

| Input | Output |
| ------------------------- | ------ |
| As Soon As Possible | ASAP |
| Liquid-crystal display | LCD |
| Thank George It's Friday! | TGIF |
1 change: 1 addition & 0 deletions exercises/practice/acronym/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
10 changes: 10 additions & 0 deletions exercises/practice/acronym/.meta/Acronym.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let abbreviate = (phrase: string): string => {
switch phrase->String.match(/[a-zA-Z']+/g) {
| Some(words) =>
words
->Array.filterMap(w => w)
->Array.map(w => w->String.charAt(0)->String.toUpperCase)
->Array.join("")
| None => ""
}
}
1 change: 1 addition & 0 deletions exercises/practice/acronym/.meta/Acronym.resi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let abbreviate: string => string
30 changes: 30 additions & 0 deletions exercises/practice/acronym/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"authors": [
"gabrielperales",
"therealowenrees"
],
"contributors": [
"benreyn",
"naartjie",
"ohana54",
"stevejb71",
"tejasbubane"
],
"files": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing an editor entry for Acronym.resi here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how strange, this was automatically added for the other exercises. I will keep my eye on that to see if there is a bug.

"solution": [
"src/Acronym.res"
],
"test": [
"tests/Acronym_test.res"
],
"example": [
".meta/Acronym.res"
],
"editor": [
"src/Acronym.resi"
]
},
"blurb": "Convert a long phrase to its acronym.",
"source": "Julien Vanier",
"source_url": "https://github.com/monkbroc"
}
17 changes: 17 additions & 0 deletions exercises/practice/acronym/.meta/testTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { stringEqual } from "../../../../test_generator/assertions.js";
import { generateTests } from '../../../../test_generator/testGenerator.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const slug = path.basename(path.resolve(__dirname, '..'))

// EDIT THIS WITH YOUR ASSERTIONS
export const assertionFunctions = [ stringEqual ]

// EDIT THIS WITH YOUR TEST TEMPLATES
export const template = (c) => {
return `stringEqual(~message="${c.description}", abbreviate("${c.input.phrase}"), "${c.expected}")`
}

generateTests(__dirname, slug, assertionFunctions, template)
37 changes: 37 additions & 0 deletions exercises/practice/acronym/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[1e22cceb-c5e4-4562-9afe-aef07ad1eaf4]
description = "basic"

[79ae3889-a5c0-4b01-baf0-232d31180c08]
description = "lowercase words"

[ec7000a7-3931-4a17-890e-33ca2073a548]
description = "punctuation"

[32dd261c-0c92-469a-9c5c-b192e94a63b0]
description = "all caps word"

[ae2ac9fa-a606-4d05-8244-3bcc4659c1d4]
description = "punctuation without whitespace"

[0e4b1e7c-1a6d-48fb-81a7-bf65eb9e69f9]
description = "very long abbreviation"

[6a078f49-c68d-4b7b-89af-33a1a98c28cc]
description = "consecutive delimiters"

[5118b4b1-4572-434c-8d57-5b762e57973e]
description = "apostrophes"

[adc12eab-ec2d-414f-b48c-66a4fc06cdef]
description = "underscore emphasis"
21 changes: 21 additions & 0 deletions exercises/practice/acronym/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Exercism

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading