-
-
Save agawley/33e0c3807e66b545b07f6361dc92a86b to your computer and use it in GitHub Desktop.
Cassidoo 2026-06-29
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
| from math import floor, log2 | |
| def getBits(val): | |
| if val == 0: | |
| return 1 | |
| return floor(log2(val)) + 1 | |
| def sumBits(val): | |
| sum = 0 | |
| for a in range(val): | |
| sum += getBits(a) | |
| return sum / val | |
| print(sumBits(6)) | |
| print(sumBits(12)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment