6 kyu

Fraction to periodic decimal

95 of 104blr_Oliver
Description
Loading description...
Mathematics
View
AllIssues2QuestionsSuggestions3Show Resolved
  • Please sign in or sign up to leave a comment.
  • o2001 Avatar

    Fork of eurydice5717's translation that resolves this issue caused by overflow. Each call to generate a random value now constructs its own int distribution, removing the arithmetic and guaranteeing that the numbers are in range.

  • michael_wu Avatar

    C++ version. Contrary to the description, negative arguments are fed to the function. The expected results for negative fractions look strange: Incorrect result for fractionToPeriodic(-1689246217, 36291): Expected: equal to "-46547.(-2-4-90-9-7-5-7-2-400-...)"

  • eurydice5717 Avatar

    C++ translation waiting for comments or ... approval :-)

  • yu5uy Avatar

    expected 207565 / 30054 to equal '6.9(06401810075197976974778731616423770546349903507020696080388633792506821055433552938044852598655752977972981965794902508817461901909895521394822652558727623610833832434950422572702468889332534770745990550342716443734611033473081786118320356691289013109735808877354095960604245691089372462900113129699873560923670726026485659146868969188793505024289612031676315964597058627803287415984561123311372862181406801091368869368470087176415784920476475677114527184401410793904305583283423171624409396419777733413189592067611632395022293205563319358488054834630997537765355693085778931257070606242097557729420376655353696679310574299594)'

    what ?? how is that possible ?

  • JohanWiltink Avatar

    This comment has been hidden.

  • JohanWiltink Avatar

    Needs random tests for repeating decimals.

    • JohanWiltink Avatar

      This comment has been hidden.

    • blr_Oliver Avatar

      I know that, but I'm just confused how to make such tests. How can I refer to my correct solution from tests? And should I? For simpler cases it was possible to explicitly construct random tests without relying on solution function, but for harder cases it seems inevitable. This is my first authored kata, I still don't know how it should go.

    • blr_Oliver Avatar
      Issue marked resolved by blr_Oliver 2 years ago
  • JohanWiltink Avatar
    assert.equal(fractionToPeriodic(n, d) , result);
    

    That needs to be assert.strictEqual. You don't want people returning numbers instead of strings.

  • JohanWiltink Avatar

    1 <= n < 10 * d

    The description examples already break this constraint.

    If you intend to specify the repeating part will be after the decimal point, you'll have to find a different constraint.

    • blr_Oliver Avatar

      Nope, this is correct, nominator may be greater than denominator, but not 10 times more. It makes possible for results to have non-zero integer part, and all examples and tests follow this restriction. Or did I understand your suggestion correct?

      Suggestion marked resolved by blr_Oliver 2 years ago
    • JohanWiltink Avatar

      I must have been confused.

      What is the expected result for 10/3 ?

    • blr_Oliver Avatar

      3.(3) And probably I should add it to tests