NW | 26-SDC-Mar | Ahmad Hmedan | Sprint 5 | Implement laptop allocation#508
Open
AhmadHmedann wants to merge 2 commits intoCodeYourFuture:mainfrom
Open
NW | 26-SDC-Mar | Ahmad Hmedan | Sprint 5 | Implement laptop allocation#508AhmadHmedann wants to merge 2 commits intoCodeYourFuture:mainfrom
AhmadHmedann wants to merge 2 commits intoCodeYourFuture:mainfrom
Conversation
OracPrime
suggested changes
Apr 25, 2026
OracPrime
left a comment
There was a problem hiding this comment.
Couple of language issues, and a major scalability issue
| best_perm = perm | ||
| results = {} | ||
| for index, person in enumerate(people): | ||
| results[person.name] = laptops[best_perm[index]] |
There was a problem hiding this comment.
You've declared the function as a dictionary with a key of Person, but you're using the name as the key. You need to be consistent.
|
|
||
| best_perm = None | ||
| min_sadness = 100000000000 | ||
| for perm in permutations(range(how_many_laptops)): |
There was a problem hiding this comment.
If you've got 15 laptops, how many times do this loop iterate?
| def sadness(person: Person, operating_system: OperatingSystem) -> int: | ||
| sad: int = 100 | ||
| for index, os in enumerate(person.preferred_operating_system): | ||
| if os == operating_system: |
There was a problem hiding this comment.
Did you consider preferred_operating_system.index() ?
| matrix[i][j] = sadness(person, laptop.operating_system) | ||
|
|
||
| best_perm = None | ||
| min_sadness = 100000000000 |
| manufacturer="Dell", | ||
| model="XPS", | ||
| screen_size_in_inches=15, | ||
| operating_system=OperatingSystem.MACOS, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
fix: complete laptop allocation logic and resolve typing issues
Questions
Hi, I ran into an issue while building the allocation.
When I tried to use
Personas a key in a dictionary like this:results[person] = laptops[best_perm[index]]I got this error:
TypeError: unhashable type: 'list'I worked around it by using
person.nameas the key instead.Could you explain why this happens, and what the correct approach should be?