CodeYourFuture / CodeYourFuture/Module-Tools

Implement laptop allocation

Đang mở
#179 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
🏝️ Priority Stretch 🐂 Size Medium 📅 Sprint 5 Module-Tools Optional Submit:PR
Ngôn ngữ chính
Shell
Star
0
Fork
109
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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:

```python
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:

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.