Hi @MangoSeed
Thank you so much for your feedback! I was a bit worried about releasing this exercise - its a bit of a leap from the others in the syllabus, and could benefit from multiple prerequisite exercises (like iterators
and comprehensions
and itertools
and more) that we haven’t (yet) gotten launched.
But its been on ice for waaaay to long, so we decided to publish and then fill in the prerequisites later.
We definitely should make that clearer. We do talk about a generator being consumed, but we could probably make that more prominent. Maybe we add some more detail to introduction.md
, and maybe even re-arrange it a bit? Very open to suggestions on that.
Yeah - I definitely see where that could be ambiguous. Here is one thought/suggestion, but I am very open to others, This one might be too “heavy”:
## 1. Generate seat letters
Conda wants to generate seat letters for their airplanes.
An airplane is made of rows of seats.
Each row has _4 seats_.
The seats in each row are always named `A`, `B`, `C`, and `D`.
The first seat in the row is `A`, the second seat in the row is `B`, and so on.
After reaching `D`, the naming should start again with `A`.
Implement a function `generate_seat_letters(<number>)` that accepts an `int` representing how many rows of seat letters need to be generated.
The function should return a generator-iterator that will yield seat letters one at a time.
In other words, your function should yield a single letter each time `next()` is called, until there are no more values to return.
```python
>>> letters = generate_seat_letters(5)
>>> next(letters)
"A"
>>> next(letters)
"B"
>>> next(letters)
"C"
>>> next(letters)
"D"
>>> next(letters)
"A"
>>> next(letters)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
```
Maybe we could add some lines to hints.md
here about modulus
, linking back to the numbers concept? And we could also write out some examples of what x % 4
returns?
Maybe we also mention that sequence
types (list
, str
, tuple
) all have common sequence operations that include using bracket notation (and that as long as what is in the brackets resolves to a valid index, you can do as much math as you like!)?
Finally, after reviewing some of the submitted community solutions, I think we might also want to link to itertools.cycle
- especially since the equivalence example code has a really nice generator example, even though itertools.cycle
by itself actually returns a cycle
object as opposed to a generator
.
I am intrigued - do you have a thought on what the clock-like example would look like in the introduction.md
?? I’d love to include more examples in the docs!