commit c1ca54db6bb3a03c20558b1b31163425de1fabfe Author: helldh Date: Tue Jan 13 20:07:53 2026 +0300 Huffan Algo: count_frequencies func diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a8510a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bigfile.pdf +.venv \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/huffman.iml b/.idea/huffman.iml new file mode 100644 index 0000000..99fbcaa --- /dev/null +++ b/.idea/huffman.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4d9c3d4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c732b8b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/huffman.py b/huffman.py new file mode 100644 index 0000000..d25636a --- /dev/null +++ b/huffman.py @@ -0,0 +1,22 @@ +import heapq as hq +from typing import BinaryIO, Dict +from collections import Counter + +def count_frequencies(fd: BinaryIO) -> Dict[int, int]: + entropy = list() + + content = fd.read() + + for byte in content: + entropy.append(byte) + + byte_counter = Counter(entropy) + + return dict(byte_counter) + +def make_tree(frequencies_table: Dict[int, int]): + ft = frequencies_table # short alias + + huffman_tree = hq.heapify(list()) + + # TODO: Реализовать логику дерева хаффмана, пока что остановимся на этом \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..ea6a1d1 --- /dev/null +++ b/main.py @@ -0,0 +1 @@ +# заглушка \ No newline at end of file