Skip to content
Merged
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
2 changes: 1 addition & 1 deletion bin/add-practice-exercise
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fi
./bin/fetch-configlet
./bin/configlet create --practice-exercise "${slug}" --author "${author}" --difficulty "${difficulty}"

filter='.exercises.practice = (.exercises.practice | sort_by(.difficulty, .slug))'
filter='.exercises.practice = (.exercises.practice | sort_by(.difficulty, (.name|ascii_upcase))'
jq "${filter}" config.json > config.sorted && mv config.sorted config.json

exercise_dir="exercises/practice/${slug}"
Expand Down
94 changes: 51 additions & 43 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,14 @@
"strings"
]
},
{
"slug": "line-up",
"name": "Line Up",
"uuid": "2a4e105e-5545-4baf-aba5-75cbc5aee498",
"practices": [],
"prerequisites": [],
"difficulty": 3
},
{
"slug": "matrix",
"name": "Matrix",
Expand Down Expand Up @@ -567,28 +575,28 @@
"difficulty": 3
},
{
"slug": "rna-transcription",
"name": "RNA Transcription",
"uuid": "5029a8ed-3766-4632-bdab-964ca4a06e34",
"slug": "reverse-string",
"name": "Reverse String",
"uuid": "2d443a8f-65de-496e-9527-8a54a840ba69",
"practices": [],
"prerequisites": [],
"difficulty": 3,
"topics": [
"control_flow_loops",
"strings",
"transforming"
"arrays",
"strings"
]
},
{
"slug": "reverse-string",
"name": "Reverse String",
"uuid": "2d443a8f-65de-496e-9527-8a54a840ba69",
"slug": "rna-transcription",
"name": "RNA Transcription",
"uuid": "5029a8ed-3766-4632-bdab-964ca4a06e34",
"practices": [],
"prerequisites": [],
"difficulty": 3,
"topics": [
"arrays",
"strings"
"control_flow_loops",
"strings",
"transforming"
]
},
{
Expand Down Expand Up @@ -776,6 +784,14 @@
"text_formatting"
]
},
{
"slug": "dominoes",
"name": "Dominoes",
"uuid": "0ea6977c-5032-40ab-bd67-be23e052c69f",
"practices": [],
"prerequisites": [],
"difficulty": 4
},
{
"slug": "grade-school",
"name": "Grade School",
Expand Down Expand Up @@ -988,14 +1004,6 @@
"prerequisites": [],
"difficulty": 4
},
{
"slug": "dominoes",
"name": "Dominoes",
"uuid": "0ea6977c-5032-40ab-bd67-be23e052c69f",
"practices": [],
"prerequisites": [],
"difficulty": 4
},
{
"slug": "affine-cipher",
"name": "Affine Cipher",
Expand Down Expand Up @@ -1113,6 +1121,14 @@
"strings"
]
},
{
"slug": "palindrome-products",
"name": "Palindrome Products",
"uuid": "928d3505-7780-4d2d-8fd8-7c8f0aac4033",
"practices": [],
"prerequisites": [],
"difficulty": 5
},
{
"slug": "pascals-triangle",
"name": "Pascal's Triangle",
Expand Down Expand Up @@ -1189,14 +1205,6 @@
"text_parsing"
]
},
{
"slug": "palindrome-products",
"name": "Palindrome Products",
"uuid": "928d3505-7780-4d2d-8fd8-7c8f0aac4033",
"practices": [],
"prerequisites": [],
"difficulty": 5
},
{
"slug": "anagram",
"name": "Anagram",
Expand All @@ -1219,6 +1227,14 @@
"prerequisites": [],
"difficulty": 6
},
{
"slug": "complex-numbers",
"name": "Complex Numbers",
"uuid": "ed6b5073-e3b1-4787-8551-ffffa9e7313d",
"practices": [],
"prerequisites": [],
"difficulty": 6
},
{
"slug": "custom-set",
"name": "Custom Set",
Expand Down Expand Up @@ -1288,17 +1304,9 @@
]
},
{
"slug": "complex-numbers",
"name": "Complex Numbers",
"uuid": "ed6b5073-e3b1-4787-8551-ffffa9e7313d",
"practices": [],
"prerequisites": [],
"difficulty": 6
},
{
"slug": "minesweeper",
"name": "Minesweeper",
"uuid": "fcb9cc16-7690-4ee6-a373-c8476063ec57",
"slug": "flower-field",
"name": "Flower Field",
"uuid": "7915cf5b-bd42-45aa-abd7-21dfb0059169",
"practices": [],
"prerequisites": [],
"difficulty": 7,
Expand All @@ -1308,16 +1316,16 @@
"control_flow_loops",
"exception_handling",
"strings"
],
"status": "deprecated"
]
},
{
"slug": "flower-field",
"name": "Flower Field",
"uuid": "7915cf5b-bd42-45aa-abd7-21dfb0059169",
"slug": "minesweeper",
"name": "Minesweeper",
"uuid": "fcb9cc16-7690-4ee6-a373-c8476063ec57",
"practices": [],
"prerequisites": [],
"difficulty": 7,
"status": "deprecated",
"topics": [
"arrays",
"control_flow_if_else_statements",
Expand Down
1 change: 0 additions & 1 deletion exercises/practice/flower-field/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"authors": [
"ryanplusplus"
],
"contributors": [],
"files": {
"solution": [
"flower-field.lua"
Expand Down
5 changes: 5 additions & 0 deletions exercises/practice/line-up/.busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
default = {
ROOT = { '.' }
}
}
19 changes: 19 additions & 0 deletions exercises/practice/line-up/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions exercises/practice/line-up/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions exercises/practice/line-up/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"authors": [
"keiravillekode"
],
"files": {
"solution": [
"line-up.lua"
],
"test": [
"line-up_spec.lua"
],
"example": [
".meta/example.lua"
]
},
"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"
}
18 changes: 18 additions & 0 deletions exercises/practice/line-up/.meta/example.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
return {
format = function(name, number)
local suffix = 'th'
if number // 10 % 10 ~= 1 then
local last = number % 10
if last == 1 then
suffix = 'st'
end
if last == 2 then
suffix = 'nd'
end
if last == 3 then
suffix = 'rd'
end
end
return string.format('%s, you are the %d%s customer we serve today. Thank you!', name, number, suffix)
end
}
10 changes: 10 additions & 0 deletions exercises/practice/line-up/.meta/spec_generator.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return {
module_name = 'line_up',

generate_test = function(case)
local template = [[
local expected = '%s'
assert.are.same(expected, line_up.format('%s', %d))]]
return template:format(case.expected, case.input.name, case.input.number)
end
}
67 changes: 67 additions & 0 deletions exercises/practice/line-up/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions exercises/practice/line-up/line-up.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
format = function(name, number)
end
}
Loading
Loading