3 ms·
Am I doing something wrong? I get 94.9% for 243/256 243 is pretty good. You have to go up to 3^17 = 129140163 < 2^27 = 134217728 to beat it: 1
by zellyn 2y ago
Am I doing something wrong? I get 94.9% for 243/256
243 is pretty good. You have to go up to 3^17 = 129140163 < 2^27 = 134217728 to beat it:
1 3 4 2 1 75.0%*
2 9 16 4 7 56.2%
3 27 32 5 5 84.4%*
4 81 128 7 47 63.3%
5 243 256 8 13 94.9%*
6 729 1024 10 295 71.2%
7 2187 4096 12 1909 53.4%
8 6561 8192 13 1631 80.1%
9 19683 32768 15 13085 60.1%
10 59049 65536 16 6487 90.1%
11 177147 262144 18 84997 67.6%
12 531441 1048576 20 517135 50.7%
13 1594323 2097152 21 502829 76.0%
14 4782969 8388608 23 3605639 57.0%
15 14348907 16777216 24 2428309 85.5%
16 43046721 67108864 26 24062143 64.1%
17 129140163 134217728 27 5077565 96.2%*
18 387420489 536870912 29 149450423 72.2%
19 1162261467 2147483648 31 985222181 54.1%
20 3486784401 4294967296 32 808182895 81.2%
21 10460353203 17179869184 34 6719515981 60.9%
22 31381059609 34359738368 35 2978678759 91.3%
23 94143178827 137438953472 37 43295774645 68.5%
24 282429536481 549755813888 39 267326277407 51.4%
25 847288609443 1099511627776 40 252223018333 77.1%
26 2541865828329 4398046511104 42 1856180682775 57.8%
27 7625597484987 8796093022208 43 1170495537221 86.7%
28 22876792454961 35184372088832 45 12307579633871 65.0%
29 68630377364883 70368744177664 46 1738366812781 97.5%*
30 205891132094649 281474976710656 48 75583844616007 73.1%
31 617673396283947 1125899906842624 50 508226510558677 54.9%
32 1853020188851841 2251799813685248 51 398779624833407 82.3%
33 5559060566555523 9007199254740992 53 3448138688185469 61.7%
34 16677181699666569 18014398509481984 54 1337216809815415 92.6%
35 50031545098999707 72057594037927936 56 22026048938928229 69.4%
36 150094635296999121 288230376151711744 58 138135740854712623 52.1%
37 450283905890997363 576460752303423488 59 126176846412426125 78.1%
38 1350851717672992089 2305843009213693952 61 954991291540701863 58.6%
39 4052555153018976267 4611686018427387904 62 559130865408411637 87.9%
Generated with this:
max_use = 0
for i in range(1, 40):
trinary = 3**i
power = math.ceil(math.log2(trinary))
binary = 2**int(power)
diff = binary - trinary
use = (trinary / binary)
max_star = ''
if use > max_use:
max_use = use
max_star = '*'
print(f' {i:2} {trinary:19} {binary:19} {power:2} {diff:18} {use:.1%}{max_star}')
- nayuki 2y ago> I get 94.9% for 243/256 You're looking at the alphabet utilization rate. Whereas the standard way to measure efficiency (which is the way that the author did it) is to look at entropy. Here's how I would phrase it. Obviously, if you have a message that has 256 possible states and each one has the same probability of occurring, then the entropy is 8 bits per message. If you have a message having 243 uniformly distributed states, then its entropy is defined as log base-2 of 243 = log_2 (243) = ln(243) / ln(2) ≈ 7.925 bits. But if you used 8 bits to express this message, then you've wasted 0.075 bits (or 75 millibits, mb) per message, so your efficiency is 7.925/8 ≈ 99.06%. How would you achieve 7.925 bits per message in practice? By packing more messages together and sharing wasted space. By using some continued fraction magic, let me proposed to store 15867× of these base-243 messages together. There are 243^15867 possibilities, which is approximately equal to 2^125742.999994713, or just a hair under 125743 bits. So, a block of 125743 bits can store 15867× base-243 messages losslessly, which means each base-243 message uses 125743/15867 ≈ 7.925 bits on average.
- zellyn 2y agoAh, thanks!