Skip to content

Conversation

@TheRealCheebs
Copy link
Contributor

This is a rebased version of #245

Original author: @theStack
Changes: Rebased onto main and resolved conflicts.
Closes #245

Original message:
Small optimization: rather than involving a string data type here (which needs to also be reversed and sliced), we can just directly operate on the amount integer variable by iterating over all the bits and add 2^i to the return list if bit i is set.

Also, add type hints to the parameter / return value and assert that the passed value must not be negative.

Updated notes:
With all of the changes over the years the only bit needed from the original PR was the change from string manipulation of binary number to the Bitwise operations. There had been talk around failing tests due to assertions, and negative amounts. All of that has been updated / resolved in other commits.

Small optimization: rather than involving a string data type here (which
needs to also be reversed and sliced), we can just directly operate on
the amount integer variable by iterating over all the bits and add 2^i
to the return list if bit i is set.

Also, add type hints to the parameter / return value and assert that
the passed value must not be negative.
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.

3 participants