How do you take a number representing a list of items, and divide it into chunks, where the number of chunks is a power-of-two, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, so 1, 2, 4, 8, 16, 32, 32 being the […]

- Tags _y_, _z_, -32, ?] ... f2 = [32, ?] Then once we have _x_, ..., ... 32 total of these, 'o', "\t", "w", (v, $m, 0, 0] } let array = [] let r = split(n) while (r[0] > 31) { array.push([32, 0] let u = 32 let i = 0 while (u > 0) { while (n >= u) { r[i]++ n -= u } i += 1 u >>= 1 } return r } f, 0]) r[0] -= 32 } array.push(r) let s = sum(r) if (!isPowerOf2(s)) { let x = pow2ceil(s) let i = 1 while (i < 5) {, 1, 1. Yes, 1] // no, 1] 16: [16] 18: [16, 1] is better because it's shorter. I guess an even better one (after getting comments) would be this, 1] Nope that doesn't work. Because the size of the array is 3 which is not a power of two, 1] That also works, 1] That one is short, 1] That works because both numbers are powers of two, 1] That works! It's 4 elements which is a power of two. [2, 16, 2, 2] 15: [8, 2] 200: [32, 3 not power of 2 14: [8, 32 being the max)? Is this even possible? So for example, 32) } } function sum(arr) { let i = 0 arr.forEach(x => { i += x }) return i } function split(n) { const r = [0, 32)? Update: I think trying to incorporate this somehow to build up that nested tree I'm trying to describe will help. The last thing now m, 32] // child "b" is 8 in length b = [32, 4, 4 is power of 2 [8, 4] But now the bucket size is 40 items long, 4] Taken another layer up, 4] When the size of the first layer of buckets in the bucket tree grows to longer than 32, 5 not power of 2 [8, 6 not power of 2 [8, 8, 8 items could be divided into 1 bucket (power of two bucket) with 8 items (power of two items): [8] 9 items could be: [8, A2, and also starts with the largest number. So following this pattern, and divide it into chunks, and the size of the array is 2 (also a power of two). Let's try 11: [8, AND where each chunk also has a power-of-two number of items (where size goes up to a max power of two, B, b] // child "a" is 32 in length a = [32, b2, but we will also have a y that is at least 1. _x_ = [a, c--, c2, d, d2, e, e2), even though it adds to 11. How about this? [4, f: '' }, f2] _y_ = [a3] a = [32, g, H, here are some other numbers: 13: [8, How do you take a number representing a list of items, i, i + size); result.push(chunk) } if (result.length > size) { return divide(result, I think you can get the gist of what I mean though. // the parent "x" is 2 in length x = [a, j, K, L)?, n, P, Q, r, s, say we have a very large number (I don't know what the minimum large number is) that requires another layer of nesting. What we can say about, since there are 8 buckets (8 is a power of two), size) { const result = [] const upSize = data.length / size; for (let i = 0; i < data.length; i += size) { const chunk = data.slic, size) } return result; }, so 1, so sorry if this isn't a perfect example, then it nests. So take the number 1234 for example. This can be represented by 38 32's followed by 16 followed by 4. [32, though I didn't see it the first time around: [8, U, up to a max (in this case, we build another layer on top. What is an algorithm/equation that will take a number and divide it into this tree of buckets / item sizes th, where the number of chunks is a power-of-two, which isn't a power of two AND it's greater than 32. So it should be nested! I can't quite visualize this in my head, with 1 or 2 items each (each a power of two). But [4, X, x will be 32 in length, y, z