6 kyu
Fraction to periodic decimal
95 of 104blr_Oliver
Loading description...
Mathematics
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
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.approved by someone
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-...)"
Fork published
.
C++ translation waiting for comments or ... approval :-)
Approved
expected 207565 / 30054 to equal '6.9(06401810075197976974778731616423770546349903507020696080388633792506821055433552938044852598655752977972981965794902508817461901909895521394822652558727623610833832434950422572702468889332534770745990550342716443734611033473081786118320356691289013109735808877354095960604245691089372462900113129699873560923670726026485659146868969188793505024289612031676315964597058627803287415984561123311372862181406801091368869368470087176415784920476475677114527184401410793904305583283423171624409396419777733413189592067611632395022293205563319358488054834630997537765355693085778931257070606242097557729420376655353696679310574299594)'
what ?? how is that possible ?
Repeating part can be long, up to
denominator
- 1 digits. Fortunately, not for all fractions.This comment has been hidden.
Needs random tests for repeating decimals.
This comment has been hidden.
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.
Done
That needs to be
assert.strictEqual
. You don't want people returning numbers instead of strings.Done
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.
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?
I must have been confused.
What is the expected result for
10/3
?3.(3) And probably I should add it to tests