Problem 918. Find the repeating decimal pattern!
Solution Stats
Problem Comments
-
2 Comments
The tests are inconsistent with the statement of the problem. Finite strings like ..123451234512345 only repeat to the end of the string, then switch to zeros.
The problem should specify the precision required, there are numbers that cannot be represented with doubles and are loosing significant digits. And this really becomes an issue when your test suite use less significant digits to identify repeating patterns such as in cases 7 and 10. I was able to overcome this issue by using 14 digits, but some people used 16 (If someone else is having problems that's the way to go). Moreover, Andrew is right, a number like 0.333333 is technically not a repeating decimal.
Solution Comments
-
1 Comment
If the number is a true repeater, then multiplying it by 999... for some number of 9's will result in an integer. The difficulty lies in the rounding. I had to tune the tolerance to deal with cases like .123451234512345, which aren't truly repeating.
-
1 Comment
Some cleaning up!
Problem Recent Solvers14
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
44015 Solvers
-
Operate on matrices of unequal, yet similar, size
131 Solvers
-
Create an index-powered vector
564 Solvers
-
492 Solvers
-
235 Solvers
More from this Author6
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!