Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing conditional check? #2

Open
aryamansharda opened this issue Jan 22, 2021 · 0 comments
Open

Missing conditional check? #2

aryamansharda opened this issue Jan 22, 2021 · 0 comments

Comments

@aryamansharda
Copy link

Thanks for this great open source resource! I think I may have noticed a potential bug, however. In the Decoder, the user provides:

input_file, n = argv[1:]            
maximum_table_size = pow(2,int(n))

But, they're not used anywhere in the following code. I believe the following change is in order:

if not(len(string) == 0):
        dictionary[next_code] = string + (dictionary[code][0])
        next_code += 1
    string = dictionary[code]

Should be:

 if not(len(phrase) == 0):
            if(len(dictionary) <= maximum_table_size):
                dictionary[next_code] = phrase + (dictionary[code][0])
                next_code += 1
        phrase = dictionary[code]

I ran the code with this change and it continued to work. Thoughts?

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

No branches or pull requests

1 participant