diff --git a/config.json b/config.json index 2b4b28b..317d9aa 100644 --- a/config.json +++ b/config.json @@ -70,6 +70,14 @@ "practices": [], "prerequisites": [], "difficulty": 1 + }, + { + "slug": "acronym", + "name": "Acronym", + "uuid": "69afd018-4769-431e-b1d3-84a678103736", + "practices": [], + "prerequisites": [], + "difficulty": 1 } ] }, diff --git a/config.yaml b/config.yaml index c350a12..a1021ad 100644 --- a/config.yaml +++ b/config.yaml @@ -74,6 +74,13 @@ exercises: prerequisites: [] difficulty: 1 + - slug: acronym + name: Acronym + uuid: 69afd018-4769-431e-b1d3-84a678103736 + practices: [] + prerequisites: [] + difficulty: 1 + tags: - execution_mode/compiled - execution_mode/interpreted diff --git a/exercises/practice/acronym/.docs/instructions.md b/exercises/practice/acronym/.docs/instructions.md new file mode 100644 index 0000000..133bd2c --- /dev/null +++ b/exercises/practice/acronym/.docs/instructions.md @@ -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 | diff --git a/exercises/practice/acronym/.meta/acronym.ys b/exercises/practice/acronym/.meta/acronym.ys new file mode 100644 index 0000000..58ef143 --- /dev/null +++ b/exercises/practice/acronym/.meta/acronym.ys @@ -0,0 +1,8 @@ +!yamlscript/v0 + +defn abbreviate(phrase): 42 + phrase + .re-seq(/[A-Z]+['a-z]*|[a-z]+/ _) + .map(first) + .apply(str) + .upper-case() diff --git a/exercises/practice/acronym/.meta/config.json b/exercises/practice/acronym/.meta/config.json new file mode 100644 index 0000000..33190aa --- /dev/null +++ b/exercises/practice/acronym/.meta/config.json @@ -0,0 +1,18 @@ +{ + "authors": [], + "files": { + "solution": [ + "acronym.ys" + ], + "test": [ + "test/test-1.ys", + "Makefile" + ], + "example": [ + ".meta/acronym.ys" + ] + }, + "blurb": "Convert a long phrase to its acronym.", + "source": "Julien Vanier", + "source_url": "https://github.com/monkbroc" +} diff --git a/exercises/practice/acronym/.meta/test b/exercises/practice/acronym/.meta/test new file mode 120000 index 0000000..419df4f --- /dev/null +++ b/exercises/practice/acronym/.meta/test @@ -0,0 +1 @@ +../test \ No newline at end of file diff --git a/exercises/practice/acronym/.meta/tests.toml b/exercises/practice/acronym/.meta/tests.toml new file mode 100644 index 0000000..6e3277c --- /dev/null +++ b/exercises/practice/acronym/.meta/tests.toml @@ -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" diff --git a/exercises/practice/acronym/Makefile b/exercises/practice/acronym/Makefile new file mode 100644 index 0000000..1560b4b --- /dev/null +++ b/exercises/practice/acronym/Makefile @@ -0,0 +1,9 @@ +SHELL := bash + +export YSPATH=$(PWD) + +default: + +.PHONY: test +test: + prove -v test/*.ys diff --git a/exercises/practice/acronym/acronym.ys b/exercises/practice/acronym/acronym.ys new file mode 100644 index 0000000..09ea797 --- /dev/null +++ b/exercises/practice/acronym/acronym.ys @@ -0,0 +1,4 @@ +!yamlscript/v0 + +defn abbreviate(phrase): + # Implement the 'abbreviate' function. diff --git a/exercises/practice/acronym/test/test-1.ys b/exercises/practice/acronym/test/test-1.ys new file mode 100644 index 0000000..100bcc7 --- /dev/null +++ b/exercises/practice/acronym/test/test-1.ys @@ -0,0 +1,48 @@ +#!/usr/bin/env ys-0 + +require ys::taptest: :all + +use: acronym + +test:: +- name: Basic + code: abbreviate('Portable Network Graphics') + want: PNG + uuid: 1e22cceb-c5e4-4562-9afe-aef07ad1eaf4 + +- name: Lowercase words + code: abbreviate('Ruby on Rails') + want: ROR + uuid: 79ae3889-a5c0-4b01-baf0-232d31180c08 + +- name: Punctuation + code: abbreviate('First In, First Out') + want: FIFO + uuid: ec7000a7-3931-4a17-890e-33ca2073a548 + +- name: All caps word + code: abbreviate('GNU Image Manipulation Program') + want: GIMP + uuid: 32dd261c-0c92-469a-9c5c-b192e94a63b0 + +- name: Punctuation without whitespace + code: abbreviate('Complementary metal-oxide semiconductor') + want: CMOS + uuid: ae2ac9fa-a606-4d05-8244-3bcc4659c1d4 + +- name: Very long abbreviation + code: abbreviate('Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me') + want: ROTFLSHTMDCOALM + uuid: 0e4b1e7c-1a6d-48fb-81a7-bf65eb9e69f9 + +- name: Consecutive delimiters + code: abbreviate('Something - I made up from thin air') + want: SIMUFTA + uuid: 6a078f49-c68d-4b7b-89af-33a1a98c28cc + +- name: Apostrophes + code: abbreviate("Halley's Comet") + want: HC + uuid: 5118b4b1-4572-434c-8d57-5b762e57973e + +done: 8