The worst part about long lines or code or math equations are the parentheses. Nobody wants to read through 2x(3y+4*abs(x^[2*e^x])-5{3(x+y)-5})
!
So, the goal of this challenge is to make it at least slightly easier to read these parentheses-filled beasts! For the above math equation, the output should be:
2x (
3y+4*abs (
x^ [
2*e^x
]
)
-5 {
3 (
x+y
)
-5
}
)
A parenthesis is defined as either of these characters: ()[]{}
. Indents should each be two spaces, and there should be one space of seperation between the expression and the parenthesis: 2x (
, x^ [
as some examples.
I would like to debut the Atomic Code Golf metric in this question. Take out all separators in your code (()[]{}. ;
to name some common ones), and then take the length of your program if every reserved word and operator were 1 character long. That is your program's score. if x**(3.2)==b[3]:print x
is 11 points: if|x|**|3|.|2|==|b|3|print|x
, or ix*3.2=b3px
. Any quick questions about the metric can be posted here; larger questions should be discussed in meta using the link above.
Lowest score wins. Good luck, have fun!
$x
one token or two? \$\endgroup\$$x
is: if it's a variable, 1 token. If it's a math operator, then 2. \$\endgroup\$