working on part 2
This commit is contained in:
parent
21421d265e
commit
025ecdb71d
@ -57,6 +57,13 @@ class DiskMap:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def findFreeBlockOfBestFit(self, size: int) -> int | None:
|
||||||
|
for i, block in enumerate(self.blocks):
|
||||||
|
if type(block) == FreeBlock and block.size >= size:
|
||||||
|
return i
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def compact(self) -> None:
|
def compact(self) -> None:
|
||||||
while True:
|
while True:
|
||||||
free_index = self.findFreeBlock()
|
free_index = self.findFreeBlock()
|
||||||
@ -109,3 +116,5 @@ for block in diskmap.blocks:
|
|||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
print(f'Part 1: {total}')
|
print(f'Part 1: {total}')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user