Skip to content

Commit 84fc881

Browse files
committed
Add line-up
1 parent bfd3e79 commit 84fc881

13 files changed

Lines changed: 653 additions & 0 deletions

File tree

config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,19 @@
650650
],
651651
"difficulty": 1
652652
},
653+
{
654+
"slug": "line-up",
655+
"name": "Line Up",
656+
"uuid": "4fb5288a-e02f-4b5b-8565-5de43b600b8f",
657+
"practices": [
658+
"strings"
659+
],
660+
"prerequisites": [
661+
"if-statements",
662+
"strings"
663+
],
664+
"difficulty": 1
665+
},
653666
{
654667
"slug": "gigasecond",
655668
"name": "Gigasecond",

exercises/Exercises.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerField", "practice\flo
373373
EndProject
374374
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Camicia", "practice\camicia\Camicia.csproj", "{637DEB61-9832-42B0-9907-0671611A92EB}"
375375
EndProject
376+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LineUp", "practice\line-up\LineUp.csproj", "{B9978244-5E52-4520-BFC6-FC81943794A9}"
377+
EndProject
376378
Global
377379
GlobalSection(SolutionConfigurationPlatforms) = preSolution
378380
Debug|Any CPU = Debug|Any CPU
@@ -2567,6 +2569,18 @@ Global
25672569
{637DEB61-9832-42B0-9907-0671611A92EB}.Release|x64.Build.0 = Release|Any CPU
25682570
{637DEB61-9832-42B0-9907-0671611A92EB}.Release|x86.ActiveCfg = Release|Any CPU
25692571
{637DEB61-9832-42B0-9907-0671611A92EB}.Release|x86.Build.0 = Release|Any CPU
2572+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2573+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
2574+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|x64.ActiveCfg = Debug|Any CPU
2575+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|x64.Build.0 = Debug|Any CPU
2576+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|x86.ActiveCfg = Debug|Any CPU
2577+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|x86.Build.0 = Debug|Any CPU
2578+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
2579+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|Any CPU.Build.0 = Release|Any CPU
2580+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|x64.ActiveCfg = Release|Any CPU
2581+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|x64.Build.0 = Release|Any CPU
2582+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|x86.ActiveCfg = Release|Any CPU
2583+
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|x86.Build.0 = Release|Any CPU
25702584
EndGlobalSection
25712585
GlobalSection(SolutionProperties) = preSolution
25722586
HideSolutionNode = FALSE
@@ -2755,6 +2769,7 @@ Global
27552769
{2C37454E-8624-47B8-A09B-ADE201C2B04C} = {E276EF69-669A-43E0-88AC-8ABB17A9C026}
27562770
{88E165C6-5E27-4F48-942A-0D41A9A6326D} = {E276EF69-669A-43E0-88AC-8ABB17A9C026}
27572771
{637DEB61-9832-42B0-9907-0671611A92EB} = {E276EF69-669A-43E0-88AC-8ABB17A9C026}
2772+
{B9978244-5E52-4520-BFC6-FC81943794A9} = {E276EF69-669A-43E0-88AC-8ABB17A9C026}
27582773
EndGlobalSection
27592774
GlobalSection(ExtensibilityGlobals) = postSolution
27602775
SolutionGuid = {AB4EA6C9-5461-4024-BDC7-2AE0C3A85CD1}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Instructions
2+
3+
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].
4+
Yaʻqūb expects to use numbers from 1 up to 999.
5+
6+
Rules:
7+
8+
- Numbers ending in 1 (unless ending in 11) → `"st"`
9+
- Numbers ending in 2 (unless ending in 12) → `"nd"`
10+
- Numbers ending in 3 (unless ending in 13) → `"rd"`
11+
- All other numbers → `"th"`
12+
13+
Examples:
14+
15+
- `"Mary", 1``"Mary, you are the 1st customer we serve today. Thank you!"`
16+
- `"John", 12``"John, you are the 12th customer we serve today. Thank you!"`
17+
- `"Dahir", 162``"Dahir, you are the 162nd customer we serve today. Thank you!"`
18+
19+
[ordinal-numeral]: https://en.wikipedia.org/wiki/Ordinal_numeral
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Introduction
2+
3+
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.
4+
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.
5+
6+
To make the customers feel special, he does not want the ticket to have only a number on it.
7+
They shall get a proper English sentence with their name and number on it.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
###############################
2+
# Core EditorConfig Options #
3+
###############################
4+
5+
; This file is for unifying the coding style for different editors and IDEs.
6+
; More information at:
7+
; https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
8+
; https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2017
9+
10+
root = true
11+
12+
[*]
13+
indent_style = space
14+
15+
[LineUp.cs]
16+
indent_size = 4
17+
18+
###############################
19+
# .NET Coding Conventions #
20+
###############################
21+
22+
# Organize usings
23+
dotnet_sort_system_directives_first = true
24+
dotnet_separate_import_directive_groups = true
25+
26+
# this. preferences
27+
dotnet_style_qualification_for_field = false:suggestion
28+
dotnet_style_qualification_for_property = false:suggestion
29+
dotnet_style_qualification_for_method = false:suggestion
30+
dotnet_style_qualification_for_event = false:suggestion
31+
32+
# Language keywords vs BCL types preferences
33+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
34+
dotnet_style_predefined_type_for_member_access = true:suggestion
35+
36+
# Parentheses preferences
37+
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
38+
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
39+
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
40+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
41+
42+
# Modifier preferences
43+
dotnet_style_require_accessibility_modifiers = always:suggestion
44+
dotnet_style_readonly_field = true:suggestion
45+
46+
# Expression-level preferences
47+
dotnet_style_object_initializer = true:suggestion
48+
dotnet_style_collection_initializer = true:suggestion
49+
dotnet_style_explicit_tuple_names = true:suggestion
50+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
51+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
52+
dotnet_style_prefer_auto_properties = true:suggestion
53+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
54+
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
55+
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
56+
dotnet_style_coalesce_expression = true:suggestion
57+
dotnet_style_null_propagation = true:suggestion
58+
59+
###############################
60+
# Naming Conventions #
61+
###############################
62+
63+
# Style Definitions
64+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
65+
66+
# Use PascalCase for constant fields
67+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
68+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
69+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
70+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
71+
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
72+
dotnet_naming_symbols.constant_fields.required_modifiers = const
73+
74+
###############################
75+
# C# Code Style Rules #
76+
###############################
77+
78+
# var preferences
79+
csharp_style_var_for_built_in_types = true:none
80+
csharp_style_var_when_type_is_apparent = true:none
81+
csharp_style_var_elsewhere = true:none
82+
83+
# Expression-bodied members
84+
csharp_style_expression_bodied_methods = true:suggestion
85+
csharp_style_expression_bodied_constructors = true:suggestion
86+
csharp_style_expression_bodied_operators = true:suggestion
87+
csharp_style_expression_bodied_properties = true:suggestion
88+
csharp_style_expression_bodied_indexers = true:suggestion
89+
csharp_style_expression_bodied_accessors = true:suggestion
90+
91+
# Pattern-matching preferences
92+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
93+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
94+
95+
# Null-checking preferences
96+
csharp_style_throw_expression = true:suggestion
97+
csharp_style_conditional_delegate_call = true:suggestion
98+
99+
# Modifier preferences
100+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
101+
102+
# Expression-level preferences
103+
csharp_prefer_braces = true:none
104+
csharp_prefer_simple_default_expression = true:suggestion
105+
csharp_style_deconstructed_variable_declaration = true:suggestion
106+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
107+
csharp_style_inlined_variable_declaration = true:suggestion
108+
109+
###############################
110+
# C# Formatting Rules #
111+
###############################
112+
113+
# New line preferences
114+
csharp_new_line_before_open_brace = all
115+
csharp_new_line_before_else = true
116+
csharp_new_line_before_catch = true
117+
csharp_new_line_before_finally = true
118+
csharp_new_line_before_members_in_object_initializers = false
119+
csharp_new_line_before_members_in_anonymous_types = false
120+
csharp_new_line_between_query_expression_clauses = true
121+
122+
# Indentation preferences
123+
csharp_indent_case_contents = true
124+
csharp_indent_switch_labels = true
125+
csharp_indent_labels = flush_left
126+
127+
# Space preferences
128+
csharp_space_after_cast = false
129+
csharp_space_after_keywords_in_control_flow_statements = true
130+
csharp_space_between_method_declaration_parameter_list_parentheses = false
131+
csharp_space_between_method_call_parameter_list_parentheses = false
132+
csharp_space_before_colon_in_inheritance_clause = true
133+
csharp_space_after_colon_in_inheritance_clause = true
134+
csharp_space_around_binary_operators = before_and_after
135+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
136+
csharp_space_between_method_call_name_and_opening_parenthesis = false
137+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
138+
139+
# Wrapping preferences
140+
csharp_preserve_single_line_blocks = true
141+
csharp_preserve_single_line_statements = true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
public static class LineUp
2+
{
3+
public static string Format(string name, int number) =>
4+
$"{name}, you are the {number}{Suffix(number)} customer we serve today. Thank you!";
5+
6+
private static string Suffix(int number)
7+
{
8+
int lastTwoDigits = number % 100;
9+
int lastDigit = number % 10;
10+
11+
if (lastTwoDigits >= 11 && lastTwoDigits <= 13)
12+
{
13+
return "th";
14+
}
15+
16+
return lastDigit switch
17+
{
18+
1 => "st",
19+
2 => "nd",
20+
3 => "rd",
21+
_ => "th",
22+
};
23+
}
24+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class {{ testClass }}
2+
{
3+
{{- for test in tests }}
4+
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
5+
public void {{ test.testMethod }}()
6+
{
7+
string expected = {{ test.expected | string.literal }};
8+
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.name | string.literal }}, {{ test.input.number }}));
9+
}
10+
{{ end -}}
11+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"authors": [
3+
"BNAndras"
4+
],
5+
"files": {
6+
"solution": [
7+
"LineUp.cs"
8+
],
9+
"test": [
10+
"LineUpTests.cs"
11+
],
12+
"example": [
13+
".meta/Example.cs"
14+
],
15+
"invalidator": [
16+
"LineUp.csproj"
17+
]
18+
},
19+
"blurb": "Help lining up customers at Yaʻqūb's Deli.",
20+
"source": "mk-mxp, based on previous work from Exercism contributors codedge and neenjaw",
21+
"source_url": "https://forum.exercism.org/t/new-exercise-ordinal-numbers/19147"
22+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[7760d1b8-4864-4db4-953b-0fa7c047dbc0]
13+
description = "format smallest non-exceptional ordinal numeral 4"
14+
15+
[e8b7c715-6baa-4f7b-8fb3-2fa48044ab7a]
16+
description = "format greatest single digit non-exceptional ordinal numeral 9"
17+
18+
[f370aae9-7ae7-4247-90ce-e8ff8c6934df]
19+
description = "format non-exceptional ordinal numeral 5"
20+
21+
[37f10dea-42a2-49de-bb92-0b690b677908]
22+
description = "format non-exceptional ordinal numeral 6"
23+
24+
[d8dfb9a2-3a1f-4fee-9dae-01af3600054e]
25+
description = "format non-exceptional ordinal numeral 7"
26+
27+
[505ec372-1803-42b1-9377-6934890fd055]
28+
description = "format non-exceptional ordinal numeral 8"
29+
30+
[8267072d-be1f-4f70-b34a-76b7557a47b9]
31+
description = "format exceptional ordinal numeral 1"
32+
33+
[4d8753cb-0364-4b29-84b8-4374a4fa2e3f]
34+
description = "format exceptional ordinal numeral 2"
35+
36+
[8d44c223-3a7e-4f48-a0ca-78e67bf98aa7]
37+
description = "format exceptional ordinal numeral 3"
38+
39+
[6c4f6c88-b306-4f40-bc78-97cdd583c21a]
40+
description = "format smallest two digit non-exceptional ordinal numeral 10"
41+
42+
[e257a43f-d2b1-457a-97df-25f0923fc62a]
43+
description = "format non-exceptional ordinal numeral 11"
44+
45+
[bb1db695-4d64-457f-81b8-4f5a2107e3f4]
46+
description = "format non-exceptional ordinal numeral 12"
47+
48+
[60a3187c-9403-4835-97de-4f10ebfd63e2]
49+
description = "format non-exceptional ordinal numeral 13"
50+
51+
[2bdcebc5-c029-4874-b6cc-e9bec80d603a]
52+
description = "format exceptional ordinal numeral 21"
53+
54+
[74ee2317-0295-49d2-baf0-d56bcefa14e3]
55+
description = "format exceptional ordinal numeral 62"
56+
57+
[b37c332d-7f68-40e3-8503-e43cbd67a0c4]
58+
description = "format exceptional ordinal numeral 100"
59+
60+
[0375f250-ce92-4195-9555-00e28ccc4d99]
61+
description = "format exceptional ordinal numeral 101"
62+
63+
[0d8a4974-9a8a-45a4-aca7-a9fb473c9836]
64+
description = "format non-exceptional ordinal numeral 112"
65+
66+
[06b62efe-199e-4ce7-970d-4bf73945713f]
67+
description = "format exceptional ordinal numeral 123"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public static class LineUp
2+
{
3+
public static string Format(string name, int number)
4+
{
5+
throw new NotImplementedException("You need to implement this method.");
6+
}
7+
}

0 commit comments

Comments
 (0)