Skip to content

Conversation

@Nataliia74
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

02 Implement laptop allocation issue 179

@Nataliia74 Nataliia74 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 20, 2025
@OracPrime OracPrime added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jan 6, 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.

I think the code will work, but it is way too complicated. Please follow-up on the suggestion for a much simpler approach. It's often slightly harder to right simpler code, but it's worth it for everyone else that has to work with the code afterwards.

operating_system: OperatingSystem

def norm_os_values(value: str) -> OperatingSystem:
value = value.strip().lower()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Liking the data cleaning here.



people = [
Person(name="Imran", age=22, preferred_operating_systems=[norm_os_values("Ubuntu"), norm_os_values("Arch Linux")]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider giving Person a constructor which took a list of strings and did the normalisation into a list of OperatingSystem? Or alternatively declaring the Person directly with [OperationSystem.UBUNTU,OperatingSystem.ARCH]



def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Tuple[str, int], int]:
sadness_table: Dict[Tuple[str, int], int] = {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels unnecessarily complicated. Could you not return a Dict[Person,Laptop]? Then most of the processing you're doing later isn't necessary.

It feels like this is almost a database design with foreign keys which has been forced into an object based language.

Can you have a think about how much simpler it would be if you stayed with Dict[Person,Laptop] ?

@OracPrime OracPrime added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jan 6, 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