[Community Puzzle] Continued Fractions

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Thaddy,validated by @ClawLegend,@Pukunya and @slogslog.
If you have any issues, feel free to ping them.

Hi,
Could someone explain me what is the difference between validator 7 and test 7. All tests are ok for me but validator 7 still refuses…
Thx

One difference I notice is that in validator 7, the denominator and the numerator have a common factor greater than 1. Not sure if that helps you in any way.

same problem for me

Thanks for this puzzle! It’s fun and instructive.

I have one tiny teeny criticism about the statement.

In Constraints it says:

0 < q ≤ 1,000,000

This explicitly allows q=1. In that case (and in the more general case where q divides p), the given input fraction is an integer. Which means the continued fraction would have only one term.

There is nothing in the statement that either:

  • Suggests that there will be no integer fractions in the test cases; or
  • Explain what the notation is for the continued fraction of an integer ([x; ]? [x]?).