[Community Puzzle] Expand the polynomial

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!


I need help for Coding Games and Programming Challenges to Code Better .
My code in java is ko on tests 5 and 6 of the validator.

What is different from the IDE?

Thanks for your help.

Hi there,

I’m stuck on this puzzle:

All my unit tests are ok but when I submit, the test 5 is KO.
I think it’s coming from parsing, but as we can’t see the post submission tests I can’t guess the source of the problem. So it’s impossible for me to fix it.

Any suggestion on extra edge-test input will be greatly appreciated!


any help from the author @nicola1, or the moderators who accepted it @algmyr @CyberLemonade @Wladek?


The community helped me.
A bug in my code, did not pass the test 5 and 6 of the validator
but was not detected by the test set.

Test 7 has been added
and the test 5 has been corrected to correspond to the validators test 5.

seems the test 5 is still an issue though. @Stilgart I see you updated it recently but @BFighter4935 encountered an issue.

Looking at the contribution in question Coding Games and Programming Challenges to Code Better cases 5 and 6 look fine to me. WolframAlpha also confirms that the polynomials are equal. Or was there some issue that has now been fixed?

I solved my parsing issue thank to the validator provided in the contribution page.

Thanks alot

1 Like

Hi. I am not passing validator #6 (“Cyclotomic Polynomial”). I am able to pass all the given test cases. Any hints?

Update: I figured it out.

Hi there,

for Python there seems to be a bug on test no. 3:
(2x+3)(x-2) is meant to be 2x^2-x-6
but it should be 2x^2+x-6 instead.

Actually only hard coding the solution helps …

Would be great if anyone could fix it.

Best Regards

(2x+3)(x-2) =
(2x)(x) + (2x)(-2) + (3)(x) + (3)(-2) = // Just to be very explicit
2x^2 - 4x + 3x - 6 =
2x^2 - x - 6

It is correct. Bug on your end?

1 Like

Anybody wants me to add polynomials written not ordered, for example (1+x)(2+x)?

I mean, you could. But it seems a bit odd to add cases a few months in considering already accepted solution will not be re-evaluated afaik.

sorry you are right. The bug was on my side.

Should have listen to my teacher:
Don’t drink and derive

Thanks for your fast reply
Best Regards

still better for new players though, isn’t it?

thank you for this contribution even if i think it should be in medium section.
Why don’t you make a new version in higher difficulty witch includes any valid expression.
al expressions should be correct but they can be in any form:

  • not ordered
  • parenthesis sum and substruct not only multyplication
  • no reduced expression
    ex: (-1+3x^4-x^4)-(x+2)(x^2-x^4)…
    expression could be longer

I bet that it won’t change my solution. :wink: