|
Download math/math-0160.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/1c6bb525d6b4b9cdb15d2a75d54734eb29bbb8cb/math/math-0160.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@1c6bb525d6b4b9cdb15d2a75d54734eb29bbb8cb/math/math-0160.jsonl
-
curl -L -o math-0160.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/1c6bb525d6b4b9cdb15d2a75d54734eb29bbb8cb/math/math-0160.jsonl
1.5 kB
| {"type": "session", "harness": "opencode", "id": "math-0160", "name": "Extended Euclidean Algorithm Implementations"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert mathematician and programmer."}} | |
| {"type": "message", "message": {"role": "user", "content": "Show extended Euclidean algorithm implementations"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "Recursive C++:\ntuple<long long, long long, long long> extgcd(long long a, long long b) {\n if (b == 0) return {a, 1, 0};\n auto [g, x, y] = extgcd(b, a % b);\n return {g, y, x - (a/b)*y};\n}\n\nIterative C++ (preferred, no stack overflow):\nlong long extgcd(long long a, long long b, long long &x, long long &y) {\n long long old_r = a, r = b;\n long long old_s = 1, s = 0;\n long long old_t = 0, t = 1;\n while (r != 0) {\n long long q = old_r / r;\n tie(old_r, r) = make_pair(r, old_r - q * r);\n tie(old_s, s) = make_pair(s, old_s - q * s);\n tie(old_t, t) = make_pair(t, old_t - q * t);\n }\n x = old_s; y = old_t;\n return old_r; // gcd\n}\n\nModular inverse:\nlong long modinv(long long a, long long m) {\n long long x, y;\n long long g = extgcd(a, m, x, y);\n if (g != 1) return -1; // no inverse\n return (x % m + m) % m;\n}\n\nLinear Diophantine:\nbool diophantine(long long a, long long b, long long c, long long &x, long long &y) {\n long long g = extgcd(a, b, x, y);\n if (c % g != 0) return false;\n x *= c/g; y *= c/g;\n return true;\n}"}} | |