diff --git a/config.json b/config.json index ccd92bdc..79012a38 100644 --- a/config.json +++ b/config.json @@ -582,6 +582,14 @@ "strings" ] }, + { + "slug": "line-up", + "name": "Line Up", + "uuid": "cb7d3d70-185d-47cb-b8b7-a0f6ce1c0cf5", + "practices": [], + "prerequisites": [], + "difficulty": 4 + }, { "slug": "matching-brackets", "name": "Matching Brackets", @@ -810,10 +818,10 @@ "practices": [], "prerequisites": [], "difficulty": 5, + "status": "deprecated", "topics": [ "control_flow_loops" - ], - "status": "deprecated" + ] }, { "slug": "nucleotide-count", diff --git a/exercises/practice/line-up/.docs/instructions.md b/exercises/practice/line-up/.docs/instructions.md new file mode 100644 index 00000000..fb41d4cb --- /dev/null +++ b/exercises/practice/line-up/.docs/instructions.md @@ -0,0 +1,19 @@ +# Instructions + +Given a name and a number, your task is to produce a sentence using that name and that number as an [ordinal numeral][ordinal-numeral]. +Yaʻqūb expects to use numbers from 1 up to 999. + +Rules: + +- Numbers ending in 1 (except for 11) → `"st"` +- Numbers ending in 2 (except for 12) → `"nd"` +- Numbers ending in 3 (except for 13) → `"rd"` +- All other numbers → `"th"` + +Examples: + +- `"Mary", 1` → `"Mary, you are the 1st customer we serve today. Thank you!"` +- `"John", 12` → `"John, you are the 12th customer we serve today. Thank you!"` +- `"Dahir", 162` → `"Dahir, you are the 162nd customer we serve today. Thank you!"` + +[ordinal-numeral]: https://en.wikipedia.org/wiki/Ordinal_numeral diff --git a/exercises/practice/line-up/.docs/introduction.md b/exercises/practice/line-up/.docs/introduction.md new file mode 100644 index 00000000..ea07268a --- /dev/null +++ b/exercises/practice/line-up/.docs/introduction.md @@ -0,0 +1,7 @@ +# Introduction + +Your friend Yaʻqūb works the counter at a deli in town, slicing, weighing, and wrapping orders for a line of hungry customers that gets longer every day. +Waiting customers are starting to lose track of who is next, so he wants numbered tickets they can use to track the order in which they arrive. + +To make the customers feel special, he does not want the ticket to have only a number on it. +They shall get a proper English sentence with their name and number on it. diff --git a/exercises/practice/line-up/.meta/config.json b/exercises/practice/line-up/.meta/config.json new file mode 100644 index 00000000..c490a517 --- /dev/null +++ b/exercises/practice/line-up/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "keiravillekode" + ], + "files": { + "solution": [ + "line-up.el" + ], + "test": [ + "line-up-test.el" + ], + "example": [ + ".meta/example.el" + ] + }, + "blurb": "Help lining up customers at Yaʻqūb's Deli.", + "source": "mk-mxp, based on previous work from Exercism contributors codedge and neenjaw", + "source_url": "https://forum.exercism.org/t/new-exercise-ordinal-numbers/19147" +} diff --git a/exercises/practice/line-up/.meta/example.el b/exercises/practice/line-up/.meta/example.el new file mode 100644 index 00000000..13da448b --- /dev/null +++ b/exercises/practice/line-up/.meta/example.el @@ -0,0 +1,29 @@ +;;; line-up.el --- Line Up (exercism) -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + + +(defun suffix (number) + (let ((units (mod number 10)) + (tens (mod (/ number 10) 10))) + (cond ((= tens 1) "th") + ((= units 1) "st") + ((= units 2) "nd") + ((= units 3) "rd") + (t "th")))) + + +(defun ticket (name number) + (concat + name + ", you are the " + (number-to-string number) + (suffix number) + " customer we serve today. Thank you!")) + + +(provide 'line-up) +;;; line-up.el ends here + diff --git a/exercises/practice/line-up/.meta/tests.toml b/exercises/practice/line-up/.meta/tests.toml new file mode 100644 index 00000000..36fdf1d0 --- /dev/null +++ b/exercises/practice/line-up/.meta/tests.toml @@ -0,0 +1,67 @@ +# 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. + +[7760d1b8-4864-4db4-953b-0fa7c047dbc0] +description = "format smallest non-exceptional ordinal numeral 4" + +[e8b7c715-6baa-4f7b-8fb3-2fa48044ab7a] +description = "format greatest single digit non-exceptional ordinal numeral 9" + +[f370aae9-7ae7-4247-90ce-e8ff8c6934df] +description = "format non-exceptional ordinal numeral 5" + +[37f10dea-42a2-49de-bb92-0b690b677908] +description = "format non-exceptional ordinal numeral 6" + +[d8dfb9a2-3a1f-4fee-9dae-01af3600054e] +description = "format non-exceptional ordinal numeral 7" + +[505ec372-1803-42b1-9377-6934890fd055] +description = "format non-exceptional ordinal numeral 8" + +[8267072d-be1f-4f70-b34a-76b7557a47b9] +description = "format exceptional ordinal numeral 1" + +[4d8753cb-0364-4b29-84b8-4374a4fa2e3f] +description = "format exceptional ordinal numeral 2" + +[8d44c223-3a7e-4f48-a0ca-78e67bf98aa7] +description = "format exceptional ordinal numeral 3" + +[6c4f6c88-b306-4f40-bc78-97cdd583c21a] +description = "format smallest two digit non-exceptional ordinal numeral 10" + +[e257a43f-d2b1-457a-97df-25f0923fc62a] +description = "format non-exceptional ordinal numeral 11" + +[bb1db695-4d64-457f-81b8-4f5a2107e3f4] +description = "format non-exceptional ordinal numeral 12" + +[60a3187c-9403-4835-97de-4f10ebfd63e2] +description = "format non-exceptional ordinal numeral 13" + +[2bdcebc5-c029-4874-b6cc-e9bec80d603a] +description = "format exceptional ordinal numeral 21" + +[74ee2317-0295-49d2-baf0-d56bcefa14e3] +description = "format exceptional ordinal numeral 62" + +[b37c332d-7f68-40e3-8503-e43cbd67a0c4] +description = "format exceptional ordinal numeral 100" + +[0375f250-ce92-4195-9555-00e28ccc4d99] +description = "format exceptional ordinal numeral 101" + +[0d8a4974-9a8a-45a4-aca7-a9fb473c9836] +description = "format non-exceptional ordinal numeral 112" + +[06b62efe-199e-4ce7-970d-4bf73945713f] +description = "format exceptional ordinal numeral 123" diff --git a/exercises/practice/line-up/line-up-test.el b/exercises/practice/line-up/line-up-test.el new file mode 100644 index 00000000..d9e5eb09 --- /dev/null +++ b/exercises/practice/line-up/line-up-test.el @@ -0,0 +1,108 @@ +;;; line-up-test.el --- Line Up (exercism) -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + + +(load-file "line-up.el") +(declare-function ticket "line-up.el" (name number)) + + +(ert-deftest format-smallest-non-exceptional-ordinal-numeral-4 () + (should (string= "Gianna, you are the 4th customer we serve today. Thank you!" + (ticket "Gianna" 4)))) + + +(ert-deftest format-greatest-single-digit-non-exceptional-ordinal-numeral-9 () + (should (string= "Maarten, you are the 9th customer we serve today. Thank you!" + (ticket "Maarten" 9)))) + + +(ert-deftest format-non-exceptional-ordinal-numeral-5 () + (should (string= "Petronila, you are the 5th customer we serve today. Thank you!" + (ticket "Petronila" 5)))) + + +(ert-deftest format-non-exceptional-ordinal-numeral-6 () + (should (string= "Attakullakulla, you are the 6th customer we serve today. Thank you!" + (ticket "Attakullakulla" 6)))) + + +(ert-deftest format-non-exceptional-ordinal-numeral-7 () + (should (string= "Kate, you are the 7th customer we serve today. Thank you!" + (ticket "Kate" 7)))) + + +(ert-deftest format-non-exceptional-ordinal-numeral-8 () + (should (string= "Maximiliano, you are the 8th customer we serve today. Thank you!" + (ticket "Maximiliano" 8)))) + + +(ert-deftest format-exceptional-ordinal-numeral-1 () + (should (string= "Mary, you are the 1st customer we serve today. Thank you!" + (ticket "Mary" 1)))) + + +(ert-deftest format-exceptional-ordinal-numeral-2 () + (should (string= "Haruto, you are the 2nd customer we serve today. Thank you!" + (ticket "Haruto" 2)))) + + +(ert-deftest format-exceptional-ordinal-numeral-3 () + (should (string= "Henriette, you are the 3rd customer we serve today. Thank you!" + (ticket "Henriette" 3)))) + + +(ert-deftest format-smallest-two-digit-non-exceptional-ordinal-numeral-10 () + (should (string= "Alvarez, you are the 10th customer we serve today. Thank you!" + (ticket "Alvarez" 10)))) + + +(ert-deftest format-non-exceptional-ordinal-numeral-11 () + (should (string= "Jacqueline, you are the 11th customer we serve today. Thank you!" + (ticket "Jacqueline" 11)))) + + +(ert-deftest format-non-exceptional-ordinal-numeral-12 () + (should (string= "Juan, you are the 12th customer we serve today. Thank you!" + (ticket "Juan" 12)))) + + +(ert-deftest format-non-exceptional-ordinal-numeral-13 () + (should (string= "Patricia, you are the 13th customer we serve today. Thank you!" + (ticket "Patricia" 13)))) + + +(ert-deftest format-exceptional-ordinal-numeral-21 () + (should (string= "Washi, you are the 21st customer we serve today. Thank you!" + (ticket "Washi" 21)))) + + +(ert-deftest format-exceptional-ordinal-numeral-62 () + (should (string= "Nayra, you are the 62nd customer we serve today. Thank you!" + (ticket "Nayra" 62)))) + + +(ert-deftest format-exceptional-ordinal-numeral-100 () + (should (string= "John, you are the 100th customer we serve today. Thank you!" + (ticket "John" 100)))) + + +(ert-deftest format-exceptional-ordinal-numeral-101 () + (should (string= "Zeinab, you are the 101st customer we serve today. Thank you!" + (ticket "Zeinab" 101)))) + + +(ert-deftest format-non-exceptional-ordinal-numeral-112 () + (should (string= "Knud, you are the 112th customer we serve today. Thank you!" + (ticket "Knud" 112)))) + + +(ert-deftest format-exceptional-ordinal-numeral-123 () + (should (string= "Yma, you are the 123rd customer we serve today. Thank you!" + (ticket "Yma" 123)))) + + +(provide 'line-up-test) +;;; line-up-test.el ends here diff --git a/exercises/practice/line-up/line-up.el b/exercises/practice/line-up/line-up.el new file mode 100644 index 00000000..3bf8cb29 --- /dev/null +++ b/exercises/practice/line-up/line-up.el @@ -0,0 +1,14 @@ +;;; line-up.el --- Line Up (exercism) -*- lexical-binding: t; -*- + +;;; Commentary: + +;;; Code: + + +(defun ticket (name number) + (error "Delete this S-Expression and write your own implementation")) + + +(provide 'line-up) +;;; line-up.el ends here +