Skip to content

Conversation

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

Used Hungarian Algorithm to minimize sadness score across all lptop users.

Questions

Kindly let me know which approah was better to solve this issue for the purpose of this assignmnent ? Thanks.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (SPRINT 5) doesn't match expected format (example: 'Sprint 2', without quotes)

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

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@SaraTahir28 SaraTahir28 changed the title WestMidlands| SDC-NOV-2025| SARA TAHIR| SPRINT 5| Feature/laptop allocation WestMidlands| SDC-NOV-2025| Sara Tahir| Sprint 5| Feature/laptop allocation Dec 8, 2025
@SaraTahir28 SaraTahir28 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 8, 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've been picky in the comments here, because if I wasn't being picky I wouldn't have much to say - it's solid code apart from the one type bug on the return value

# Map people to laptops
allocation = {}
for i, j in zip(row_indices, col_indices):#it pairs up results (person indices and laptop indices). The loop then uses those pairs to build the final allocation dictionary
allocation[people[i].name] = laptops[j]

Choose a reason for hiding this comment

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

You've declared the function as Dict[Person,Laptop] but are return Dict[str,Laptop]. I'm guessing you actually want the former?

if laptop.operating_system == person.preferred_operating_systems[0]:
return 0
elif len(person.preferred_operating_systems) > 1 and laptop.operating_system == person.preferred_operating_systems[1]:
return 1

Choose a reason for hiding this comment

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

Hard-coding the 0,1,2 feels clunky here. If you're explicitly saying that if it's not in the top 3 it's terrible, then that's one thing. But this code looks like a failure to use index to get the ranking of the laptop. Either explicitly have a "maximum rank for any happiness" (as you appear to have here, but don't say) or use and index (making sure it copes with not found correctly)

Laptop(id=3, manufacturer="Dell", model="XPS", screen_size_in_inches=15, operating_system=OperatingSystem.UBUNTU),
Laptop(id=4, manufacturer="Apple", model="macBook", screen_size_in_inches=13, operating_system=OperatingSystem.MACOS),
Laptop(id=5, manufacturer="Apple", model="macBook", screen_size_in_inches=13, operating_system=OperatingSystem.MACOS),
Laptop(id=6, manufacturer="Dell", model="macBook", screen_size_in_inches=13, operating_system=OperatingSystem.ARCH),

Choose a reason for hiding this comment

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

Dell have started making macBooks? who knew? 😄

for j, laptop in enumerate(laptops):
sadness_matrix[i,j] = sadness(person, laptop) #this matrix represents complete laptop allocation
# Hungarian algorithm to run on our sadness matrix
row_indices, col_indices = linear_sum_assignment(sadness_matrix) #which person which laptop

Choose a reason for hiding this comment

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

You're using a "black box" algorithm here. It is entirely opaque what it is doing or how it is working. For me, this would trigger adding some test files to check that it is working how I expect it to.

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