incomplete state of day 9 - step 3
This commit is contained in:
parent
b7ea34fd2b
commit
3d51680482
1 changed files with 14 additions and 8 deletions
|
|
@ -33,22 +33,28 @@ def get_disk(disk_map: str) -> tuple:
|
||||||
|
|
||||||
|
|
||||||
def print_disk(disk: list) -> None:
|
def print_disk(disk: list) -> None:
|
||||||
for pos in disk:
|
for block in disk:
|
||||||
if pos is None:
|
if block is None:
|
||||||
print(".", end="")
|
print(".", end="")
|
||||||
else:
|
else:
|
||||||
print(pos, end="")
|
print(block, end="")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
def defragment(disk: list, full_blocks: deque, free_blocks: deque) -> None:
|
||||||
|
while len(free_blocks) > 0:
|
||||||
|
pass
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
disk_map = get_lines("sample-input.txt")[0]
|
# disk_map = get_lines("sample-input.txt")[0]
|
||||||
# disk_map = get_lines("sample-input2.txt")[0]
|
disk_map = get_lines("sample-input2.txt")[0]
|
||||||
# disk_map = get_lines("input.txt")[0]
|
# disk_map = get_lines("input.txt")[0]
|
||||||
|
|
||||||
disk, free_blocks, full_blocks = get_disk(disk_map)
|
disk, free_blocks, full_blocks = get_disk(disk_map)
|
||||||
print_disk(disk)
|
print_disk(disk)
|
||||||
print(free_blocks)
|
# print(free_blocks)
|
||||||
print(full_blocks)
|
# print(full_blocks)
|
||||||
|
defragment(disk, free_blocks, full_blocks)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue