The OA was an in-memory file system design problem:
- add files, copy files
- search files with prefix and suffix
- add users with capacity, add files by user, update user capacity
- compress and decompress files
@dataclass
class File:
name: str
size: int
created_by: str
@dataclass
class User:
user_id: str
capacity: int
files: list[File] = field(default_factory=list)
consumed_capacity: int = 0
@property
def remaining_capacity(self):
return self.capacity - self.consumed_capacity
class Solution:
def __init__(self):
self._users: dict[str, User] = {}
self._files: dict[str, File] = {}
L1 and L2 were pretty straightforward.
L3 required handling the relationship between users and files, and you had to modify the copy_file from L2. The copied file also has a size, and if size > remaining_capacity, you can't copy it. For L1 and L2 you now had to assume there was an admin user.
L4 added compress — the compressed_file's size is halved, so you also had to update the consumed capacity.
I passed L3, but ran out of time on L4, so I'm probably failing this one.
The problem itself isn't hard to understand — it feels like it's mainly testing OOD and basic container operations. Everything is in-memory, no actual file reading/writing involved. And it doesn't need to be optimal either, just passing the tests is enough.
I think the hard part is that doing L3 requires changing your L1 and L2 code. The dataclasses get modified gradually — you don't know the full shape upfront. Once you change the L2 code for L3, there's a chance you introduce errors.
There's another post on this forum you can use to practice and get familiar with list and dict operations, plus other basics.
Other posts also mentioned that CodeSignal isn't great to use, and yeah, it really isn't. You can't modify the test file, you can't copy the function signature, and I couldn't figure out how to debug. Getting familiar with it ahead of time should help.
Good luck everyone.
Discussion
Loading comments…