diff options
author | Andinus <andinus@nand.sh> | 2021-09-08 22:26:42 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-09-08 22:26:42 +0530 |
commit | 39a144c85aa4229345463280d4f61266350a6527 (patch) | |
tree | 15b7c9aeedfaee8700c8e79b1f73c0716de23a13 | |
parent | 2cccd54aaa588c7446417b00c6ece21f69fbd8ec (diff) | |
download | exercism-39a144c85aa4229345463280d4f61266350a6527.tar.gz |
Raku: Acronym: Add solution
-rw-r--r-- | README.org | 1 | ||||
-rw-r--r-- | raku/acronym/Acronym.rakumod | 5 | ||||
-rw-r--r-- | raku/acronym/HELP.md | 32 | ||||
-rw-r--r-- | raku/acronym/README.md | 27 | ||||
-rw-r--r-- | raku/acronym/acronym.rakutest | 89 |
5 files changed, 154 insertions, 0 deletions
diff --git a/README.org b/README.org index 7d5a0b0..8924540 100644 --- a/README.org +++ b/README.org @@ -88,6 +88,7 @@ My solutions for [[https://exercism.io][Exercism]] exercises. - [X] Luhn - [ ] Phone Number - [ ] RNA Transcription +- [ ] Acronym * Rust [2/3] diff --git a/raku/acronym/Acronym.rakumod b/raku/acronym/Acronym.rakumod new file mode 100644 index 0000000..401d867 --- /dev/null +++ b/raku/acronym/Acronym.rakumod @@ -0,0 +1,5 @@ +unit module Acronym; + +sub abbreviate(Str $phrase --> Str) is export { + $phrase.split((' ', '-'), :skip-empty).map(*.comb(/<[a..zA..Z]>/).first).join.uc +} diff --git a/raku/acronym/HELP.md b/raku/acronym/HELP.md new file mode 100644 index 0000000..dce79ca --- /dev/null +++ b/raku/acronym/HELP.md @@ -0,0 +1,32 @@ +# Help + +## Running the tests + +You can run the test suite for the exercise by executing the command +`prove6 .` in the exercise directory. + +## Submitting your solution + +You can submit your solution using the `exercism submit Acronym.rakumod` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Raku track's documentation](https://exercism.org/docs/tracks/raku) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [Raku resources](https://raku.org/resources/) +- [/r/rakulang](https://www.reddit.com/r/rakulang) is the Raku subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/raku) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/raku/acronym/README.md b/raku/acronym/README.md new file mode 100644 index 0000000..d2ca89c --- /dev/null +++ b/raku/acronym/README.md @@ -0,0 +1,27 @@ +# Acronym + +Welcome to Acronym on Exercism's Raku Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## 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). + +## Source + +### Created by + +- @dcampos + +### Contributed to by + +- @m-dango + +### Based on + +Julien Vanier - https://github.com/monkbroc \ No newline at end of file diff --git a/raku/acronym/acronym.rakutest b/raku/acronym/acronym.rakutest new file mode 100644 index 0000000..fad0fe4 --- /dev/null +++ b/raku/acronym/acronym.rakutest @@ -0,0 +1,89 @@ +#!/usr/bin/env raku +use Test; +use JSON::Fast; +use lib $?FILE.IO.dirname; +use Acronym; +plan 9; + +my @test-cases = from-json($=pod[*-1].contents).List; +for @test-cases -> %case { + is abbreviate(%case<input><phrase>), |%case<expected description>; +} + +=head2 Test Cases +=begin code +[ + { + "description": "basic", + "expected": "PNG", + "input": { + "phrase": "Portable Network Graphics" + }, + "property": "abbreviate" + }, + { + "description": "lowercase words", + "expected": "ROR", + "input": { + "phrase": "Ruby on Rails" + }, + "property": "abbreviate" + }, + { + "description": "punctuation", + "expected": "FIFO", + "input": { + "phrase": "First In, First Out" + }, + "property": "abbreviate" + }, + { + "description": "all caps word", + "expected": "GIMP", + "input": { + "phrase": "GNU Image Manipulation Program" + }, + "property": "abbreviate" + }, + { + "description": "punctuation without whitespace", + "expected": "CMOS", + "input": { + "phrase": "Complementary metal-oxide semiconductor" + }, + "property": "abbreviate" + }, + { + "description": "very long abbreviation", + "expected": "ROTFLSHTMDCOALM", + "input": { + "phrase": "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" + }, + "property": "abbreviate" + }, + { + "description": "consecutive delimiters", + "expected": "SIMUFTA", + "input": { + "phrase": "Something - I made up from thin air" + }, + "property": "abbreviate" + }, + { + "description": "apostrophes", + "expected": "HC", + "input": { + "phrase": "Halley's Comet" + }, + "property": "abbreviate" + }, + { + "description": "underscore emphasis", + "expected": "TRNT", + "input": { + "phrase": "The Road _Not_ Taken" + }, + "property": "abbreviate" + } +] +=end code |