|
Download math/math-0151.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/034ba678829a1c436b19d43dd3adab33b5170a80/math/math-0151.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@034ba678829a1c436b19d43dd3adab33b5170a80/math/math-0151.jsonl
-
curl -L -o math-0151.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/034ba678829a1c436b19d43dd3adab33b5170a80/math/math-0151.jsonl
1.42 kB
| {"type": "session", "harness": "opencode", "id": "math-0151", "name": "Bit Manipulation Mathematics"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert mathematician and programmer."}} | |
| {"type": "message", "message": {"role": "user", "content": "Explain bit manipulation mathematics deeply"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "Popcount: number of set bits. Kernighan: x & (x-1) clears lowest set bit. Loop until x=0 counts bits.\n\nXOR properties: a^a=0, a^0=a, commutative/associative. Missing number in 1..n: XOR all nums and indices. Single number appearing once: XOR all.\n\nIsolate lowest set bit: x & (-x). Highest set bit: 1 << (31 - __builtin_clz(x)).\n\nBitmasks for subsets: iterate subsets of {0..n-1}: for(mask=0; mask<(1<<n); mask++) for(i=0; i<n; i++) if(mask&(1<<i)).\n\nSubsets of submasks: for(sub=mask; sub; sub=(sub-1)&mask) iterates all non-empty submasks. Total: 3^n over all masks.\n\nGosper's hack: next number with same popcount. x += x & (-x); x |= (((x & (-x)) / (x & (-x))) >> 1) - 1. Used for iterating subsets of fixed size.\n\nBit DP: dp[mask] = best value for subset mask. TSP: dp[mask][i] = min cost visiting mask ending at i. O(n^2 * 2^n).\n\nPopulation count parity: XOR all bits. Useful for parity checks, Gray code conversion.\n\nBit reversal: for i in 0..n-1: rev[i] = rev[i>>1]>>1 | ((i&1) << (log2n-1)). Used in FFT."}} | |