Datasets:
Download code/generators/sequences.py from ahmed-wez/hidden-capability-math: direct link, hf CLI and curl.
- Browser
- Download file 3.92 kB
-
https://huggingface.co/datasets/ahmed-wez/hidden-capability-math/resolve/main/code/generators/sequences.py
- Command line
-
hf download hf://datasets/ahmed-wez/hidden-capability-math/code/generators/sequences.py
-
curl -L -o sequences.py https://huggingface.co/datasets/ahmed-wez/hidden-capability-math/resolve/main/code/generators/sequences.py
3.92 kB
| from common import register | |
| D = 'sequences' | |
| def add(n, c, t, s, e, **kw): | |
| register(D, n, c, t, s, e, **kw) | |
| add('arithmetic_term', [['An arithmetic sequence has first term {a} and common difference {d}.', 'Start an arithmetic sequence at {a}, adding {d} at each step.', 'The first entry is {a}; consecutive entries increase by {d}.'], ['Use the index n = {n}.', 'The requested term number is {n}.', 'Count terms starting at one, up to term {n}.']], ['What is the nth term?', 'Find the term at this index.', 'Determine the specified entry.'], lambda r: dict(a=r.randint(3, 80), d=r.randint(2, 19), n=r.randint(8, 70)), [('increment', '(n-1)*d'), ('answer', 'a+increment')], level='easy') | |
| add('second_order', [['A sequence has a_0 = {a}, a_1 = {b}, and a_n = a_(n-1) + a_(n-2) for n >= 2.', 'Begin with a_0 = {a} and a_1 = {b}; every later term is the sum of its two predecessors.', 'The initial terms indexed 0 and 1 are {a} and {b}; use a_n = a_(n-1) + a_(n-2) from n = 2 onward.'], ['Use index {n}.', 'The target index is {n}.', 'Work up to n = {n}.']], ['What is a_n at that index?', 'Find the specified term.', 'Determine the term at the stated index.'], lambda r: dict(a=r.randint(2, 35), b=r.randint(2, 40), n=r.randint(6, 18)), [('first_weight', 'fibonacci(n-1)'), ('second_weight', 'fibonacci(n)'), ('answer', 'first_weight*a+second_weight*b')], level='hard', depth=4) | |
| add('quadratic_differences', [['A sequence has a_1 = {a}; its differences satisfy a_(k+1) - a_k = {b}*k + {c} for k >= 1.', 'Begin at a_1 = {a}; moving from term k to term k+1 adds {b}*k + {c}.', 'The first term is {a}, and the kth successive difference is {b}*k + {c}.'], ['Use the term number {n}.', 'The desired index is {n}.', 'Take n = {n}.']], ['What is a_n?', 'Find the specified term.', 'Determine the sequence value at this index.'], lambda r: dict(a=r.randint(2, 35), b=r.randint(2, 15), c=r.randint(2, 20), n=r.randint(8, 50)), [('sum_indices', 'n*(n-1)/2'), ('answer', 'a+b*sum_indices+c*(n-1)')], level='medium', depth=3) | |
| add('telescoping_sum', [['For k >= 1, let a_k = 1/((k + {h})*(k + {h} + 1)).', 'Define a_k as the reciprocal of (k + {h})*(k + {h} + 1), for positive k.', 'The sequence is a_k = 1/((k + {h})*(k + {h} + 1)), indexed from k = 1.'], ['Sum through index {n}.', 'Include indices 1 through {n}.', 'Take the first {n} terms.']], ['What is the exact sum?', 'Find the partial sum as an exact fraction.', 'Determine the total exactly.'], lambda r: dict(h=r.randint(2, 40), n=r.randint(10, 150)), [('first_endpoint', '1/(h+1)'), ('answer', 'first_endpoint-1/(h+n+1)')], level='hard', depth=3, concepts=3) | |
| add('weighted_arithmetic_sum', [['Let a_k = {a} + (k-1)*{d}, for positive k.', 'An arithmetic sequence starts at {a} with common difference {d}.', 'The kth entry, starting at k = 1, equals {a} + (k-1)*{d}.'], ['Use weights k on terms k = 1 through {n}.', 'Multiply each of the first {n} terms by its index.', 'For indices 1 through {n}, weight each term by its term number.']], ['What is the sum of the weighted terms?', 'Find the sum of k*a_k over these indices.', 'Determine the total after applying these weights.'], lambda r: dict(a=r.randint(2, 30), d=r.randint(2, 15), n=r.randint(8, 70)), [('sum_k', 'n*(n+1)/2'), ('sum_k_squared', 'n*(n+1)*(2*n+1)/6'), ('answer', '(a-d)*sum_k+d*sum_k_squared')], level='medium', depth=4, concepts=3) | |
| add('square_increment_recurrence', [['Let a_0 = {a} and a_k = a_(k-1) + {c}*k^2 for k >= 1.', 'Start at a_0 = {a}; on step k add {c} times k squared.', 'The initial value is {a}, and the kth update increases the value by {c}*k^2.'], ['Perform {n} updates.', 'Use index n = {n}.', 'Continue through step {n}.']], ['What is a_n?', 'Find the final sequence value.', 'Determine the term after these updates.'], lambda r: dict(a=r.randint(2, 40), c=r.randint(2, 15), n=r.randint(8, 60)), [('sum_squares', 'n*(n+1)*(2*n+1)/6'), ('answer', 'a+c*sum_squares')], level='easy') | |