Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Concept Exercise] : generators #2293

Closed
BethanyG opened this issue Apr 30, 2020 · 9 comments
Closed

[New Concept Exercise] : generators #2293

BethanyG opened this issue Apr 30, 2020 · 9 comments
Assignees
Labels
claimed 🐾 For new exercises being written by contributors and maintainers. x:action/create Work on something from scratch x:knowledge/advanced Comprehensive Exercism knowledge required x:module/concept-exercise Work on Concept Exercises x:rep/large Large amount of reputation x:size/large Large amount of work x:status/claimed Someone is working on this issue

Comments

@BethanyG
Copy link
Member

BethanyG commented Apr 30, 2020

This issue describes how to implement the generators concept exercise for the Python track.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Please also watch the following video:

Goal

The goal of this exercise is to teach the syntax and use of generators in Python.

Learning objectives

  • Understand what generators are and how/when to use them
  • Understand how generators relate to loops and iterators
  • Understand how to use the yield keyword
  • Understand the __next__() method
  • Create a generator

Out of scope

  • Memory and performance characteristics and optimizations
  • throw(type, value=None, traceback=None)
  • close()
  • generator expressions
  • yield from
  • generators used as coroutines

Concepts covered

  • generators
  • yield
  • __next__()
  • iterators

Prerequisites

  • conditionals
  • dicts
  • functions
  • higher-order-functions
  • lists
  • loops
  • iteration
  • iterators
  • sequences

Resources to refer to

Hints

  • Referring to one or more of the resources linked above, or analogous resources from a trusted source.
  • Generators section of the Python Docs Functional How to tutorial: Generators

Concept Description

(a variant of this can be used for the v3/languages/python/concepts/<concept>/about.md doc and this exercises introduction.md doc.)

Concept Description Needs to Be Filled In Here/Written

Some "extras" that we might want to include as notes in the concept description, or as links in links.json:

  • Additional Generator-iterator methods, such as generator.send() and generator.throw()
  • generator expressions
  • Asynchronous generator functions
  • generators used as coroutines

Representer

No changes required.

Analyzer

No changes rquired.

Implementing

The general Python track concept exercise implantation guide can be found here.

Tests should be written using unittest.TestCase and the test file named generators_test.py.

Code in the .meta/example.py file should only use syntax & concepts introduced in this exercise or one of its prerequisites. Please do not use comprehensions, generator expressions, or other syntax not previously covered. Please also follow PEP8 guidelines.

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue, or contact one of the maintainers on our Slack channel.

@BethanyG BethanyG changed the title [Python] Implement new Concept Exercise: generators [V3] Implement new Concept Exercise: generators Jan 28, 2021
@BethanyG BethanyG transferred this issue from exercism/v3 Jan 28, 2021
@BethanyG BethanyG added this to the First 22 Concept Exercises Due for V3 milestone Jan 29, 2021
@BethanyG
Copy link
Member Author

BethanyG commented Feb 4, 2021

@djjohnsongeek is going to take this on. 🎉 🌟

@BethanyG BethanyG modified the milestones: First 22 Concept Exercises Due for V3, New V3 Concept Exercises Mar 31, 2021
@BethanyG BethanyG modified the milestones: New V3 Concept Exercises, V3 Concept Exercises for Beta May 21, 2021
@BethanyG BethanyG changed the title [V3] Implement new Concept Exercise: generators [New Concept Exercise] : generators Jun 16, 2021
@J08K
Copy link
Member

J08K commented Oct 5, 2021

Heya, I am going to work on this.

My idea

An airline needs your help with assigning seats for passengers, to do this they need you to make them a generator for that.

First, clarification:
A seat uses the following format 11F, with each 1 being a number from 1 through 9, AKA the rows. And the F is the seat in each row, it uses A through F. It is important to note that a lot of airlines (we'll be using all airlines in the exercise) do not use row 13 because of the superstition surrounding it.

The exercise consists (prone to change) out of these functions/generators:

  • generate_seats: Using the argument number_of_seats generate that amount of seats by counting up 1A, 1B, 1C, etc. inside a generator.
  • assign_seats: This generator needs to assign seats to a list of given passengers. It returns a list of tuples, with (passenger_name, assigned_seat). These seats need to be generated by the previously mentioned function.

I think these should cover most of generators, but I am still stuck on how to implement __next__() and next() into the exercise itself.

@J08K J08K self-assigned this Oct 5, 2021
@BethanyG BethanyG added claimed 🐾 For new exercises being written by contributors and maintainers. x:size/large Large amount of work x:action/create Work on something from scratch x:knowledge/advanced Comprehensive Exercism knowledge required x:module/concept-exercise Work on Concept Exercises labels Oct 5, 2021
@djjohnsongeek
Copy link

Yeah sorry I realize I never got to this. My personal life sorta blew up right after I started contributing.

@BethanyG
Copy link
Member Author

BethanyG commented Oct 6, 2021

No worries @djjohnsongeek! We're happy you are back, and hopefully everything is going well for you.
If you'd like, I think @J08K might be open to collaboration? Just check in with him.

But there are also other issues (open issues) you can take on as well (if you'd like) -- just let us know! 😄

@djjohnsongeek
Copy link

@BethanyG
For the most part it has all been good stuff: new baby, new job, new house. New baby especially has trimmed all my free time 😄
I'd love to come back and contribute at some point, but still might be a while yet.

@BethanyG
Copy link
Member Author

@djjohnsongeek -- WOW 😮 That is a LOT of new! Congratulations! 🌟

...and just give a shout when you want to ease back into contributing. 😄

@J08K
Copy link
Member

J08K commented Oct 13, 2021

Wowie, congratulations on the kid! I wish you good night's rest! 😛 Enjoy every moment, and we'll see you around!

@djjohnsongeek
Copy link

Thank you both!

@BethanyG BethanyG added the x:status/claimed Someone is working on this issue label Feb 10, 2022
@BethanyG BethanyG added the x:rep/large Large amount of reputation label Apr 23, 2022
@BethanyG
Copy link
Member Author

Closing this issue, since we've merged the Plane Tickets exercise. Any further changes will be logged in a new issue. Thanks everyone for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
claimed 🐾 For new exercises being written by contributors and maintainers. x:action/create Work on something from scratch x:knowledge/advanced Comprehensive Exercism knowledge required x:module/concept-exercise Work on Concept Exercises x:rep/large Large amount of reputation x:size/large Large amount of work x:status/claimed Someone is working on this issue
Projects
None yet
Development

No branches or pull requests

3 participants