{"task": {"agent_timeout": 1800, "task": "polyglot_javascript_rational-numbers", "verifier_timeout": 1800, "instruction": "# Instructions\n\nA rational number is defined as the quotient of two integers `a` and `b`, called the numerator and denominator, respectively, where `b != 0`.\n\n~~~~exercism/note\nNote that mathematically, the denominator can't be zero.\nHowever in many implementations of rational numbers, you will find that the denominator is allowed to be zero with behaviour similar to positive or negative infinity in floating point numbers.\nIn those cases, the denominator and numerator generally still can't both be zero at once.\n~~~~\n\nThe absolute value `|r|` of the rational number `r = a/b` is equal to `|a|/|b|`.\n\nThe sum of two rational numbers `r\u2081 = a\u2081/b\u2081` and `r\u2082 = a\u2082/b\u2082` is `r\u2081 + r\u2082 = a\u2081/b\u2081 + a\u2082/b\u2082 = (a\u2081 * b\u2082 + a\u2082 * b\u2081) / (b\u2081 * b\u2082)`.\n\nThe difference of two rational numbers `r\u2081 = a\u2081/b\u2081` and `r\u2082 = a\u2082/b\u2082` is `r\u2081 - r\u2082 = a\u2081/b\u2081 - a\u2082/b\u2082 = (a\u2081 * b\u2082 - a\u2082 * b\u2081) / (b\u2081 * b\u2082)`.\n\nThe product (multiplication) of two rational numbers `r\u2081 = a\u2081/b\u2081` and `r\u2082 = a\u2082/b\u2082` is `r\u2081 * r\u2082 = (a\u2081 * a\u2082) / (b\u2081 * b\u2082)`.\n\nDividing a rational number `r\u2081 = a\u2081/b\u2081` by another `r\u2082 = a\u2082/b\u2082` is `r\u2081 / r\u2082 = (a\u2081 * b\u2082) / (a\u2082 * b\u2081)` if `a\u2082` is not zero.\n\nExponentiation of a rational number `r = a/b` to a non-negative integer power `n` is `r^n = (a^n)/(b^n)`.\n\nExponentiation of a rational number `r = a/b` to a negative integer power `n` is `r^n = (b^m)/(a^m)`, where `m = |n|`.\n\nExponentiation of a rational number `r = a/b` to a real (floating-point) number `x` is the quotient `(a^x)/(b^x)`, which is a real number.\n\nExponentiation of a real number `x` to a rational number `r = a/b` is `x^(a/b) = root(x^a, b)`, where `root(p, q)` is the `q`th root of `p`.\n\nImplement the following operations:\n\n- addition, subtraction, multiplication and division of two rational numbers,\n- absolute value, exponentiation of a given rational number to an integer power, exponentiation of a given rational number to a real (floating-point) power, exponentiation of a real number to a rational number.\n\nYour implementation of rational numbers should always be reduced to lowest terms.\nFor example, `4/4` should reduce to `1/1`, `30/60` should reduce to `1/2`, `12/8` should reduce to `3/2`, etc.\nTo reduce a rational number `r = a/b`, divide `a` and `b` by the greatest common divisor (gcd) of `a` and `b`.\nSo, for example, `gcd(12, 8) = 4`, so `r = 12/8` can be reduced to `(12/4)/(8/4) = 3/2`.\nThe reduced form of a rational number should be in \"standard form\" (the denominator should always be a positive integer).\nIf a denominator with a negative integer is present, multiply both numerator and denominator by `-1` to ensure standard form is reached.\nFor example, `3/-4` should be reduced to `-3/4`\n\nAssume that the programming language you are using does not have an implementation of rational numbers.\n\n----\nUse the instructions above to modify the supplied files: rational-numbers.js\nDon't change the names of existing functions or classes, as they may be referenced from other code like unit tests.\nOnly use standard libraries; don't install additional packages.\n", "memory": "4g", "runnable": false, "difficulty": "medium", "language": "javascript", "cpus": 1, "instruction_truncated": false, "category": "coding-exercises", "compose": false, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "aider_polyglot", "tags": ["aider_polyglot", "exercise:rational-numbers", "javascript"]}, "runs": []}