What exactly did you misunderstand about the kata?
100%
Do not use global variables. The initial value of result will not be 0 when your solution is invoked several times. Move result inside your function and use nonlocal in your nested function.
result
0
nonlocal
Nothing will prepare you better for a career in development than requirements like this :D
You haven't implemented this case:
If two monomials have the same number of variables, they appears in lexicographic order, e.g.: "a+ca-ab" -> "a-ab+ac", "xzy+zby" ->"byz+xyz"
"a+ca-ab" -> "a-ab+ac"
"xzy+zby" ->"byz+xyz"
In the first example, 4a should come first before b since a < b in lexicographical order. Same with the second example, fk < kq.
4a
b
a
fk
kq
Loading collection data...
What exactly did you misunderstand about the kata?
100%
Do not use global variables. The initial value of
result
will not be0
when your solution is invoked several times. Moveresult
inside your function and usenonlocal
in your nested function.Nothing will prepare you better for a career in development than requirements like this :D
You haven't implemented this case:
In the first example,
4a
should come first beforeb
sincea
<b
in lexicographical order. Same with the second example,fk
<kq
.