-
-
Notifications
You must be signed in to change notification settings - Fork 42
London | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 5 | Laptop-allocation #314
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
base: main
Are you sure you want to change the base?
London | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 5 | Laptop-allocation #314
Conversation
…dness scores and improve overall allocation quality
OracPrime
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some intelligent coding here, nice!
Couple of questions to clear up, but overall good work.
| name: str | ||
| age: int | ||
| # Sorted in order of preference, most preferred is first. | ||
| preferred_operating_system: tuple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a tuple rather than a list?
| raise ValueError("Not enough laptops to allocate one per person") | ||
|
|
||
|
|
||
| people_sorted = sorted(people, key = lambda p: len(p.preferred_operating_system)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice touch - haven't seen anyone else do this, but it is a clever tweak to the algorithm
| people_sorted = sorted(people, key = lambda p: len(p.preferred_operating_system)) | ||
|
|
||
| result={} | ||
| available_laptops = laptops.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot that you need the copy if you don't want to change the original
| sadness = calculate_sadness(person, laptop) | ||
| if sadness < smallest_sadness: | ||
| smallest_sadness = sadness | ||
| best_laptop = laptop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could of course break out of the loop if sadness is 0
|
|
||
| return result | ||
|
|
||
| allocate_laptops(people, laptops) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this first call to allocate laptops here?
Learners, PR Template
Self checklist
Changelist
This PR implements laptop allocation.