Skip to content

Commit 25bf192

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d1200cb commit 25bf192

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compression/huffman.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from collections import defaultdict
33
import sys
44

5+
56
class HuffmanNode:
67
def __init__(self, char=None, freq=0):
78
self.char = char
@@ -18,7 +19,7 @@ def calculate_frequencies(file_path):
1819
Reads the file and calculates the frequency of each character.
1920
"""
2021
freq = defaultdict(int)
21-
with open(file_path, 'r') as file:
22+
with open(file_path, "r") as file:
2223
for line in file:
2324
for char in line:
2425
freq[char] += 1
@@ -67,12 +68,12 @@ def encode_file(file_path, code_map):
6768
Encodes the file contents using the Huffman codes.
6869
"""
6970
encoded_output = []
70-
with open(file_path, 'r') as file:
71+
with open(file_path, "r") as file:
7172
for line in file:
7273
for char in line:
7374
encoded_output.append(code_map[char])
7475

75-
return ''.join(encoded_output)
76+
return "".join(encoded_output)
7677

7778

7879
def huffman(file_path):

0 commit comments

Comments
 (0)