# [Community Puzzle] Factorials of primes decomposition

Hello, i pass the 3 first test cases with succes, but none in the validator cases, can i have an idea about the validators, or only one of them.

1 Like

I think no one will give here any validator.

May I suggest you to : wait to pass all the test case before submitting and, if needed, ask help directly on #world or #fr or any other channel you want.

1 Like

Iâ€™m in a similar boat, but Iâ€™m passing all the test cases and for some reason Iâ€™m failing the last validator. I think my code is pretty robust to different combinations to numerators and denominators, but apparently not.

Sorry, Iâ€™m a bit of a codingame newbie, and donâ€™t know what this means. Is that related to IRC? I googled #world and it linked back to this forum post.

The way you have to tackle this is to convert your value into factors of primes, take the largest one and use it as a factorial and then work down from there, note the lowest factorials are 5 : 120, 3 : 6 and 2 :2. I am having trouble using my Python program, the compiler seems to have run out of indentation lines to allocate because I have more than 150 lines of code. How can I ensure it has enough memory or space to complete?

Have you tried your script at home?

Yes it took a long time to develop, now I think it works perfectly(perhaps). Send me some test cases I will return the solutions. I will rewrite it later in C to get it to work on Codinggames.

120
â†’5#1
54
â†’3#3 2#-2
5020
â†’251#1 241#-1 83#-1 79#1 61#-1 59#1 31#-1 29#1 19#-1 17#1 13#-1 11#-1 5#4 3#6 2#3
1/40320
â†’7#-1 2#-3
96/143
â†’13#-1 7#1 5#1 3#3 2#5

I get correct answers immediately for 120, 54 and 96/143, because of the geometric nature of calculating factorials and my program requires its calculation locally the solution for 5020 is correct but takes over 2 minutes. I would not attempt 40320 in terms of time because to cover all possibilities the program needs to cover all primes and their factorials upto the value.

Thats the progress so far.

Maybe you are beginning your calculations from the wrong side.

you were so right, I have to generate the factorials after I know the max prime I am to use. Now I get the answer for 5020 immediately and 1/40320 in 3s.

Give me some more to answer without giving the answers, I will send the solns.

3 s for 40320? Look at the primes involved: they are are below 11.

Hello,
I am trying to solve this puzzle ( factorial of primes decomposition)
and in fact I wrote some code which solves all the tests, but fails to solve 2 of the validators
(power of factorial and fraction)
the equivalents ( as already said ) are PASSED.

Any Idea how to investigate

I checked that my program gives the right solution to the examples given in this article and it does.
I donâ€™t think there is any performance issue since the program is quite fast for the examples I did test.
but still these 2 validators failing. Any suggestion on how to find out what is failing ( I understand why validators do not give any tracesâ€¦ but itâ€™s very frustrating for finding my â€śbugâ€ť without knowing the input data failing
any help on how to proceed is welcome.

Power of factorial is something like (5!)^4.
Fraction involves negative exponents.

2 Likes

Thanks a lot,
that was exactly what I was looking for I found 2 bugs in my code

and now itâ€™s 100%Pass
great puzzle and definitely great help

2 Likes

Hi Nicola,
Iâ€™m in the same boat, passing all tests but failing validators 3 and 6.
Your comments are pertinent to these two cases but, keeping in mind the constraint that 0 < N, numerator, denominator < 20,000:

• For powers of factorials, there arenâ€™t that many below 20,000 so I tried all of them manually and all my attempts succeed, so I donâ€™t know why the validator fails;
• You mention that Fraction has negative elements but isnâ€™t that a violation of the above constraint? Suppose, there is such violation, how should I format a negative result? Should I use parentheses, such as in -(3#2 4#1) ? If you only refer to negative exponents, then this is taken care of and the negative exponents appear properly. Also, the code passes all of your above examples as well.

There are no negative inputs. Answers may contain negative powers, though.