Skip to content

080_lesson#8

Open
ikrugloff wants to merge 1 commit into
masterfrom
080_lesson
Open

080_lesson#8
ikrugloff wants to merge 1 commit into
masterfrom
080_lesson

Conversation

@ikrugloff
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@Dzhoker1 Dzhoker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оставил комментарии по коду

Comment thread task_01.py
ht_with_repetitions = ''.join(random.choice(string.ascii_lowercase) for y in range(Y))
print(f'ht_with_repetitions = {ht_with_repetitions}')

class Hash:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Собственный класс для хэша - хорошо.
Но я специально написал рекомендацию по использованию готовой функции для подсчёта хэша.

Comment thread task_01.py
return self.str[self.init:self.end]


def rabin_karp_matcher(substring, string):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Доработать алгоритм с урока - тоже хорошо.
Но задача стояла совсем другая.
Нужно анализировать строку и никакие подстроки передаваться не должны.

Comment thread task_02.py
"""
2. Закодируйте любую строку (хотя бы из трех слов) по алгоритму Хаффмана.
"""
from heapq import heappush, heappop, heapify
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично, что вы знаете эту библиотеку )))

Comment thread task_02.py

txt = "this is an example for huffman encoding"
symb2freq = collections.Counter(txt)
for ch in txt:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот цикл совершенно не нужен. 24 строка уже всё посчитала.

Comment thread task_02.py
huff = encode(symb2freq)
print("Symbol\tWeight\tHuffman Code")
for p in huff:
print("%s\t\t%s\t\t%s" % (p[0], symb2freq[p[0]], p[1])) No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Таблица кодирования есть.
А закодированную строку так и не вывели.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants