Implement laptop allocation
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Start by reviewing the earlier prep exercise for finding possible laptops, then use the stated Person, Laptop, and OperatingSystem definitions as the entry point for allocate_laptops. Done means every person has exactly one laptop and the total sadness is minimized, with unlisted operating systems counted as 100.
Written by the indexing model from the issue text.
Description
In the prep, there was an exercise around finding possible laptops for a group of people.
Your exercise is to extend this to actually allocate laptops to the people.
Given these class definitions:
from dataclasses import dataclass
from enum import Enum
from typing import List
class OperatingSystem(Enum):
MACOS = "macOS"
ARCH = "Arch Linux"
UBUNTU = "Ubuntu"
@dataclass(frozen=True)
class Person:
name: str
age: int
# Sorted in order of preference, most preferred is first.
preferred_operating_system: List[OperatingSystem]
@dataclass(frozen=True)
class Laptop:
id: int
manufacturer: str
model: str
screen_size_in_inches: float
operating_system: OperatingSystem
Write a function with this signature:
def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person, Laptop]:
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.
Maximum time in hours
3
How to submit
Submit a PR to this repo containing your function (and any supporting code).
- Dominant language
- Shell
- Stars
- 0
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CodeYourFuture/Module-Tools
-
🏕 Priority Mandatory 📅 Sprint 4 Core Module-Tools Submit:None 🦔 Size Tiny
Difficulty 1/5 Under an hour Newbie friendliness 70/100
CodeYourFuture/Module-Tools#581 ·
-
🏕 Priority Mandatory 🐇 Size Small 📅 Sprint 2 📅 Sprint 4 Module-Tools Recurring Submit:None
Difficulty 1/5 1-3 hours Newbie friendliness 58/100
CodeYourFuture/Module-Tools#544 ·
-
Install a JDK Open🏕 Priority Mandatory 📅 Sprint 4 Core Module-Tools Submit:None
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
CodeYourFuture/Module-Tools#480 ·
-
Write a general CV Open🏕 Priority Mandatory 🐂 Size Medium 📅 Sprint 4 Core Module-Tools Submit:Slack
Difficulty 2/5 Half a day Newbie friendliness 45/100
CodeYourFuture/Module-Tools#137 ·
-
Prep Exercises Open🏕 Priority Mandatory 📅 Sprint 5 🦑 Size Large Core Module-Tools Submit:PR
Difficulty 3/5 1-2 days Newbie friendliness 65/100
CodeYourFuture/Module-Tools#178 ·
All issues in CodeYourFuture/Module-Tools
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug easy help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
lacs-project/sysknife#503 ·
-
help wanted kind/documentation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
liquidmetal-dev/flintlock#1239 ·