Cody

Problem 1891. High Precision Square Root (Inspired by Project Euler 80)

Solution 2550195

Submitted on 14 Jun 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
assert(strcmp(string_sqrt(1000,10),'31.6227766016'))

xBD1 = 999.999999999999952145026886195277998846429033444945999793175561709546173005946911871433258056640625

Output argument "y" (and maybe others) not assigned during call to "string_sqrt". Error in Test1 (line 1) assert(strcmp(string_sqrt(1000,10),'31.6227766016'))

2   Fail
assert(strcmp(string_sqrt(10,11),'3.16227766016'))

xBD1 = 10.000000000000001206650333778769296922885792260236090451915231570867437227434493252076208591461181640625

Output argument "y" (and maybe others) not assigned during call to "string_sqrt". Error in Test2 (line 1) assert(strcmp(string_sqrt(10,11),'3.16227766016'))

3   Fail
assert(strcmp(string_sqrt(3,100),'1.7320508075688772935274463415058723669428052538103806280558069794519330169088000370811461867572485756'))

xBD1 = 2.999999999999999652374485391953124263087948371306152179697188976670307880567634128965437412261962890625

Output argument "y" (and maybe others) not assigned during call to "string_sqrt". Error in Test3 (line 1) assert(strcmp(string_sqrt(3,100),'1.7320508075688772935274463415058723669428052538103806280558069794519330169088000370811461867572485756'))

4   Fail
assert(strcmp(string_sqrt(314159,314),'560.49888492306565872479934293941633491101288779142813321911971670725840486880541273457870660258696202335374555140881778649205224589390756076993240996126057385009263605818384161945745399159720436585888004381611637660905033452884843995010613320008027334007622507916692664539613518278405454926834945753785814159773889523'))

xBD1 = 314159.00000000004898628941786076866655318988726477459627606236836072639562189579010009765625

Output argument "y" (and maybe others) not assigned during call to "string_sqrt". Error in Test4 (line 1) assert(strcmp(string_sqrt(314159,314),'560.49888492306565872479934293941633491101288779142813321911971670725840486880541273457870660258696202335374555140881778649205224589390756076993240996126057385009263605818384161945745399159720436585888004381611637660905033452884843995010613320008027334007622507916692664539613518278405454926834945753785814159773889523'))

5   Fail
a=2:50; a(sqrt(a)==floor(sqrt(a)))=[]; na=numel(a); b=zeros(na,100); for flag=1:na temp=string_sqrt(a(flag),101); t2=regexprep(temp,'\.','')-'0'; b(flag,:)=t2(1:100); end y_correct=sum(sum(b)) assert(isequal(19543,y_correct))

xBD1 = 2.00000000000000027343234630647692806884916507957232351955020204815893780647684252471663057804107666015625

Output argument "y" (and maybe others) not assigned during call to "string_sqrt". Error in Test5 (line 6) temp=string_sqrt(a(flag),101);

6   Fail
assert(strcmp(string_sqrt(12345,1),'111.1'))

xBD1 = 12344.999999999998913100036160168829040078570586890503203714164470738978707231581211090087890625

Output argument "y" (and maybe others) not assigned during call to "string_sqrt". Error in Test6 (line 1) assert(strcmp(string_sqrt(12345,1),'111.1'))