Skip to content

Conversation

@AFatmaa
Copy link

@AFatmaa AFatmaa commented Oct 26, 2025

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

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.

@github-actions
Copy link

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).

@AFatmaa AFatmaa added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Decomposition The name of the module. labels Oct 26, 2025
@github-actions
Copy link

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
@github-actions
Copy link

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).

Copy link

@LonMcGregor LonMcGregor left a 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)

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?

Copy link
Author

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.

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 28, 2025
@AFatmaa
Copy link
Author

AFatmaa commented Nov 9, 2025

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 break for the perfect match to make it a bit faster.
Can you check it when you have some time, please?

Thanks a lot!

@AFatmaa AFatmaa added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 9, 2025
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

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
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

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).

Copy link

@LonMcGregor LonMcGregor left a 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!

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 10, 2025
@github-actions
Copy link

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
@github-actions
Copy link

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).

@AFatmaa
Copy link
Author

AFatmaa commented Nov 10, 2025

Thank you so much @LonMcGregor! I appreciate all your feedback. I learned a lot from your comments ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Decomposition The name of the module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants