6
1
Challenge
The goal of this challenge is to take a radical and convert it to a reduced and entire radical, and a real number. You do not have to convert it to all 3, however, you will get bonus points for converting it to 2 or 3 of them. You will also get bonus points if your code works not just with square roots. How the input works is your choice. You don't have to parse the input so you could just have it as a function. If your unable to output the root symbol (√) then you could output it as sqrt(x)
or cuberoot(x)
. You could also use a superscript (²√) for the index of the radical.
Rules
- If you just output one of the 3 options, then you can't just output it without converting it (ie: if the input is
√125
then you can't just output√125
back). - The entire radical must have no co-efficient.
- The mixed radical must have a coefficient (if there is no coefficient, then it should be
1
). - The real number (or result of the radical) should have as many decimals as possible.
Example
Here's an example output for the square root of 125 (√125):
Entire radical: √125
Mixed radical: 5√5
Real number: 11.18033988749895
Scoring
- 10% off your score for outputting 2 of either an entire radical, mixed radical, or real number.
- 30% off your score for outputting all 3 (entire radical, mixed radical, and real number).
- 30% off your score for working with a radical with any index
Winner
The person with the shortest code length wins. Good luck!
2What is the first enumerated rule supposed to mean? Specifically: 1. Does it imply that the solution must accept input in the form of an entire radical? 2. Is that the only input form which must be supported? 3. If a program only outputs entire radicals, and an entire radical is supplied as input, what should the program do? Not output anything? – Peter Taylor – 2014-01-15T08:42:02.320
You may also want to specify, that the coefficient for mixed radicals is not always 1 but the maximum integer value. – Howard – 2014-01-15T09:30:16.113