primeiro commit com exercicios de Exercism realizados até esta data

This commit is contained in:
2026-10-17 22:10:27 +01:00
commit 58fccbe27a
708 changed files with 35038 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
{
"authors": [
"BNAndras"
],
"files": {
"solution": [
"line_up.py"
],
"test": [
"line_up_test.py"
],
"example": [
".meta/example.py"
]
},
"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"
}
+1
View File
@@ -0,0 +1 @@
{"track":"python","exercise":"line-up","id":"d0c2453a1ae5498a9727a6c50298a90a","url":"https://exercism.org/tracks/python/exercises/line-up","handle":"sanctushck","is_requester":true,"auto_approve":false}
+130
View File
@@ -0,0 +1,130 @@
# Help
## Running the tests
We use [pytest][pytest: Getting Started Guide] as our website test runner.
You will need to install `pytest` on your development machine if you want to run tests for the Python track locally.
You should also install the following `pytest` plugins:
- [pytest-cache][pytest-cache]
- [pytest-subtests][pytest-subtests]
Extended information can be found in our website [Python testing guide][Python track tests page].
### Running Tests
To run the included tests, navigate to the folder where the exercise is stored using `cd` in your terminal (_replace `<exercise-folder-location>` below with your path_).
Test files usually end in `_test.py`, and are the same tests that run on the website when a solution is uploaded.
Linux/MacOS
```bash
$ cd <path/to/exercise-folder-location>
```
Windows
```powershell
PS C:\Users\foobar> cd <path\to\exercise-folder-location>
```
<br>
Next, run the `pytest` command in your terminal, replacing `<exercise_test.py>` with the name of the test file:
Linux/MacOS
```bash
$ python3 -m pytest -o markers=task <exercise_test.py>
==================== 7 passed in 0.08s ====================
```
Windows
```powershell
PS C:\Users\foobar> py -m pytest -o markers=task <exercise_test.py>
==================== 7 passed in 0.08s ====================
```
### Common options
- `-o` : override default `pytest.ini` (_you can use this to avoid marker warnings_)
- `-v` : enable verbose output.
- `-x` : stop running tests on first failure.
- `--ff` : run failures from previous test before running other test cases.
For additional options, use `python3 -m pytest -h` or `py -m pytest -h`.
### Fixing warnings
If you do not use `pytest -o markers=task` when invoking `pytest`, you might receive a `PytestUnknownMarkWarning` for tests that use our new syntax:
```bash
PytestUnknownMarkWarning: Unknown pytest.mark.task - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/mark.html
```
To avoid typing `pytest -o markers=task` for every test you run, you can use a `pytest.ini` configuration file.
We have made one that can be downloaded from the top level of the Python track directory: [pytest.ini][pytest.ini].
You can also create your own `pytest.ini` file with the following content:
```ini
[pytest]
markers =
task: A concept exercise task.
```
Placing the `pytest.ini` file in the _root_ or _working_ directory for your Python track exercises will register the marks and stop the warnings.
More information on pytest marks can be found in the `pytest` documentation on [marking test functions][pytest: marking test functions with attributes] and the `pytest` documentation on [working with custom markers][pytest: working with custom markers].
Information on customizing pytest configurations can be found in the `pytest` documentation on [configuration file formats][pytest: configuration file formats].
### Extending your IDE or Code Editor
Many IDEs and code editors have built-in support for using `pytest` and other code quality tools.
Some community-sourced options can be found on our [Python track tools page][Python track tools page].
[Pytest: Getting Started Guide]: https://docs.pytest.org/en/latest/getting-started.html
[Python track tools page]: https://exercism.org/docs/tracks/python/tools
[Python track tests page]: https://exercism.org/docs/tracks/python/tests
[pytest-cache]:http://pythonhosted.org/pytest-cache/
[pytest-subtests]:https://github.com/pytest-dev/pytest-subtests
[pytest.ini]: https://github.com/exercism/python/blob/main/pytest.ini
[pytest: configuration file formats]: https://docs.pytest.org/en/6.2.x/customize.html#configuration-file-formats
[pytest: marking test functions with attributes]: https://docs.pytest.org/en/6.2.x/mark.html#raising-errors-on-unknown-marks
[pytest: working with custom markers]: https://docs.pytest.org/en/6.2.x/example/markers.html#working-with-custom-markers
## Submitting your solution
You can submit your solution using the `exercism submit line_up.py` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [Python track's documentation](https://exercism.org/docs/tracks/python)
- The [Python track's programming category on the forum](https://forum.exercism.org/c/programming/python)
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
Below are some resources for getting help if you run into trouble:
- [The PSF](https://www.python.org) hosts Python downloads, documentation, and community resources.
- [Python Community Forums](https://discuss.python.org/) help, PEP discussion, core Python committers, and more.
- [The Exercism Community on Discord](https://exercism.org/r/discord)
- [The Exercism Community Discussion Forums](https://forum.exercsim.org)
- [Python Community on Discord](https://pythondiscord.com/) is a very helpful and active community.
- [/r/learnpython/](https://www.reddit.com/r/learnpython/) is a subreddit designed for Python learners.
- [#python on Libera.chat](https://www.python.org/community/irc/) this is where the core developers for the language hang out and get work done.
- [Free Code Camp Community Forums](https://forum.freecodecamp.org/)
- [Pythontutor](http://pythontutor.com/) for stepping through small code snippets visually.
Additionally, [StackOverflow](http://stackoverflow.com/questions/tagged/python) is a good spot to search for your problem/question to see if it has been answered already.
If not - you can always [ask](https://stackoverflow.com/help/how-to-ask) or [answer](https://stackoverflow.com/help/how-to-answer) someone else's question.
+42
View File
@@ -0,0 +1,42 @@
# Line Up
Welcome to Line Up on Exercism's Python Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## 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.
## 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
## Source
### Created by
- @BNAndras
### Based on
mk-mxp, based on previous work from Exercism contributors codedge and neenjaw - https://forum.exercism.org/t/new-exercise-ordinal-numbers/19147
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
def line_up(name, number):
ordinal_sufix: str = ""
# for the special case when the tenths of the number is between 10 and 20
# the ordinal of all numbers are equal to 'th'
if number % 100 > 10 and number % 100 < 20:
return f"{name}, you are the {number}th customer we serve today. Thank you!"
match number % 10:
case 1:
ordinal_sufix = "st"
case 2:
ordinal_sufix = "nd"
case 3:
ordinal_sufix = "rd"
case _:
ordinal_sufix = "th"
return f"{name}, you are the {number}{ordinal_sufix} customer we serve today. Thank you!"
+173
View File
@@ -0,0 +1,173 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/line-up/canonical-data.json
# File last updated on 2026-09-30
import unittest
from line_up import (
line_up,
)
class LineUpTest(unittest.TestCase):
def test_format_smallest_non_exceptional_ordinal_numeral_4(self):
self.assertEqual(
line_up("Gianna", 4),
"Gianna, you are the 4th customer we serve today. Thank you!",
)
def test_format_greatest_single_digit_non_exceptional_ordinal_numeral_9(self):
self.assertEqual(
line_up("Maarten", 9),
"Maarten, you are the 9th customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_5(self):
self.assertEqual(
line_up("Petronila", 5),
"Petronila, you are the 5th customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_6(self):
self.assertEqual(
line_up("Attakullakulla", 6),
"Attakullakulla, you are the 6th customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_7(self):
self.assertEqual(
line_up("Kate", 7),
"Kate, you are the 7th customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_8(self):
self.assertEqual(
line_up("Maximiliano", 8),
"Maximiliano, you are the 8th customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_1(self):
self.assertEqual(
line_up("Mary", 1),
"Mary, you are the 1st customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_2(self):
self.assertEqual(
line_up("Haruto", 2),
"Haruto, you are the 2nd customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_3(self):
self.assertEqual(
line_up("Henriette", 3),
"Henriette, you are the 3rd customer we serve today. Thank you!",
)
def test_format_smallest_two_digit_non_exceptional_ordinal_numeral_10(self):
self.assertEqual(
line_up("Alvarez", 10),
"Alvarez, you are the 10th customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_11(self):
self.assertEqual(
line_up("Jacqueline", 11),
"Jacqueline, you are the 11th customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_12(self):
self.assertEqual(
line_up("Juan", 12),
"Juan, you are the 12th customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_13(self):
self.assertEqual(
line_up("Patricia", 13),
"Patricia, you are the 13th customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_21(self):
self.assertEqual(
line_up("Washi", 21),
"Washi, you are the 21st customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_22_ending_in_nd_even_though_it_is_a_multiple_of_11(
self,
):
self.assertEqual(
line_up("Ingrid", 22),
"Ingrid, you are the 22nd customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_33_ending_in_rd_even_though_it_is_a_multiple_of_11(
self,
):
self.assertEqual(
line_up("Mario", 33),
"Mario, you are the 33rd customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_52_ending_in_nd_even_though_it_is_a_multiple_of_13(
self,
):
self.assertEqual(
line_up("Quentin", 52),
"Quentin, you are the 52nd customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_62(self):
self.assertEqual(
line_up("Nayra", 62),
"Nayra, you are the 62nd customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_72_ending_in_nd_even_though_it_is_a_multiple_of_12(
self,
):
self.assertEqual(
line_up("Ugo", 72),
"Ugo, you are the 72nd customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_91_ending_in_st_even_though_it_is_a_multiple_of_13(
self,
):
self.assertEqual(
line_up("Boris", 91),
"Boris, you are the 91st customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_100(self):
self.assertEqual(
line_up("John", 100),
"John, you are the 100th customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_101(self):
self.assertEqual(
line_up("Zeinab", 101),
"Zeinab, you are the 101st customer we serve today. Thank you!",
)
def test_format_non_exceptional_ordinal_numeral_112(self):
self.assertEqual(
line_up("Knud", 112),
"Knud, you are the 112th customer we serve today. Thank you!",
)
def test_format_exceptional_ordinal_numeral_123(self):
self.assertEqual(
line_up("Yma", 123),
"Yma, you are the 123rd customer we serve today. Thank you!",
)
def test_format_large_number_972_ending_in_nd_even_though_it_is_a_multiple_of_12(
self,
):
self.assertEqual(
line_up("Elias", 972),
"Elias, you are the 972nd customer we serve today. Thank you!",
)