-
-
Notifications
You must be signed in to change notification settings - Fork 21
London | 25-SDC-July | Fatma Arslantas | Sprint 4 | Laptop allocation #58
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?
Conversation
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR description contained template fields which weren't filled in. Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
LonMcGregor
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.
This is a good start on an implementation, but if you want an additional challenge, you could consider my comment on the efficiency of your solution
| # assign and remove from pool | ||
| if best_laptop: | ||
| allocation[person] = best_laptop | ||
| remaining_laptops.remove(best_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.
How long will this loop within a loop run if you have a lot of people and laptops as input? Can you think of any way to complete the loop early if you find a perfect match early on?
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.
The loop runs once for every person and every laptop, so it could take a long time if there are many of them. I realised that if a person finds a perfect match (sadness = 0), there’s no need to keep checking the rest of the laptops. I added a break to stop the loop early in that case and make it a bit more efficient.
|
Hi @LonMcGregor, Thanks for pointing that out! 😊 I hadn’t considered the efficiency part when I first wrote the code, so your comment really helped me see it from a different angle. I added a Thanks a lot! |
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
LonMcGregor
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.
Great work. Sometimes looping over lots of data is unavoidable, so trying to find efficiencies wherever you can is a good idea.
You're done with this task now!
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
1 similar comment
|
Your PR couldn't be matched to an assignment in this module. Please check its title is in the correct format, and that you only have one PR per assignment. If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). |
|
Thank you so much @LonMcGregor! I appreciate all your feedback. I learned a lot from your comments |
Learners, PR Template
Self checklist
Changelist
This PR adds a function that allocates laptops to people based on their preferred operating systems.
Each person receives exactly one laptop, aiming to minimise total “sadness”.
Sadness is calculated by how far down the person’s OS preference list the assigned laptop is.
If an OS is not in their list, sadness is set to 100.
Questions
I don’t have any questions. Thank you.