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
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@
"practices": [],
"prerequisites": [],
"difficulty": 2
},
{
"slug": "line-up",
"name": "Line Up",
"uuid": "faab9c05-bbb8-4b5c-8cb9-6d7019927630",
"practices": [],
"prerequisites": [],
"difficulty": 2
}
]
},
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 (unless ending in 11) → `"st"`
- Numbers ending in 2 (unless ending in 12) → `"nd"`
- Numbers ending in 3 (unless ending in 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": [
"glennj"
],
"files": {
"solution": [
"line_up.moon"
],
"test": [
"line_up_spec.moon"
],
"example": [
".meta/example.moon"
]
},
"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"
}
12 changes: 12 additions & 0 deletions exercises/practice/line-up/.meta/example.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
format: (name, number) ->
ones, tens = number % 10, number % 100

suffix = switch ones
when 1 then if tens == 11 then 'th' else 'st'
when 2 then if tens == 12 then 'th' else 'nd'
when 3 then if tens == 13 then 'th' else 'rd'
else 'th'

"#{name}, you are the #{number}#{suffix} customer we serve today. Thank you!"
}
11 changes: 11 additions & 0 deletions exercises/practice/line-up/.meta/spec_generator.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
module_name: 'LineUp',

generate_test: (case, level) ->
lines = {
"result = LineUp.#{case.property} #{quote case.input.name}, #{case.input.number}",
"expected = #{quote case.expected}",
"assert.are.equal expected, result"
}
table.concat [indent line, level for line in *lines], '\n'
}
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"
Empty file.
97 changes: 97 additions & 0 deletions exercises/practice/line-up/line_up_spec.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
LineUp = require 'line_up'

describe 'line-up', ->
it 'format smallest non-exceptional ordinal numeral 4', ->
result = LineUp.format 'Gianna', 4
expected = 'Gianna, you are the 4th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format greatest single digit non-exceptional ordinal numeral 9', ->
result = LineUp.format 'Maarten', 9
expected = 'Maarten, you are the 9th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format non-exceptional ordinal numeral 5', ->
result = LineUp.format 'Petronila', 5
expected = 'Petronila, you are the 5th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format non-exceptional ordinal numeral 6', ->
result = LineUp.format 'Attakullakulla', 6
expected = 'Attakullakulla, you are the 6th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format non-exceptional ordinal numeral 7', ->
result = LineUp.format 'Kate', 7
expected = 'Kate, you are the 7th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format non-exceptional ordinal numeral 8', ->
result = LineUp.format 'Maximiliano', 8
expected = 'Maximiliano, you are the 8th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format exceptional ordinal numeral 1', ->
result = LineUp.format 'Mary', 1
expected = 'Mary, you are the 1st customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format exceptional ordinal numeral 2', ->
result = LineUp.format 'Haruto', 2
expected = 'Haruto, you are the 2nd customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format exceptional ordinal numeral 3', ->
result = LineUp.format 'Henriette', 3
expected = 'Henriette, you are the 3rd customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format smallest two digit non-exceptional ordinal numeral 10', ->
result = LineUp.format 'Alvarez', 10
expected = 'Alvarez, you are the 10th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format non-exceptional ordinal numeral 11', ->
result = LineUp.format 'Jacqueline', 11
expected = 'Jacqueline, you are the 11th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format non-exceptional ordinal numeral 12', ->
result = LineUp.format 'Juan', 12
expected = 'Juan, you are the 12th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format non-exceptional ordinal numeral 13', ->
result = LineUp.format 'Patricia', 13
expected = 'Patricia, you are the 13th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format exceptional ordinal numeral 21', ->
result = LineUp.format 'Washi', 21
expected = 'Washi, you are the 21st customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format exceptional ordinal numeral 62', ->
result = LineUp.format 'Nayra', 62
expected = 'Nayra, you are the 62nd customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format exceptional ordinal numeral 100', ->
result = LineUp.format 'John', 100
expected = 'John, you are the 100th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format exceptional ordinal numeral 101', ->
result = LineUp.format 'Zeinab', 101
expected = 'Zeinab, you are the 101st customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format non-exceptional ordinal numeral 112', ->
result = LineUp.format 'Knud', 112
expected = 'Knud, you are the 112th customer we serve today. Thank you!'
assert.are.equal expected, result

pending 'format exceptional ordinal numeral 123', ->
result = LineUp.format 'Yma', 123
expected = 'Yma, you are the 123rd customer we serve today. Thank you!'
assert.are.equal expected, result
Loading