From 1ff9c0549436a39f4036df40333d8aa916ae1c6a Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Sat, 26 Nov 2022 20:17:04 +0100 Subject: [PATCH 01/19] add config --- concepts/sequences/.meta/config.json | 2 +- config.json | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/concepts/sequences/.meta/config.json b/concepts/sequences/.meta/config.json index 9b9e8da5a9..3bf2b514cc 100644 --- a/concepts/sequences/.meta/config.json +++ b/concepts/sequences/.meta/config.json @@ -1,5 +1,5 @@ { "blurb": "TODO: add blurb for this concept", - "authors": ["bethanyg", "cmccandless"], + "authors": ["bethanyg", "meatball133"], "contributors": [] } diff --git a/config.json b/config.json index 61cc1285f0..9fcce5b9c1 100644 --- a/config.json +++ b/config.json @@ -144,6 +144,14 @@ "prerequisites": ["loops", "lists", "tuples", "dicts"], "status": "wip" }, + { + "slug": "thallias-tram-troubles", + "name": "Thallias Tram Troubles", + "uuid": "d1cf6301-d8fe-47a8-95a8-5ec0765aef7b", + "concepts": ["sequence"], + "prerequisites": ["loops", "lists", "tuples", "dicts", "unpacking-and-multiple-assignment"], + "status": "wip" + }, { "slug": "cater-waiter", "name": "Cater Waiter", From 6542fca28208b084ef2808dc3567a07f8c5b705f Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Sat, 26 Nov 2022 20:19:52 +0100 Subject: [PATCH 02/19] fix config --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 9fcce5b9c1..523dc6b4c8 100644 --- a/config.json +++ b/config.json @@ -141,7 +141,7 @@ "name": "Locomotive Engineer", "uuid": "e1b8b9c9-21c3-47b1-b645-5938b3110c78", "concepts": ["unpacking-and-multiple-assignment"], - "prerequisites": ["loops", "lists", "tuples", "dicts"], + "prerequisites": ["loops", "lists", "tuples", "dicts", "unpacking-and-multiple-assignment"], "status": "wip" }, { @@ -149,7 +149,7 @@ "name": "Thallias Tram Troubles", "uuid": "d1cf6301-d8fe-47a8-95a8-5ec0765aef7b", "concepts": ["sequence"], - "prerequisites": ["loops", "lists", "tuples", "dicts", "unpacking-and-multiple-assignment"], + "prerequisites": ["loops", "lists", "tuples", "dicts"], "status": "wip" }, { From 6b25d0ec728cc8ab66de006c83851152546a936f Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Sun, 27 Nov 2022 16:02:25 +0100 Subject: [PATCH 03/19] Add reverse sequence to about --- concepts/sequences/about.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index c628150d56..dbd84dc8a9 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -1,2 +1,15 @@ -#TODO: Add about for this concept. +## Reverse a sequence +Using slicing with steps allows reversing a sequence. +That is because we can use a negative step to start at the end of the sequence and move backwards. +This is a very common operation. + +```python +>>> numbers = [1, 2, 3, 4, 5] +>>> numbers[::-1] +[5, 4, 3, 2, 1] + +>>> name = "Delizald" +>>> name[::-1] +'dlazileD' +``` From 81d47250a6d37a85dfc8722956e89a397ac4a3fe Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Sun, 27 Nov 2022 16:13:26 +0100 Subject: [PATCH 04/19] Added in --- concepts/sequences/about.md | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index dbd84dc8a9..a28f3e276d 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -1,3 +1,49 @@ +## Sequence operations + +### In operator + +`In` checks if a sequence contains a value. +It returns `True` if the value is found, and `False` otherwise. + +```python +>>> 1 in [1, 2, 3] +True + +>>> 4 in [1, 2, 3] +False + +>>> "a" in "abc" +True + +>>> "d" in "abc" +False +``` + +It does not check if a value is in a sequence within a sequence. + +```python +>>> "a" in ["abc", "def"] +False + +>>> 1 in [[1, 2, 3], [4, 5, 6]] +False +``` + +### Not in operator + +`Not in` checks if a sequence does not contain a value. +It does the reverse of `in`. + +```python +>>> 1 not in [1, 2, 3] +False + +>>> 4 not in [1, 2, 3] +True +``` + +## Get the length of a sequence + ## Reverse a sequence Using slicing with steps allows reversing a sequence. From 23a1a735fb2aa9dac5d5b7740b208134e11ca8b7 Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Sun, 27 Nov 2022 18:20:51 +0100 Subject: [PATCH 05/19] fix --- concepts/sequences/about.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index a28f3e276d..ddf520df49 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -47,7 +47,7 @@ True ## Reverse a sequence Using slicing with steps allows reversing a sequence. -That is because we can use a negative step to start at the end of the sequence and move backwards. +That is because we can use a negative step to start at the end of the sequence and walk backwards. This is a very common operation. ```python From 3211a01533b8aac59c27215eca750f89d8bd066a Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Sun, 27 Nov 2022 19:29:17 +0100 Subject: [PATCH 06/19] Added filles for tram exercise and fixes --- concepts/sequences/about.md | 20 +++++- config.json | 2 +- .../thallias-tram-troubles/.docs/hints.md | 1 + .../.docs/instructions.md | 1 + .../.docs/introduction.md | 1 + .../thallias-tram-troubles/.meta/config.json | 10 +++ .../thallias-tram-troubles/.meta/design.md | 69 +++++++++++++++++++ .../thallias-tram-troubles/.meta/exemplar.py | 48 +++++++++++++ .../thallias_tram_troubles.py | 1 + .../thallias_tram_troubles_test.py | 1 + 10 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 exercises/concept/thallias-tram-troubles/.docs/hints.md create mode 100644 exercises/concept/thallias-tram-troubles/.docs/instructions.md create mode 100644 exercises/concept/thallias-tram-troubles/.docs/introduction.md create mode 100644 exercises/concept/thallias-tram-troubles/.meta/config.json create mode 100644 exercises/concept/thallias-tram-troubles/.meta/design.md create mode 100644 exercises/concept/thallias-tram-troubles/.meta/exemplar.py create mode 100644 exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py create mode 100644 exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index ddf520df49..03870c403a 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -1,8 +1,26 @@ +# Sequences + +A sequence is an ordered, indexable collection of items. +All sequence types support a common set of operations that include `in`/`not in`, `min`/`max`, `.index`, `.count` and `.len`. `lists` support additional mutable operations such as [slice assignment][], .append, `.extend`, `.reverse`, and `.copy`. +All sequences can be iterated over using the `for item in ` construct. +`for index, item in enumerate()` can be used when both the element index and the element value are needed. +Pythons `list`, `tuple`, `str`, `byte`, and `range` types all belong to this wider sequence type. +In the case of `str`, the “collection” is made up of unicode code points. +In the case of `byte`, bytes. +Ranges are “collections” of numbers conforming to a `start:stop:step` rule. + +Sequences can be copied in whole or in part via slice notation. +copy an object via the "full" slice `[:]` + +e = "I am a happy person" + +end = e[-6:] + ## Sequence operations ### In operator -`In` checks if a sequence contains a value. +`in` checks if a sequence contains a value. It returns `True` if the value is found, and `False` otherwise. ```python diff --git a/config.json b/config.json index 523dc6b4c8..009aede5c3 100644 --- a/config.json +++ b/config.json @@ -148,7 +148,7 @@ "slug": "thallias-tram-troubles", "name": "Thallias Tram Troubles", "uuid": "d1cf6301-d8fe-47a8-95a8-5ec0765aef7b", - "concepts": ["sequence"], + "concepts": ["sequences"], "prerequisites": ["loops", "lists", "tuples", "dicts"], "status": "wip" }, diff --git a/exercises/concept/thallias-tram-troubles/.docs/hints.md b/exercises/concept/thallias-tram-troubles/.docs/hints.md new file mode 100644 index 0000000000..b5296c3664 --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/.docs/hints.md @@ -0,0 +1 @@ +# Hints diff --git a/exercises/concept/thallias-tram-troubles/.docs/instructions.md b/exercises/concept/thallias-tram-troubles/.docs/instructions.md new file mode 100644 index 0000000000..63fd98ab00 --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/.docs/instructions.md @@ -0,0 +1 @@ +# Instructions diff --git a/exercises/concept/thallias-tram-troubles/.docs/introduction.md b/exercises/concept/thallias-tram-troubles/.docs/introduction.md new file mode 100644 index 0000000000..b15fe77524 --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/.docs/introduction.md @@ -0,0 +1 @@ +#todo diff --git a/exercises/concept/thallias-tram-troubles/.meta/config.json b/exercises/concept/thallias-tram-troubles/.meta/config.json new file mode 100644 index 0000000000..3909c27771 --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/.meta/config.json @@ -0,0 +1,10 @@ +{ + "blurb": "todo", + "icon": "tracks-on-tracks-on-tracks", + "authors": ["meatball133","BethanyG"], + "files": { + "solution": ["thallias_tram_troubles.py"], + "test": ["thallias_tram_troubles_test.py"], + "exemplar": [".meta/exemplar.py"] + } +} diff --git a/exercises/concept/thallias-tram-troubles/.meta/design.md b/exercises/concept/thallias-tram-troubles/.meta/design.md new file mode 100644 index 0000000000..af4109a9b0 --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/.meta/design.md @@ -0,0 +1,69 @@ +# Design + +## TODO: Add introduction for this concept. +## Goal + +This concept exercise is meant to teach an understanding/use of `unpacking` and the `*` (splat) and `**` (double splat) operators in Python. + +
+ +## Learning objectives + +- Understand/use `unpacking` through the use of `*` and `**` _prefix_ operators in various scenarios + - `*` and `**` as _prefixes_ ..... not to be confused with `*` (_multiply_) and `**` (_exponentiation_) as _infix_, or mathematical operators (**consider a link in the links doc or a mention in dig deeper.**) + - ~~what happens in the process of "unpacking" - form, ordering, & iteration~~ (this will go in a **dig deeper** or the link docs.) + - use in arguments to `functions` + - use in argument _capture_ for `functions` (_aka passing an arbitrary number of arguments -- *args * & **kwargs_) + - ~~use in defining `keyword only arguments`~~ (_topic moved to arguments exercise_). + - use in iterable (_mainly `tuple` and `list`_) unpacking & packing + - use in `dict` unpacking & packing +- Understand/use `unpacking` via `multiple assignment` + - using `multiple assignment ` in place of `indexing` + - using `multiple assigment` + `*` in place of `slicing` + - ~~using "list-like" syntax & "tuple-like" syntax~~ + - unpacking plus "leftovers" via `*` +- Differences between straight `multiple assignment` and `*` & `**` +- Deep unpacking + + +## Concepts + +- `unpacking` +- `unpacking generalizations` +- `multiple assignment` + + +## Topics that are Out of scope + +- `classes` +- `comprehensions` +- `comprehensions` in `lambdas` +- `map()`, `filter()` or `functools.reduce()` in a `comprehension` +- `function-arguments` beyond explaining briefly how `*`, `**` work in function arguments. +- `functools` beyond `functools.reduce()`(_this will get its own exercise_) +- `generators` +- using an `assignment expression` or "walrus" operator (`:=`) alone or in a `lambda` + + +## Prerequisites + +- `basics` +- `bools` +- `comparisons` +- `dicts` +- `lists` +- `numbers` +- `strings` +- `tuples` + + +## Representer + +This exercise does not require any specific logic to be added to the [representer][representer] + +## Analyzer + +This exercise does not require any specific logic to be added to the [analyzer][analyzer]. + +[analyzer]: https://github.com/exercism/python-analyzer +[representer]: https://github.com/exercism/python-representer \ No newline at end of file diff --git a/exercises/concept/thallias-tram-troubles/.meta/exemplar.py b/exercises/concept/thallias-tram-troubles/.meta/exemplar.py new file mode 100644 index 0000000000..861cce2fde --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/.meta/exemplar.py @@ -0,0 +1,48 @@ +"""Functions which helps the locomotive engineer to keep track of the train.""" + + +def get_list_of_wagons(*args): + return list(args) + + +def fix_list_of_wagons(each_wagons_id, missing_wagons): + """Fix the list of wagons. + + :param each_wagons_id: list - the list of wagons. + :param missing_wagons: list - the list of missing wagons. + :return: list - list of wagons. + """ + first, second, loctomotive, *rest = each_wagons_id + return [loctomotive, *missing_wagons, *rest, first, second] + + +def add_missing_stops(route, **kwargs): + """Add missing stops to route dict. + + :param route: dict - the dict of routing information. + :param **kwards: arbitrary number of stops. + :return: dict - updated route dictionary. + """ + return {**route, "stops": list(kwargs.values())} + + +def extend_route_information(route, more_route_information): + """Extend the route information with the more_route_information. + + :param route: dict - the route information. + :param more_route_information: dict - extra route information. + :return: dict - extended route information. + """ + return {**route, **more_route_information} + + +def fix_wagon_depot(wagons_rows): + """Fix the list of rows of wagons. + + :param wagons_rows: list[tuple] - the list of rows of wagons. + :return: list[tuple] - list of rows of wagons. + """ + + [*row_one], [*row_two], [*row_three] = zip(*wagons_rows) + + return [row_one, row_two, row_three] diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py new file mode 100644 index 0000000000..8b68f79948 --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py @@ -0,0 +1 @@ +#todo \ No newline at end of file diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py new file mode 100644 index 0000000000..8b68f79948 --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py @@ -0,0 +1 @@ +#todo \ No newline at end of file From b0a9db2a54f352170d3d1a1d98da76166060d240 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Sun, 27 Nov 2022 23:38:31 -0800 Subject: [PATCH 07/19] First Pass Sequences A first pass for About.md intro and concept intro. --- concepts/sequences/.meta/config.json | 2 +- concepts/sequences/about.md | 20 +++++++++---------- concepts/sequences/introduction.md | 16 ++++++++++++++- .../thallias-tram-troubles/.meta/config.json | 4 ++-- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/concepts/sequences/.meta/config.json b/concepts/sequences/.meta/config.json index 3bf2b514cc..0399a1c47c 100644 --- a/concepts/sequences/.meta/config.json +++ b/concepts/sequences/.meta/config.json @@ -1,5 +1,5 @@ { - "blurb": "TODO: add blurb for this concept", + "blurb": "A sequence is an ordered, indexable collection of items. All sequence types support a common set of operations, with lists supporting additional mutable operations. All sequences can be indexed into with bracket notation, copied in whole or in part using slice notation, and iterated over using the \"for item in \".", "authors": ["bethanyg", "meatball133"], "contributors": [] } diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index 03870c403a..de03891808 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -1,22 +1,20 @@ # Sequences A sequence is an ordered, indexable collection of items. -All sequence types support a common set of operations that include `in`/`not in`, `min`/`max`, `.index`, `.count` and `.len`. `lists` support additional mutable operations such as [slice assignment][], .append, `.extend`, `.reverse`, and `.copy`. -All sequences can be iterated over using the `for item in ` construct. -`for index, item in enumerate()` can be used when both the element index and the element value are needed. +All sequence types support a common set of operations that include `in`/`not in`, `min()`/`max()`, `.index`, `.count()` and `.len()`. +`lists` support additional mutable operations such as [slice assignment][], `.append()`, `.extend()`, `.reverse()`, and `.copy()`. + +All sequences can be indexed into using `[]`, copied in whole or in part using `[::]`(_a full copy can be made with `[:]`), and iterated over using the `for item in ` construct. + `for index, item in enumerate()` can be used when both the element index and the element value are needed. + + Pythons `list`, `tuple`, `str`, `byte`, and `range` types all belong to this wider sequence type. In the case of `str`, the “collection” is made up of unicode code points. -In the case of `byte`, bytes. +In the case of `byte`, bytes. Ranges are “collections” of numbers conforming to a `start:stop:step` rule. -Sequences can be copied in whole or in part via slice notation. -copy an object via the "full" slice `[:]` - -e = "I am a happy person" - -end = e[-6:] -## Sequence operations +## Common Sequence operations ### In operator diff --git a/concepts/sequences/introduction.md b/concepts/sequences/introduction.md index fcde74642c..6c090cbde2 100644 --- a/concepts/sequences/introduction.md +++ b/concepts/sequences/introduction.md @@ -1,2 +1,16 @@ -#TODO: Add introduction for this concept. +# Sequences + +A sequence is an ordered, indexable collection of items. +All sequence types support a common set of operations that include `in`/`not in`, `min()`/`max()`, `.index`, `.count()` and `.len()`. +`lists` support additional mutable operations such as [slice assignment][], `.append()`, `.extend()`, `.reverse()`, and `.copy()`. + +All sequences can be indexed into using `[]`, copied in whole or in part using `[::]`(_a full copy can be made with `[:]`), and iterated over using the `for item in ` construct. + `for index, item in enumerate()` can be used when both the element index and the element value are needed. + + +Pythons `list`, `tuple`, `str`, `byte`, and `range` types all belong to this wider sequence type. +In the case of `str`, the “collection” is made up of unicode code points. +In the case of `byte`, bytes. +Ranges are “collections” of numbers conforming to a `start:stop:step` rule. + diff --git a/exercises/concept/thallias-tram-troubles/.meta/config.json b/exercises/concept/thallias-tram-troubles/.meta/config.json index 3909c27771..e5bd8afcac 100644 --- a/exercises/concept/thallias-tram-troubles/.meta/config.json +++ b/exercises/concept/thallias-tram-troubles/.meta/config.json @@ -3,8 +3,8 @@ "icon": "tracks-on-tracks-on-tracks", "authors": ["meatball133","BethanyG"], "files": { - "solution": ["thallias_tram_troubles.py"], - "test": ["thallias_tram_troubles_test.py"], + "solution": ["sequences.py"], + "test": ["sequences_test.py"], "exemplar": [".meta/exemplar.py"] } } From 77436e0df1023f67478cae7e9ca60473dd57cc56 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Sun, 27 Nov 2022 23:57:22 -0800 Subject: [PATCH 08/19] Renamed Stub and Test files un-breaking the CI... --- .../{thallias_tram_troubles.py => sequences.py} | 0 .../{thallias_tram_troubles_test.py => sequences_test.py} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename exercises/concept/thallias-tram-troubles/{thallias_tram_troubles.py => sequences.py} (100%) rename exercises/concept/thallias-tram-troubles/{thallias_tram_troubles_test.py => sequences_test.py} (100%) diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py b/exercises/concept/thallias-tram-troubles/sequences.py similarity index 100% rename from exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py rename to exercises/concept/thallias-tram-troubles/sequences.py diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py b/exercises/concept/thallias-tram-troubles/sequences_test.py similarity index 100% rename from exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py rename to exercises/concept/thallias-tram-troubles/sequences_test.py From b160fce742bd0fe7310cd5a908ad889efd4418c5 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Mon, 28 Nov 2022 00:05:36 -0800 Subject: [PATCH 09/19] More CI fixes --- exercises/concept/thallias-tram-troubles/sequences.py | 1 - .../concept/thallias-tram-troubles/sequences_test.py | 1 - .../thallias-tram-troubles/thallias_tram_troubles.py | 1 + .../thallias-tram-troubles/thallias_tram_troubles_test.py | 8 ++++++++ 4 files changed, 9 insertions(+), 2 deletions(-) delete mode 100644 exercises/concept/thallias-tram-troubles/sequences.py delete mode 100644 exercises/concept/thallias-tram-troubles/sequences_test.py create mode 100644 exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py create mode 100644 exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py diff --git a/exercises/concept/thallias-tram-troubles/sequences.py b/exercises/concept/thallias-tram-troubles/sequences.py deleted file mode 100644 index 8b68f79948..0000000000 --- a/exercises/concept/thallias-tram-troubles/sequences.py +++ /dev/null @@ -1 +0,0 @@ -#todo \ No newline at end of file diff --git a/exercises/concept/thallias-tram-troubles/sequences_test.py b/exercises/concept/thallias-tram-troubles/sequences_test.py deleted file mode 100644 index 8b68f79948..0000000000 --- a/exercises/concept/thallias-tram-troubles/sequences_test.py +++ /dev/null @@ -1 +0,0 @@ -#todo \ No newline at end of file diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py new file mode 100644 index 0000000000..503fa1da06 --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py @@ -0,0 +1 @@ +#TODO \ No newline at end of file diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py new file mode 100644 index 0000000000..a29993f26c --- /dev/null +++ b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py @@ -0,0 +1,8 @@ +import unittest +import pytest + + +class ThalliasTramTroublesTest(unittest.TestCase): + + pass + From 97b9f1589fd28ec2c0a187b6062eafd2853ef2bb Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Tue, 6 Dec 2022 20:37:08 +0100 Subject: [PATCH 10/19] progress --- concepts/sequences/about.md | 78 +++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 8 deletions(-) diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index de03891808..bb4401d3bb 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -1,19 +1,17 @@ # Sequences A sequence is an ordered, indexable collection of items. -All sequence types support a common set of operations that include `in`/`not in`, `min()`/`max()`, `.index`, `.count()` and `.len()`. +All sequence types support a common set of operations that include `in`/`not in`, `min()`/`max()`, `.index`, `.count()` and `.len()`. `lists` support additional mutable operations such as [slice assignment][], `.append()`, `.extend()`, `.reverse()`, and `.copy()`. -All sequences can be indexed into using `[]`, copied in whole or in part using `[::]`(_a full copy can be made with `[:]`), and iterated over using the `for item in ` construct. - `for index, item in enumerate()` can be used when both the element index and the element value are needed. - +All sequences can be indexed into using `[]`, copied in whole or in part using `[::]`(\_a full copy can be made with `[:]`), and iterated over using the `for item in ` construct. +`for index, item in enumerate()` can be used when both the element index and the element value are needed. Pythons `list`, `tuple`, `str`, `byte`, and `range` types all belong to this wider sequence type. In the case of `str`, the “collection” is made up of unicode code points. -In the case of `byte`, bytes. +In the case of `byte`, bytes. Ranges are “collections” of numbers conforming to a `start:stop:step` rule. - ## Common Sequence operations ### In operator @@ -58,9 +56,73 @@ False True ``` -## Get the length of a sequence +### Get the length of a sequence + +`len()` gives the length of a sequence. + +```python +>>> len([1, 2, 3]) +3 + +>>> len((1, 2, 3)) +3 + +>>> len("abc") +3 +``` + +### min() and max() + +`min()` gives the minimum value in a sequence. + +```python +>>> min([1, 2, 3]) +1 + +>>> min("abc") +'a' +``` + +`max()` gives the maximum value in a sequence. + +```python +>>> max([1, 2, 3]) +3 + +>>> max("abc") +'c' +``` + +Using `max()/min()` on an empty sequence will raise a `ValueError`. + +```python +>>> max([]) + +Traceback (most recent call last): + File "c:\sequence.py", line 3, in + print(max([])) + ^^^^^^^ +ValueError: max() arg is an empty sequence +``` + +Using `min()/max()` on a sequence that includes a number and a `string` will raise a `TypeError`. + +```python +>>> max([1, 2, 3, "a"]) + +Traceback (most recent call last): + File "c:\sequence.py", line 3, in + print(max([1, 2, 3, "a"])) + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +TypeError: '>' not supported between instances of 'str' and 'int' +``` + +```exercism/caution +Using `max()/max()` on an `string` is tricky since it compares via acsii values. +Therefore when dealing with characters outside of the english alphabet, the result may not be what you expect. +``` -## Reverse a sequence +### Reverse a sequence Using slicing with steps allows reversing a sequence. That is because we can use a negative step to start at the end of the sequence and walk backwards. From 69c861e5a5ecb86de5bec95384d7ac38f92b0253 Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Tue, 6 Dec 2022 22:02:02 +0100 Subject: [PATCH 11/19] progress --- concepts/sequences/about.md | 44 ++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index bb4401d3bb..d66f94c02f 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -2,14 +2,14 @@ A sequence is an ordered, indexable collection of items. All sequence types support a common set of operations that include `in`/`not in`, `min()`/`max()`, `.index`, `.count()` and `.len()`. -`lists` support additional mutable operations such as [slice assignment][], `.append()`, `.extend()`, `.reverse()`, and `.copy()`. +`lists` and `bytearray` support additional mutable operations such as [slice assignment][], `.append()`, `.extend()`, `.reverse()`, and `.copy()`. All sequences can be indexed into using `[]`, copied in whole or in part using `[::]`(\_a full copy can be made with `[:]`), and iterated over using the `for item in ` construct. `for index, item in enumerate()` can be used when both the element index and the element value are needed. -Pythons `list`, `tuple`, `str`, `byte`, and `range` types all belong to this wider sequence type. +Pythons `list`, `tuple`, `str`, `bytes`, `bytearray` and `range` types all belong to this wider sequence type. In the case of `str`, the “collection” is made up of unicode code points. -In the case of `byte`, bytes. +In the case of `bytes`, bytes. Ranges are “collections” of numbers conforming to a `start:stop:step` rule. ## Common Sequence operations @@ -71,8 +71,15 @@ True 3 ``` +!!! Add that a nested sequence will not return the count of elements within sequences + ### min() and max() +```exercism/caution +Using `max()/max()` on an `string` is tricky since it compares via unicode code point value. +Therefore when dealing with characters outside of the English alphabet, the result may not be what you expect. +``` + `min()` gives the minimum value in a sequence. ```python @@ -117,11 +124,6 @@ Traceback (most recent call last): TypeError: '>' not supported between instances of 'str' and 'int' ``` -```exercism/caution -Using `max()/max()` on an `string` is tricky since it compares via acsii values. -Therefore when dealing with characters outside of the english alphabet, the result may not be what you expect. -``` - ### Reverse a sequence Using slicing with steps allows reversing a sequence. @@ -137,3 +139,29 @@ This is a very common operation. >>> name[::-1] 'dlazileD' ``` + +NOTES: + +Time table, tickets, ads. +Models of trams + +```python + +def time_table(table_of_time, week_day, start, stop): + return table_of_time[week_day][start:stop] + +print(time_table(("8:00", "9:00"),["8:00", "9:00"] )) +``` + +Fastest route (last exercise) + +Fewest stops or transfers + +Ad function + +`min()`/`max()`, yes +`.index`, yes +`.count()`, maybe +`.len()`, maybe +`slicing`, yes +`slice assignment` From fe05503096f2edd8dc2208b6687b7419662da519 Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Sun, 11 Dec 2022 23:56:21 +0100 Subject: [PATCH 12/19] Started on exercise --- concepts/sequences/about.md | 2 +- .../thallias-tram-troubles/.meta/exemplar.py | 55 +++++-------------- .../thallias_tram_troubles.py | 47 +++++++++++++++- 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index d66f94c02f..19dd09189b 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -164,4 +164,4 @@ Ad function `.count()`, maybe `.len()`, maybe `slicing`, yes -`slice assignment` +`slice assignment`, yes diff --git a/exercises/concept/thallias-tram-troubles/.meta/exemplar.py b/exercises/concept/thallias-tram-troubles/.meta/exemplar.py index 861cce2fde..89f9782d06 100644 --- a/exercises/concept/thallias-tram-troubles/.meta/exemplar.py +++ b/exercises/concept/thallias-tram-troubles/.meta/exemplar.py @@ -1,48 +1,21 @@ -"""Functions which helps the locomotive engineer to keep track of the train.""" +def time_table_for_a_weekday(table_of_time, week_day): + """Get the time table for a weekday. - -def get_list_of_wagons(*args): - return list(args) - - -def fix_list_of_wagons(each_wagons_id, missing_wagons): - """Fix the list of wagons. - - :param each_wagons_id: list - the list of wagons. - :param missing_wagons: list - the list of missing wagons. - :return: list - list of wagons. + :parm table_of_time: sequence[sequence] - sequence of time tables. + :parm week_day: integer - the number of the weekday. + :return: sequence - sequence of timetables within a weekday . """ - first, second, loctomotive, *rest = each_wagons_id - return [loctomotive, *missing_wagons, *rest, first, second] + return table_of_time[week_day] -def add_missing_stops(route, **kwargs): - """Add missing stops to route dict. +def time_table_for_a_specific_range(table_of_time, week_day, start, stop): + """Get the a slice of time table for a weekday. - :param route: dict - the dict of routing information. - :param **kwards: arbitrary number of stops. - :return: dict - updated route dictionary. + :parm table_of_time: sequence[sequence] - sequence of time tables. + :parm week_day: integer - the number of the weekday. + :parm start: integer - the start of the slice. + :parm stop: integer - the end of the slice. + :return: sequence - slice of timetables within a weekday . """ - return {**route, "stops": list(kwargs.values())} - - -def extend_route_information(route, more_route_information): - """Extend the route information with the more_route_information. - - :param route: dict - the route information. - :param more_route_information: dict - extra route information. - :return: dict - extended route information. - """ - return {**route, **more_route_information} - - -def fix_wagon_depot(wagons_rows): - """Fix the list of rows of wagons. - - :param wagons_rows: list[tuple] - the list of rows of wagons. - :return: list[tuple] - list of rows of wagons. - """ - - [*row_one], [*row_two], [*row_three] = zip(*wagons_rows) + return table_of_time[week_day][start:stop] - return [row_one, row_two, row_three] diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py index 503fa1da06..aeed8013b3 100644 --- a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py +++ b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles.py @@ -1 +1,46 @@ -#TODO \ No newline at end of file +def time_table_for_a_weekday(table_of_time, week_day): + """Get the time table for a weekday. + + :parm table_of_time: sequence[sequence[sequence]] - sequence of time tables. + :parm week_day: integer - the number of the weekday. + :return: sequence - sequence of timetables within a weekday . + """ + pass + + +def time_table_for_a_specific_range(table_of_time, week_day, start, stop): + """Get the a slice of time table for a weekday. + + :parm table_of_time: sequence[sequence[sequence]] - sequence of time tables. + :parm week_day: integer - the number of the weekday. + :parm start: integer - the start of the slice. + :parm stop: integer - the end of the slice. + :return: sequence - slice of timetables within a weekday . + """ + pass + + +def fewest_transfers(routes): + """Find the fewest transfers between two stops. + + :parm route: sequence[sequence] - sequence of time tables. + :return: sequence - the fewest transfers. + """ + pass + + +def fastest_route(): + """Find the fastest route between two stops. + + :parm ... + :return: sequence - the fastest route. + """ + pass + +def update___(): + """Update the ... . + + :parm ... + :return: ... + """ + pass From 9f7cf3f37bca1bf413419369f0cbb6d7119d6bf8 Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Mon, 12 Dec 2022 00:00:38 +0100 Subject: [PATCH 13/19] Update about.md --- concepts/sequences/about.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/concepts/sequences/about.md b/concepts/sequences/about.md index 19dd09189b..14a8744ca8 100644 --- a/concepts/sequences/about.md +++ b/concepts/sequences/about.md @@ -153,6 +153,13 @@ def time_table(table_of_time, week_day, start, stop): print(time_table(("8:00", "9:00"),["8:00", "9:00"] )) ``` +```python +def time_table(table_of_time, week_day, start, stop): + return table_of_time[week_day][start:stop] + +print(time_table(("8:00", "9:00"),["8:00", "9:00"] )) +``` + Fastest route (last exercise) Fewest stops or transfers From 37741db4f3e3d0761d9e26b84cb2f82b2e26155c Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Mon, 12 Dec 2022 10:24:22 +0100 Subject: [PATCH 14/19] Updated test data --- .../thallias_tram_troubles_test.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py index a29993f26c..f45472e2da 100644 --- a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py +++ b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py @@ -1,8 +1,17 @@ import unittest import pytest +from thallias_tram_troubles import time_table_for_a_weekday class ThalliasTramTroublesTest(unittest.TestCase): - pass + @pytest.mark.task(taskno=1) + def test_time_table_for_a_weekday(self): + input_data = (([["7:00", "12:00", "19:00"], ("7:00", "13:00", "17:00"), ["7:00", "12:00", "17:00"], ("10:00", "12:00", "17:00"), ("7:00", "15:00", "17:00"), ["7:00", "12:00"], ["7:00", "12:00"]],2), + ((("5:00", "7:00", "12:00", "15:00", "18:00"),("6:00", "8:00", "13:00", "14:00", "17:00"),("4:00", "6:00", "9:00", "12:00", "18:00"),("6:00", "7:30", "16:00", "18:00", "19:00"),("6:00", "9:00", "12:00", "13:00", "18:00"), ("7:00", "8:00", "10:00", "12:00", "19:00"),("7:00", "10:00", "12:00", "15:00", "18:00")), 6) + ) + output_data = (["7:00", "12:00", "17:00"], ("7:00", "10:00", "12:00", "15:00", "18:00")) + for variant, (input_data, output_data) in enumerate(zip(input_data, output_data), start=1): + with self.subTest(f"variation #{variant}", input_data=input_data, output_data=output_data): + self.assertEqual(time_table_for_a_weekday(*input_data), output_data) From a2a7ef850e8f4321d0e9d5ee364c93415c8d60fe Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Mon, 12 Dec 2022 21:45:45 +0100 Subject: [PATCH 15/19] updated the tests --- .../thallias_tram_troubles_test.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py index f45472e2da..dd00ceda9b 100644 --- a/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py +++ b/exercises/concept/thallias-tram-troubles/thallias_tram_troubles_test.py @@ -1,17 +1,31 @@ import unittest import pytest -from thallias_tram_troubles import time_table_for_a_weekday +from thallias_tram_troubles import time_table_for_a_weekday, time_table_for_a_specific_range, fewest_transfers, fastest_route, update___ class ThalliasTramTroublesTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_time_table_for_a_weekday(self): - input_data = (([["7:00", "12:00", "19:00"], ("7:00", "13:00", "17:00"), ["7:00", "12:00", "17:00"], ("10:00", "12:00", "17:00"), ("7:00", "15:00", "17:00"), ["7:00", "12:00"], ["7:00", "12:00"]],2), - ((("5:00", "7:00", "12:00", "15:00", "18:00"),("6:00", "8:00", "13:00", "14:00", "17:00"),("4:00", "6:00", "9:00", "12:00", "18:00"),("6:00", "7:30", "16:00", "18:00", "19:00"),("6:00", "9:00", "12:00", "13:00", "18:00"), ("7:00", "8:00", "10:00", "12:00", "19:00"),("7:00", "10:00", "12:00", "15:00", "18:00")), 6) + input_data = (([['7:00', '12:00', '19:00'], ('7:00', '13:00', '17:00'), ['7:00', '12:00', '17:00'], ('10:00', '12:00', '17:00'), ('7:00', '15:00', '17:00'), ['7:00', '12:00'], ['7:00', '12:00']],2), + ((('5:00', '7:00', '12:00', '15:00', '18:00'),('6:00', '8:00', '13:00', '14:00', '17:00'),('4:00', '6:00', '9:00', '12:00', '18:00'),('6:00', '7:30', '16:00', '18:00', '19:00'),('6:00', '9:00', '12:00', '13:00', '18:00'), ('7:00', '8:00', '10:00', '12:00', '19:00'),('7:00', '10:00', '12:00', '15:00', '18:00')), 6), + ([['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00'], ['4:00', '6:00', '8:00', '9:00', '11:00', '14:00', '17:00', '19:00', '21:00']],4) ) - output_data = (["7:00", "12:00", "17:00"], ("7:00", "10:00", "12:00", "15:00", "18:00")) + output_data = (['7:00', '12:00', '17:00'], ('7:00', '10:00', '12:00', '15:00', '18:00'), ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30']) for variant, (input_data, output_data) in enumerate(zip(input_data, output_data), start=1): with self.subTest(f"variation #{variant}", input_data=input_data, output_data=output_data): self.assertEqual(time_table_for_a_weekday(*input_data), output_data) + + @pytest.mark.task(taskno=2) + def test_time_table_for_a_specific_range(self): + input_data = ( + ([['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00', '23:30'], ['4:00', '6:00', '7:00', '8:00', '9:00', '11:00', '12:00', '14:00', '17:00', '19:00', '21:00'], ['4:00', '6:00', '8:00', '9:00', '11:00', '14:00', '17:00', '19:00', '21:00']],4, 2,5), + ((['4:00' ,'7:00', '8:00', '9:00', '15:00'], ['7:00', '8:00', '9:00', '18:00'], ['6:00', '7:00', '8:00', '9:00', '15:00'], ['6:00', '7:00', '8:00', '9:00', '18:00'], ['5:00', '7:00', '8:00', '9:00', '15:00'], ['5:00', '7:00', '8:00', '9:00', '18:00'], ['8:00', '9:00']), 1, 0, 1), + ((('9:00', '10:00', '14:00', '15:00', '18:00'),('9:00', '10:00', '14:00', '15:00', '18:00'),('9:00', '10:00', '14:00', '15:00', '18:00'),('9:00', '10:00', '14:00', '15:00', '18:00'),('9:00', '10:00', '14:00', '15:00', '18:00'), ('9:00', '10:00', '14:00', '15:00', '18:00'),('9:00', '10:00', '14:00', '15:00', '18:00')), 1, 3, 5), + ) + output_data = (['7:00', '8:00', '9:00'],['7:00'], ('15:00', '18:00')) + + for variant, (input_data, output_data) in enumerate(zip(input_data, output_data), start=1): + with self.subTest(f"variation #{variant}", input_data=input_data, output_data=output_data): + self.assertEqual(time_table_for_a_specific_range(*input_data), output_data) From 23af8000544077b66cd273b01ec28092d2b214ea Mon Sep 17 00:00:00 2001 From: BethanyG Date: Wed, 14 Dec 2022 08:31:12 -0800 Subject: [PATCH 16/19] Story Updates --- .../.docs/instructions.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/exercises/concept/thallias-tram-troubles/.docs/instructions.md b/exercises/concept/thallias-tram-troubles/.docs/instructions.md index 63fd98ab00..7f60339a6e 100644 --- a/exercises/concept/thallias-tram-troubles/.docs/instructions.md +++ b/exercises/concept/thallias-tram-troubles/.docs/instructions.md @@ -1 +1,60 @@ # Instructions + +Your classmate Thallia has just won an internship with the city's premier tram company. +Her goal for the term of the internship is to improve communications with the ridership and promote special services. +She's decided to focus on writing several apps that can run on station platforms, the tram website, and rider's phones. +Since writing all these apps is a big taksk, she's asked that the tram company recruit you to help on the project. + + +1. Schedules by Weekday Number + +First on the agenda is an app that can help commuters navigate the various schedules so they can more eaily get to and from work. +Thallia's got the lines and locations mostly figured out, but would like you to write a function that will filter the timetable sequence for a given weekday, so riders can clearly see all the departure times. +The aim will be to return tram departure times from the timetable based on a weekday number (_0 being Monday, 6 being Sunday_). +Write the `time_table_for_a_weekday` function that takes a sequence of daily timetables and weekday number. +It should return the schedule sequence corresponding to the weekeday number. + + +```python +examples here +``` + + +2. Departures by Commute Window + +Now that you have the weekday filtering figured out, Thallia has asked you to drill down into specfic commute times. +This part of the app is designed to allow a commuter to input their commute day plus a "commute window" and recieve a sequence of departure times. +Wite the `time_table_for_a_specific_range` function that takes a sequence of daily timetables, a weekday number, and `start`/`stop` indexes for the "commute window". +It should return a sequence of departure times for the commuter that fits their travel day and "commute window". + +```python +example here +``` + + +3. Calculate Route with Fewest Transfers + +The tram system has many routes and many different ways for commuters to reach their destinations. +However, transferring adds time and complexity to the process. +Thallia is trying to tackle this in-app by asking you to add a feature that will calculate routes with the fewest transfers. + + +4. Calculate Fastes Route + +To up the tram company's visibility, Thallia has decided to add functionality similar to Googles "plan a trip" functionality. +But instead of providing all routes and times, she'd like you to provide commuters only with the fastest available routes listed in the time tables. + + + +5. Update Station Status Displays + +Having built up commuter features, Thallia now wants to focus a bit on weekend "famiy activitiy" services. +She'd like to update the stattion display software to better promote different activities (concerts, museums, amusment parks, zoos, sports matches, theater) that can be reached via different tram lines. +She's asked you to write a function that will insert a short blurb about an activity into the arrival and departure displays. + +6. Update Weekend Schedule Information + +Thallia would also like to update the app so that weekend riders can know when an event is scheduled and what train departures will get them to the activities on time. +She'd like you to write a function that will insert an activities description and start time into a given schedule display, so that riders are reminded that they can take the tram to the activity. + + From 5aacbae65449ddae7eca8e3993494a94150b5976 Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Wed, 14 Dec 2022 17:40:10 +0100 Subject: [PATCH 17/19] Fixes --- .../.docs/instructions.md | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/exercises/concept/thallias-tram-troubles/.docs/instructions.md b/exercises/concept/thallias-tram-troubles/.docs/instructions.md index 7f60339a6e..0ed43763d4 100644 --- a/exercises/concept/thallias-tram-troubles/.docs/instructions.md +++ b/exercises/concept/thallias-tram-troubles/.docs/instructions.md @@ -3,58 +3,49 @@ Your classmate Thallia has just won an internship with the city's premier tram company. Her goal for the term of the internship is to improve communications with the ridership and promote special services. She's decided to focus on writing several apps that can run on station platforms, the tram website, and rider's phones. -Since writing all these apps is a big taksk, she's asked that the tram company recruit you to help on the project. - +Since writing all these apps is a big task, she's asked that the tram company recruit you to help with the project. 1. Schedules by Weekday Number -First on the agenda is an app that can help commuters navigate the various schedules so they can more eaily get to and from work. +First on the agenda is an app that can help commuters navigate the various schedules so they can more easily get to and from work. Thallia's got the lines and locations mostly figured out, but would like you to write a function that will filter the timetable sequence for a given weekday, so riders can clearly see all the departure times. The aim will be to return tram departure times from the timetable based on a weekday number (_0 being Monday, 6 being Sunday_). Write the `time_table_for_a_weekday` function that takes a sequence of daily timetables and weekday number. -It should return the schedule sequence corresponding to the weekeday number. - +It should return the schedule sequence corresponding to the weekday number. ```python examples here ``` - 2. Departures by Commute Window -Now that you have the weekday filtering figured out, Thallia has asked you to drill down into specfic commute times. -This part of the app is designed to allow a commuter to input their commute day plus a "commute window" and recieve a sequence of departure times. -Wite the `time_table_for_a_specific_range` function that takes a sequence of daily timetables, a weekday number, and `start`/`stop` indexes for the "commute window". +Now that you have the weekday filtering figured out, Thallia has asked you to drill down into specific commute times. +This part of the app is designed to allow a commuter to input their commute day plus a "commute window" and receive a sequence of departure times. +With the `time_table_for_a_specific_range` function that takes a sequence of daily timetables, a weekday number, and `start`/`stop` indexes for the "commute window". It should return a sequence of departure times for the commuter that fits their travel day and "commute window". ```python example here ``` - 3. Calculate Route with Fewest Transfers The tram system has many routes and many different ways for commuters to reach their destinations. However, transferring adds time and complexity to the process. Thallia is trying to tackle this in-app by asking you to add a feature that will calculate routes with the fewest transfers. - -4. Calculate Fastes Route +4. Calculate Fastest Route To up the tram company's visibility, Thallia has decided to add functionality similar to Googles "plan a trip" functionality. -But instead of providing all routes and times, she'd like you to provide commuters only with the fastest available routes listed in the time tables. - - +But instead of providing all routes and times, she'd like you to provide commuters only with the fastest available routes listed in the timetables. 5. Update Station Status Displays -Having built up commuter features, Thallia now wants to focus a bit on weekend "famiy activitiy" services. -She'd like to update the stattion display software to better promote different activities (concerts, museums, amusment parks, zoos, sports matches, theater) that can be reached via different tram lines. +Having built up commuter features, Thallia now wants to focus a bit on weekend "family activity" services. +She'd like to update the station display software to better promote different activities (concerts, museums, amusement parks, zoos, sports matches, theater) that can be reached via different tram lines. She's asked you to write a function that will insert a short blurb about an activity into the arrival and departure displays. 6. Update Weekend Schedule Information Thallia would also like to update the app so that weekend riders can know when an event is scheduled and what train departures will get them to the activities on time. -She'd like you to write a function that will insert an activities description and start time into a given schedule display, so that riders are reminded that they can take the tram to the activity. - - +She'd like you to write a function that will insert an activity description and start time into a given schedule display, so that riders are reminded that they can take the tram to the activity. From 986fa9e1ddc59cc4d199a8003fe0daf9e5a785f0 Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Wed, 14 Dec 2022 17:51:54 +0100 Subject: [PATCH 18/19] Added examples --- .../concept/thallias-tram-troubles/.docs/instructions.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exercises/concept/thallias-tram-troubles/.docs/instructions.md b/exercises/concept/thallias-tram-troubles/.docs/instructions.md index 0ed43763d4..38dbfcc2f6 100644 --- a/exercises/concept/thallias-tram-troubles/.docs/instructions.md +++ b/exercises/concept/thallias-tram-troubles/.docs/instructions.md @@ -14,7 +14,8 @@ Write the `time_table_for_a_weekday` function that takes a sequence of daily tim It should return the schedule sequence corresponding to the weekday number. ```python -examples here +>>> time_table_for_a_weekday([["8:00", "17:00"], ("9:00", "16:00"), ("8:30", "15:00"), ["10:00", "19:00", "21:00"], ["12:00", "20:00"], ("9:00", "19:00"), ("9:30", "15:00", "20:00")], 3) +["10:00", "19:00", "21:00"] ``` 2. Departures by Commute Window @@ -25,7 +26,8 @@ With the `time_table_for_a_specific_range` function that takes a sequence of dai It should return a sequence of departure times for the commuter that fits their travel day and "commute window". ```python -example here +>>> time_table_for_a_specific_range([["8:00", "17:00"], ("9:00", "16:00"), ("8:30", "15:00"), ["10:00", "19:00", "21:00"], ["12:00", "20:00"], ("9:00", "19:00"), ("9:30", "15:00", "20:00", "21:00")], 6, 1, 3) +("15:00", "20:00") ``` 3. Calculate Route with Fewest Transfers From e792152edb3d15a8e316962831072ff9aa7b096d Mon Sep 17 00:00:00 2001 From: meatball <69751659+meatball133@users.noreply.github.com> Date: Wed, 14 Dec 2022 19:43:47 +0100 Subject: [PATCH 19/19] smal change --- .../concept/thallias-tram-troubles/.docs/instructions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/concept/thallias-tram-troubles/.docs/instructions.md b/exercises/concept/thallias-tram-troubles/.docs/instructions.md index 38dbfcc2f6..bcc118306c 100644 --- a/exercises/concept/thallias-tram-troubles/.docs/instructions.md +++ b/exercises/concept/thallias-tram-troubles/.docs/instructions.md @@ -10,7 +10,7 @@ Since writing all these apps is a big task, she's asked that the tram company re First on the agenda is an app that can help commuters navigate the various schedules so they can more easily get to and from work. Thallia's got the lines and locations mostly figured out, but would like you to write a function that will filter the timetable sequence for a given weekday, so riders can clearly see all the departure times. The aim will be to return tram departure times from the timetable based on a weekday number (_0 being Monday, 6 being Sunday_). -Write the `time_table_for_a_weekday` function that takes a sequence of daily timetables and weekday number. +Write the `time_table_for_a_weekday` function that takes a nested sequence of timetables and weekday number. It should return the schedule sequence corresponding to the weekday number. ```python @@ -47,7 +47,7 @@ Having built up commuter features, Thallia now wants to focus a bit on weekend " She'd like to update the station display software to better promote different activities (concerts, museums, amusement parks, zoos, sports matches, theater) that can be reached via different tram lines. She's asked you to write a function that will insert a short blurb about an activity into the arrival and departure displays. -6. Update Weekend Schedule Information +6. Update Weekend Schedule Information Thallia would also like to update the app so that weekend riders can know when an event is scheduled and what train departures will get them to the activities on time. She'd like you to write a function that will insert an activity description and start time into a given schedule display, so that riders are reminded that they can take the tram to the activity.