Skip to content

Conversation

@delmorallopez
Copy link

Laptop allocation app

Every person should be allocated exactly one laptop.

If we define “sadness” as the number of places down in someone’s ranking the operating system the ended up with (i.e. if your preferences were [UBUNTU, ARCH, MACOS] and you were allocated a MACOS machine your sadness would be 2), we want to minimise the total sadness of all people. If we allocate someone a laptop with an operating system not in their preferred list, treat them as having a sadness of 100

@delmorallopez delmorallopez added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 10, 2025
@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.

Couple of minor points, one bug, but generally good code, well done.

class Person:
name: str
age: int
preferred_operating_system: Tuple[OperatingSystem, ...]

Choose a reason for hiding this comment

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

  1. Why a Tuple, not a List?
  2. If it is a collection, it should have a pluralised name (preferred_operating_systems)


def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person, Laptop]:
if len(people) != len(laptops):
raise ValueError("Number of people must equal number of laptops.")

Choose a reason for hiding this comment

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

Why does the number of people need to equal the number of laptops?

raise ValueError("Number of people must equal number of laptops.")

# Clone list so we can remove laptops as they are assigned
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!

@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