Created
February 10, 2018 20:18
-
-
Save gfredtech/30daa57d9c1165ee47fd04737aacb824 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def is_power_of_2(num): | |
| if num < 2: | |
| return False | |
| power = int(math.log(num, 2) + 0.5) | |
| return 2 ** power == num | |
| def func(x, y): | |
| maxx = max(len(x), len(y)) | |
| if len(x) == len(y) and is_power_of_2(len(x)): | |
| return x, y | |
| while not is_power_of_2(maxx): | |
| maxx += 1 | |
| return ([0] * (maxx - len(x))) + x, ([0] * (maxx - len(y))) + y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment