Skip to content
Open
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
13 changes: 13 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,19 @@
],
"difficulty": 1
},
{
"slug": "line-up",
"name": "Line Up",
"uuid": "4fb5288a-e02f-4b5b-8565-5de43b600b8f",
"practices": [
"strings"
],
"prerequisites": [
"if-statements",
"strings"
],
"difficulty": 1
},
{
"slug": "gigasecond",
"name": "Gigasecond",
Expand Down
15 changes: 15 additions & 0 deletions exercises/Exercises.sln
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowerField", "practice\flo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Camicia", "practice\camicia\Camicia.csproj", "{637DEB61-9832-42B0-9907-0671611A92EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LineUp", "practice\line-up\LineUp.csproj", "{B9978244-5E52-4520-BFC6-FC81943794A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -2567,6 +2569,18 @@ Global
{637DEB61-9832-42B0-9907-0671611A92EB}.Release|x64.Build.0 = Release|Any CPU
{637DEB61-9832-42B0-9907-0671611A92EB}.Release|x86.ActiveCfg = Release|Any CPU
{637DEB61-9832-42B0-9907-0671611A92EB}.Release|x86.Build.0 = Release|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|x64.ActiveCfg = Debug|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|x64.Build.0 = Debug|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|x86.ActiveCfg = Debug|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Debug|x86.Build.0 = Debug|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|Any CPU.Build.0 = Release|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|x64.ActiveCfg = Release|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|x64.Build.0 = Release|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|x86.ActiveCfg = Release|Any CPU
{B9978244-5E52-4520-BFC6-FC81943794A9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2755,6 +2769,7 @@ Global
{2C37454E-8624-47B8-A09B-ADE201C2B04C} = {E276EF69-669A-43E0-88AC-8ABB17A9C026}
{88E165C6-5E27-4F48-942A-0D41A9A6326D} = {E276EF69-669A-43E0-88AC-8ABB17A9C026}
{637DEB61-9832-42B0-9907-0671611A92EB} = {E276EF69-669A-43E0-88AC-8ABB17A9C026}
{B9978244-5E52-4520-BFC6-FC81943794A9} = {E276EF69-669A-43E0-88AC-8ABB17A9C026}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AB4EA6C9-5461-4024-BDC7-2AE0C3A85CD1}
Expand Down
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.
141 changes: 141 additions & 0 deletions exercises/practice/line-up/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
###############################
# Core EditorConfig Options #
###############################

; This file is for unifying the coding style for different editors and IDEs.
; More information at:
; https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
; https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2017

root = true

[*]
indent_style = space

[LineUp.cs]
indent_size = 4

###############################
# .NET Coding Conventions #
###############################

# Organize usings
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = true

# this. preferences
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion

# Modifier preferences
dotnet_style_require_accessibility_modifiers = always:suggestion
dotnet_style_readonly_field = true:suggestion

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion

###############################
# Naming Conventions #
###############################

# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const

###############################
# C# Code Style Rules #
###############################

# var preferences
csharp_style_var_for_built_in_types = true:none
csharp_style_var_when_type_is_apparent = true:none
csharp_style_var_elsewhere = true:none

# Expression-bodied members
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion

# Pattern-matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion

# Null-checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion

# Expression-level preferences
csharp_prefer_braces = true:none
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

###############################
# C# Formatting Rules #
###############################

# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_between_query_expression_clauses = true

# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false

# Wrapping preferences
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
24 changes: 24 additions & 0 deletions exercises/practice/line-up/.meta/Example.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
public static class LineUp
{
public static string Format(string name, int number) =>
$"{name}, you are the {number}{Suffix(number)} customer we serve today. Thank you!";

private static string Suffix(int number)
{
int lastTwoDigits = number % 100;
int lastDigit = number % 10;

if (lastTwoDigits >= 11 && lastTwoDigits <= 13)
{
return "th";
}

return lastDigit switch
{
1 => "st",
2 => "nd",
3 => "rd",
_ => "th",
};
}
}
11 changes: 11 additions & 0 deletions exercises/practice/line-up/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class {{ testClass }}
{
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
string expected = {{ test.expected | string.literal }};
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.name | string.literal }}, {{ test.input.number }}));
}
{{ end -}}
}
22 changes: 22 additions & 0 deletions exercises/practice/line-up/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"authors": [
"BNAndras"
],
"files": {
"solution": [
"LineUp.cs"
],
"test": [
"LineUpTests.cs"
],
"example": [
".meta/Example.cs"
],
"invalidator": [
"LineUp.csproj"
]
},
"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"
}
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"
7 changes: 7 additions & 0 deletions exercises/practice/line-up/LineUp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public static class LineUp
{
public static string Format(string name, int number)
{
throw new NotImplementedException("You need to implement this method.");
}
}
22 changes: 22 additions & 0 deletions exercises/practice/line-up/LineUp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit.v3" Version="1.1.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1" />
<PackageReference Include="Exercism.Tests.xunit.v3" Version="0.1.0-beta1" />
</ItemGroup>

</Project>
Loading
Loading