testsuite not working, please change "assert(isequal(pidigit(N,n)-y_correct<0.0001))" to "assert(abs(pidigit(N,n)-y_correct)<0.0001)"
Thanks, I have made the change
Still missing a ")" in your assert statement
Thanks, I have add ')'
In Solution 1301292 I am finding the same thing as Yona reported (see comment below). "Digits" should mean all digits, including the leading 3. That is the definition required to pass Test 1. But to pass Test 2 and Test 5, it is required to ignore the leading 3. Or else some people have misread the problem statement, which says that the number of digits to inspect is not N, but rather N–1. (Because we're trying to predict the N'th digit.) I count only 15 occurrences of "6" in the first 200 digits, when the leading "3" is included (as it should be).
I can not find a solution without using the symbolic math toolbox ;(
David, Maurício, Yona and mhartma3 check your solutions. They should pass all the test suit now.
Thanks, Mehmet OZC. I suppose that numerically my Solution 1301292 should now pass, but it seems it is failing the new assertion that uses regex to parse the M-file. I guess it is looking for hard-coded solutions that might characteristically contain any of the numbers [101,201,202,203,1001], which are important parameters in your Test Suite. However, inspection of pi reveals that the sequence "101" appears at the 852nd decimal place, "201" appears at the 244th decimal place, etc. So the new assertion might be creating unexpected side-effects.
@David it is somewhat funny but that solution is not failing because of those partial matches in the pi sequence (the regexp command used will disregard partial matches) but rather because of the explicit 1001 value in your commented line (reading "First 1001 digits of pi")
Ah, thanks for the clarification, Alfonso. So it was an unintended side-effect, but not the one I had supposed. That also explains why it didn't disrupt most other solutions.
It is a shame vpa does not work, this could lead to some more interesting challenges
You have to provide the number pi as a string as input. This is horrible, however, this is needed, because the symbolic toolbox is not working. Therefore, here is the number:
I think the answers to the second and the last tests are wrong, they should be 0.08 and .105 respectively
It does not accept VPA and digits function? Something wrong with online debugging?
at least the first 20 SOL are fun ;P
quite silly as we cannot use the vpa function.
how do I solve this without using either the Pi value string or symbolic toolbox?
why do I always get this error message:
Undefined function 'vpa' for input arguments of type 'double'.
When running the code in my Matlab version, it works fine
to use vpa function you must have symbolic math toolbox. We cannot use the toolbox on cody.
I think the answer to test suite 3 should be 0.0746 rather than 0.0796.
Kyle, test suite is correct. your code includes decimal point. check your solution
Ah, you're correct. Thanks!
My code passes all tests but the last... I'm getting 0.1050 as a result instead of 0.1060.
can we just do not paste pi and truncate? try something different.
Shouldn't the correct answer for test 2 be 0.08? There are be 16 occurrences of the digit 6 in the first 200 digits. 16/200 = 0.08.
Sorry for that, I have corrected the mistake.
I think this correction is not good. the 201th digit is 6 so only 15 until 200 (when the first digit is 3 and not only the decimal part)
same problem in test 5. need to be 105. (see solution 1292755 and 1292769)
I agree with Yona that the "corrected" solution is now wrong. There are only 15 occurrences of the digit 6 in the first 200 digits. 15/200 = 0.0750. Similarly, the solution to test 5 should be 105/1000 = 0.1050.
Not a particularly cool solution to be proud of, but a string literal would be neither too elegant...
Find state names that end with the letter A
Knight's Tour Checker
Sorted highest to lowest?
Symmetry of vector
Fix the last element of a cell array
Find two triangular numbers whose sum is input.
Your favourite city!
Go back n times
Low level NaN
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office