{"id":21275683,"url":"https://github.com/halimath/calculator-kata","last_synced_at":"2025-06-14T09:32:59.662Z","repository":{"id":222497298,"uuid":"754515129","full_name":"halimath/calculator-kata","owner":"halimath","description":"A coding kata for building a simple calculator for very long mathematical terms","archived":false,"fork":false,"pushed_at":"2024-02-29T14:49:22.000Z","size":6545,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T03:27:46.076Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halimath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-08T08:10:33.000Z","updated_at":"2024-02-14T13:31:13.000Z","dependencies_parsed_at":"2024-02-16T23:04:19.235Z","dependency_job_id":"4841eb36-b38b-42d0-9476-727073284c52","html_url":"https://github.com/halimath/calculator-kata","commit_stats":null,"previous_names":["halimath/calculator-kata"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fcalculator-kata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fcalculator-kata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fcalculator-kata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fcalculator-kata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halimath","download_url":"https://codeload.github.com/halimath/calculator-kata/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732303,"owners_count":20338839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-21T09:36:09.487Z","updated_at":"2025-03-15T13:13:45.680Z","avatar_url":"https://github.com/halimath.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Calculator Kata\n\nWrite a calculator that reads mathematical terms containing\nfloating point numbers, +, -, * and / as well as parenthesis. \n\nCalculate the result by applying the \"usual\" mathematical rules:\n\n* operators are used in _infix notation_: `2 + 3`\n* multiply/div have higher precedence then add/sub\n* parenthesis have higher precedence then operators\n* numbers can contain a mix of integers and floating point numbers\n* calculation should follow mathematical rules, i.e. `2 / 0` is an error and not\n  something like `NaN` or `-Inf`\n\nThe calculator should\n\n* calculate the result of a single mathematical expression (no matter how long)\n* print the result in a human readable style\n* report any error and refuse the calculation (error reporting style doesn't matter)\n* handle arbitrary long terms (i.e. tens of megabytes of input) well (i.e. in \n  terms of memory usage as well as running time)\n\n# Specification of the input language\n\nThe calculator processes input that is read as `UTF-8` encoded characters. A \nformal specification of the input language is defined by the following [EBNF]:\n\n```ebnf\n(* An expression defines the start of the production. *)\nexpr = number (* A bare number is a valid expression*)\n     | ( expr, S, operator, S, number ) (* left-recursive operator chained expression *)\n     | ( \"(\" S, expr, S, \")\" ); (* parenthesis surround an expression *)\n\n(* The list of available operators. *)\noperator = \"+\" | \"-\" | \"*\" | \"/\";\n\n(* Definition of a number - either 0.xyz or abc.xyz *)\nnumber = zero_fraction \n       | non_zero_fraction;\n\nnon_zero_fraction = non_zero_digit { digit } { \".\" digit { digit } };\n\nzero_fraction = \"0\" { \".\" digit { digit } };\n\nnon_zero_digit = \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\";\n\ndigit = \"0\" | non_zero_digit;\n\n(* Any whitespace used as a separator including none. *)\nS = \"\" | { \" \" | \"\\n\" | \"\\t\" | \"\\r\" | \"\\f\" | \"\\b\" } ;\n```\n\nNote that expressions in parenthesis can also contain parenthesis.\n\n[EBNF]: https://en.wikipedia.org/wiki/Extended_Backus–Naur_form\n\n## Examples\n\nThe following lines are all valid input sequences:\n\n```\n0\n0.123\n807.1328\n17 * 19\n(21 - 3) * 8\n```\n\n# Implementation Restrictions\n\n* Only use the standard library for the production code; do not rely on external\n  libraries (except for testing/benchmarking)\n* Apply an appropriate structure (i.e. packages, types, ...)\n* Write _idiomatic_ code\n* Write unit tests to\n\n\n# Testcases\n\nA couple of test files with increasing sizes are provided in [`testdata`](./testdata). \nThe file names roughly tell the file's sizes. You can use them for functional\nas well as for benchmark tests.\n\nThe results are\n\n* `testdata/1k` -\u003e 248253190541.03891\n* `testdata/10k` -\u003e 214512826488689376\n* `testdata/100k` -\u003e 481585283158357967896576\n* `testdata/1m` -\u003e 830415166156152287340265472\n* `testdata/10m` -\u003e 6780466519056739908798922614519103488\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalimath%2Fcalculator-kata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalimath%2Fcalculator-kata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalimath%2Fcalculator-kata/lists"}