Skip to content

Conversation

@zohrehKazemianpour
Copy link

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 implements laptop allocation.

@zohrehKazemianpour zohrehKazemianpour added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jan 4, 2026
@OracPrime OracPrime added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jan 11, 2026
Copy link

@OracPrime OracPrime left a 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

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

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

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

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)

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?

@OracPrime OracPrime 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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants