Skip to content

Commit d40d30e

Browse files
committed
create a dir & README.md file for the new "Implement Laptop Allocation" task
1 parent 407b010 commit d40d30e

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
In the prep, there was an exercise around finding possible laptops for a group of people.
2+
3+
Your exercise is to extend this to actually allocate laptops to the people.
4+
5+
Given these class definitions:
6+
7+
from dataclasses import dataclass
8+
from enum import Enum
9+
from typing import List
10+
11+
class OperatingSystem(Enum):
12+
MACOS = "macOS"
13+
ARCH = "Arch Linux"
14+
UBUNTU = "Ubuntu"
15+
16+
@dataclass(frozen=True)
17+
class Person:
18+
name: str
19+
age: int
20+
# Sorted in order of preference, most preferred is first.
21+
preferred_operating_system: List[OperatingSystem]
22+
23+
24+
@dataclass(frozen=True)
25+
class Laptop:
26+
id: int
27+
manufacturer: str
28+
model: str
29+
screen_size_in_inches: float
30+
operating_system: OperatingSystem
31+
Write a function with this signature:
32+
33+
def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person, Laptop]:
34+
Every person should be allocated exactly one laptop.
35+
36+
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.
37+
38+
Maximum time in hours
39+
3
40+
41+
How to submit
42+
Submit a PR to this repo containing your function (and any supporting code).

0 commit comments

Comments
 (0)