{"id":32383729,"url":"https://github.com/jacadzaca/zadanko","last_synced_at":"2026-05-17T15:09:38.995Z","repository":{"id":192368702,"uuid":"459338434","full_name":"jacadzaca/zadanko","owner":"jacadzaca","description":"a set of python3 scripts that generate math worksheets with answers.","archived":false,"fork":false,"pushed_at":"2022-02-19T14:12:13.000Z","size":31,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-25T02:01:24.770Z","etag":null,"topics":["generate","generator","latex","math","sympy","worksheet"],"latest_commit_sha":null,"homepage":"https://jacadzaca.github.io/blog/generating_a_maths_worksheet.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacadzaca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-14T21:57:19.000Z","updated_at":"2025-06-08T19:36:34.000Z","dependencies_parsed_at":"2023-09-04T13:41:58.398Z","dependency_job_id":null,"html_url":"https://github.com/jacadzaca/zadanko","commit_stats":null,"previous_names":["jacadzaca/zadanko"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jacadzaca/zadanko","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacadzaca%2Fzadanko","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacadzaca%2Fzadanko/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacadzaca%2Fzadanko/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacadzaca%2Fzadanko/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacadzaca","download_url":"https://codeload.github.com/jacadzaca/zadanko/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacadzaca%2Fzadanko/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33143276,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generate","generator","latex","math","sympy","worksheet"],"created_at":"2025-10-25T02:00:07.123Z","updated_at":"2026-05-17T15:09:38.978Z","avatar_url":"https://github.com/jacadzaca.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## About\nThis repository contains code for 'zadanko' - a set of python3 scripts that generate math worksheets with answers.\n\n## Requirements\n- python3\n- [sympy](https://www.sympy.org/en/index.html)\n- [jinja2](https://jinja.palletsprojects.com/)\n- a LaTeX compiler (e.g. [pdflatex](https://man.archlinux.org/man/pdftex.1))\n- some-kind of a document viewer (e.g. [zathura](https://pwmt.org/projects/zathura/))\n\n## Installation\nFirst ensure you have pdflatex and a document viewer\n```bash\napt install texlive-latex-base texlive-fonts-recommended zathura # debian et al.\npacman -Syy texlive-most zathura # arch\n```\nInstall zadanko:\n```bash\ngit clone https://github.com/jacadzaca/zadanko \u0026\u0026 cd zadanko \u0026\u0026 python3 -m pip install -r requirements.txt .\n```\n\n## Examples\n##### [Generate a worksheet on quadratics](https://raw.githubusercontent.com/jacadzaca/zadanko/master/examples/generate_quadratics_worksheet.py)\n\n```python\n#!/usr/bin/env python3\nimport random\nimport collections\n\nimport sympy\nfrom jinja2 import Environment, PackageLoader\n\nfrom zadanko import quadratics\n\nTask = collections.namedtuple('Task', ['instruction', 'problems', 'awnsers'])\n\nENV = Environment(\n    loader=PackageLoader('zadanko'),\n    trim_blocks=True,\n    lstrip_blocks=True)\n\ndef generate_quadratics_task():\n    # generate diffrent kinds of quadratic equations\n    zero_solutions_quadratics = [quadratics.generate_quadratic_zero_solutions() for _ in range(10)]\n    one_solution_quadratics = [quadratics.generate_quadratic_one_solution() for _ in range(10)]\n    two_solutions_quadratics = [quadratics.generate_quadratic_two_solutions() for _ in range(6)]\n    # sort them according to 'difficulty' - the greater the sum of quadratic's coefficients, the more difficult it is\n    zero_solutions_quadratics.sort(key=quadratics.quadratic_difficulty_comperator)\n    one_solution_quadratics.sort(key=quadratics.quadratic_difficulty_comperator)\n    two_solutions_quadratics.sort(key=quadratics.quadratic_difficulty_comperator)\n\n    # arrange the problems in random order, but try to keep the problem's difficulty incremental\n    problems = []\n    problem_lists = [zero_solutions_quadratics, one_solution_quadratics, two_solutions_quadratics]\n    for _ in range(sum(map(len, problem_lists))):\n        choice = random.choice(problem_lists)\n        problems.append(choice.pop())\n        if not choice:\n            problem_lists.remove(choice)\n\n    # generate the awnsers with sympy https://docs.sympy.org/latest/index.html\n    awnsers = (sympy.printing.latex((sympy.solvers.solveset(quadratic, domain=sympy.S.Reals))) for quadratic in problems)\n    # generate LaTeX code\n    problems = map(sympy.printing.latex, problems)\n    return Task('Find the roots of function $f$, given by expression:', problems, awnsers)\n\nif __name__ == '__main__':\n    #output latex code\n    latex = ENV \\\n            .get_template('problem_sheet.jinja.tex') \\\n            .render(tasks=[generate_quadratics_task()])\n    print(latex)\n```\n\n##### [Generate a worksheet on differentiation](https://raw.githubusercontent.com/jacadzaca/zadanko/master/examples/generate_differentiation_worksheet.py)\n\n```python\n#!/usr/bin/env python3\nimport itertools\nimport collections\n\nimport sympy\nfrom jinja2 import Environment, PackageLoader\n\nfrom zadanko import elementary_functions\n\nTask = collections.namedtuple('Task', ['instruction', 'problems', 'awnsers'])\n\nENV = Environment(\n    loader=PackageLoader('zadanko'),\n    trim_blocks=True,\n    lstrip_blocks=True)\n\ndef take(iterable, n):\n    \"Return first n items of the iterable as a list\"\n    return list(itertools.islice(iterable, n))\n\ndef generate_differentiation_task():\n    # generate 10 elementary functions that are made out of 2 composite functions and append them to the problem list\n    differentiation_problems = take(elementary_functions.elementary_function_generator(2), 10)\n    # generate 10 elementary functions that are at most made out of 2 composite functions and then append the multiplication of them to the problem list\n    for function, function1 in zip(take(elementary_functions.elementary_function_generator(2), 10), take(elementary_functions.elementary_function_generator(2), 10)):\n        differentiation_problems.append(function * function1)\n    # generate 6 elementary functions that are madeout of 3 composite functions and append them to the problem list\n    differentiation_problems += take(elementary_functions.elementary_function_generator(3), 6)\n    # sort them by how 'complicated' they are - the more 'composite', the later it's in the list\n    differentiation_problems.sort(key=sympy.count_ops)\n    # differentiate and generate LaTeX code\n    awnsers = (sympy.printing.latex(function.diff()) for function in differentiation_problems)\n    # generate LaTeX code for problem statments\n    differentiation_problems = map(sympy.printing.latex, differentiation_problems)\n    return Task('Find the derivative of function $f$, given by expression:', differentiation_problems, awnsers)\n\nif __name__ == '__main__':\n    # output the LaTeX code\n    latex = ENV \\\n            .get_template('problem_sheet.jinja.tex') \\\n            .render(tasks=[generate_differentiation_task()])\n    print(latex)\n```\n\n##### [Generate a worksheet on integration](https://raw.githubusercontent.com/jacadzaca/zadanko/master/examples/generate_integration_worksheet.py)\n\n```python\n#!/usr/bin/env python3\nimport collections\nimport itertools\n\nimport sympy\nfrom jinja2 import Environment, PackageLoader\n\nfrom zadanko import elementary_functions\n\nTask = collections.namedtuple('Task', ['instruction', 'problems', 'awnsers'])\n\nENV = Environment(\n    loader=PackageLoader('zadanko'),\n    trim_blocks=True,\n    lstrip_blocks=True)\n\n# https://docs.python.org/3/library/itertools.html#itertools-recipes\ndef take(iterable, n):\n    \"Return first n items of the iterable as a list\"\n    return list(itertools.islice(iterable, n))\n\ndef generate_integration_task():\n    # generate awnsers first - it's easier to ensure the problems will be integrable that way\n    awnsers = take(filter(lambda expr: expr.diff() != 1, elementary_functions.elementary_function_generator(2)), 16)\n    random_functions = itertools.cycle(elementary_functions.elementary_function_generator(1))\n    awnsers += ((left_func * right_func) for left_func, right_func in zip(take(random_functions, 10), take(random_functions, 10)))\n    awnsers.sort(key=sympy.count_ops)\n    # generate problems\n    problems = (sympy.printing.latex(function.diff()) for function in awnsers)\n    awnsers = map(sympy.printing.latex, awnsers)\n\n    return Task('Integrate function $f$, given by expression:', problems, awnsers)\n\nif __name__ == '__main__':\n    latex = ENV \\\n            .get_template('problem_sheet.jinja.tex') \\\n            .render(tasks=[generate_integration_task()])\n    print(latex)\n```\n\n##### [Generate a worksheet that is the combination of the above worksheets](https://raw.githubusercontent.com/jacadzaca/zadanko/master/examples/generate_combination_worksheet.py)\n\n```python\n#!/usr/bin/env python3\n# keep in mind this depends on the previous scripts\n\nfrom jinja2 import Environment, PackageLoader\n\nfrom generate_quadratics_worksheet import generate_quadratics_task\nfrom generate_differentiation_worksheet import generate_differentiation_task\nfrom generate_integration_worksheet import generate_integration_task\n\nENV = Environment(\n    loader=PackageLoader('zadanko', 'templates'),\n    trim_blocks=True,\n    lstrip_blocks=True)\n\nif __name__ == '__main__':\n    latex = ENV \\\n            .get_template('problem_sheet.jinja.tex') \\\n            .render(tasks=[generate_quadratics_task(), generate_differentiation_task(), generate_integration_task()])\n    print(latex)\n```\n\nTo compile use:\n```bash\nchmod +x example.py \u0026\u0026 ./example.py | pdflatex --jobname worksheet --output-directory /tmp \u0026\u0026 zathura /tmp/worksheet.pdf\n```\nSee [examples](https://github.com/jacadzaca/zadanko/tree/master/examples) for more\n\n## Legal Note\nThe code is licensed under [GPL 3.0](https://www.gnu.org/licenses/gpl-3.0.txt).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacadzaca%2Fzadanko","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacadzaca%2Fzadanko","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacadzaca%2Fzadanko/lists"}