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.
Hi! I wrote the function and everything works! I check in Visual Code on Ubuntu 24.04.1 LTS and everything counts fine!
But when running the test at x=4, the function outputs a value of 2150 instead of 1675. Python version 3.11. Everything works locally... it gives a strange result when checking. What is my mistake? Thanks
Hi! An error is issued:
poly = 3a+b+4ac+bc-ab+3a-cb-a-a
Sorry :( : 'b+4a-ab+4ac' should equal '4a+b-ab+4ac'
by the condition of the problem, this is true! 'b+4a-ab+4ac'
poly = -8fk+5kv-4yk+7kf-qk+yqv-3vqy+4ky+4kf+yvqkf
Sorry :( : '-kq+3fk+5kv-2qvy+fkqvy' should equal '3fk-kq+5kv-2qvy+fkqvy'
by the condition of the problem, this is true! '-kq+3fk+5kv-2qvy+fkqvy'
A clear question formation always allows you to find the answer. In this kata, the question is completely incomprehensible and clumsy. Solved by poking
There is no explanation for this kata. The question should be clear! If you can't ask a question, give some examples that will help you understand what you need.
What exactly did you misunderstand about the kata?
100%
Thanks! I can't keep up with the time now. I will decide! An interesting task!
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.Hi! I wrote the function and everything works! I check in Visual Code on Ubuntu 24.04.1 LTS and everything counts fine!
But when running the test at x=4, the function outputs a value of 2150 instead of 1675. Python version 3.11. Everything works locally... it gives a strange result when checking. What is my mistake? Thanks
Nothing will prepare you better for a career in development than requirements like this :D
duplicate of this issue
duplicate of this issue
Solved the problem. The question arose due to a misunderstanding. Clear question == clear answer.
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
.Hi! An error is issued:
poly = 3a+b+4ac+bc-ab+3a-cb-a-a
Sorry :( : 'b+4a-ab+4ac' should equal '4a+b-ab+4ac'
by the condition of the problem, this is true! 'b+4a-ab+4ac'
poly = -8fk+5kv-4yk+7kf-qk+yqv-3vqy+4ky+4kf+yvqkf
Sorry :( : '-kq+3fk+5kv-2qvy+fkqvy' should equal '3fk-kq+5kv-2qvy+fkqvy'
by the condition of the problem, this is true! '-kq+3fk+5kv-2qvy+fkqvy'
Fix it or test it or tell me where I'm wrong.
OP passed the kata, closing.
A clear question formation always allows you to find the answer. In this kata, the question is completely incomprehensible and clumsy. Solved by poking
A clear question formation always allows you to find the answer. In this kata, the question is completely incomprehensible and clumsy.
There is no explanation for this kata. The question should be clear! If you can't ask a question, give some examples that will help you understand what you need.