Cody

Solution 1957403

Submitted on 3 Oct 2019 by Le Manh Long Le Manh Long
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   Pass
filetext = fileread('divisible_by_5.m'); assert(isempty(strfind(filetext, '*')),'* forbidden') assert(isempty(strfind(filetext, 'mtimes')),'mtimes() forbidden') assert(isempty(strfind(filetext, 'cross')),'cross() forbidden') assert(isempty(strfind(filetext, 'prod')),'prod() forbidden') assert(isempty(strfind(filetext, 'cumprod')),'cumprod() forbidden') assert(isempty(strfind(filetext, 'times')),'times() forbidden') assert(isempty(strfind(filetext, 'mldivide')),'mldivide() forbidden') assert(isempty(strfind(filetext, 'mrdivide')),'mrdivide() forbidden') assert(isempty(strfind(filetext, '/')),'/ forbidden') assert(isempty(strfind(filetext, '\')),'\ forbidden') assert(isempty(strfind(filetext, '^')),'^ forbidden') assert(isempty(strfind(filetext, 'dot')),'dot() forbidden') assert(isempty(strfind(filetext, 'rem')),'rem() forbidden') assert(isempty(strfind(filetext, 'mod')),'mod() forbidden') assert(isempty(strfind(filetext, 'round')),'round() forbidden') assert(isempty(strfind(filetext, 'ceil')),'ceil() forbidden') assert(isempty(strfind(filetext, 'floor')),'floor() forbidden') assert(isempty(strfind(filetext, 'java')),'java forbidden')

2   Pass
n_str = '12'; assert(isequal(divisible_by_5(n_str),0))

a = 1 2 k = 2 tf = 0

3   Pass
n_str = '13'; assert(isequal(divisible_by_5(n_str),0))

a = 1 3 k = 2 tf = 0

4   Pass
n_str = '225'; assert(isequal(divisible_by_5(n_str),1))

a = 2 2 5 k = 3 tf = 1

5   Pass
n_str = '232'; assert(isequal(divisible_by_5(n_str),0))

a = 2 3 2 k = 3 tf = 0

6   Pass
n_str = '223'; assert(isequal(divisible_by_5(n_str),0))

a = 2 2 3 k = 3 tf = 0

7   Pass
n_str = '1236125'; assert(isequal(divisible_by_5(n_str),1))

a = 1 2 3 6 1 2 5 k = 7 tf = 1

8   Pass
n_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; assert(isequal(divisible_by_5(n_str),1))

a = Columns 1 through 30 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 31 through 60 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 61 through 90 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 91 through 120 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 121 through 150 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 151 through 180 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 k = 180 tf = 1

9   Pass
n_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901'; assert(isequal(divisible_by_5(n_str),0))

a = Columns 1 through 30 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 31 through 60 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 61 through 90 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 91 through 120 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 121 through 150 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 151 through 180 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Column 181 1 k = 181 tf = 0

10   Pass
n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; assert(isequal(divisible_by_5(n_str),1))

a = Columns 1 through 30 1 2 3 6 7 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 61 through 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 91 through 120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 121 through 150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 151 through 180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 181 through 207 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 k = 207 tf = 1

11   Pass
n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'; assert(isequal(divisible_by_5(n_str),0))

a = Columns 1 through 30 1 2 3 6 7 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 61 through 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 91 through 120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 121 through 150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 151 through 180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 181 through 207 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 k = 207 tf = 0

12   Pass
n_str = '3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195909216420198938095257201065485863278865936153381827968230301952035301852968995773622599413891249721775283479131515574857242454150695950829533116861727855889075098381754637464939319255060400927701671139009848824012858361603563707660104710181942955596198946767837449448255379774726847104047534646208046684259069491293313677028989152104752162056966024058038150193511253382430035587640247496473263914199272604269922796'; assert(isequal(divisible_by_5(n_str),0))

a = Columns 1 through 30 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 Columns 31 through 60 9 5 0 2 8 8 4 1 9 7 1 6 9 3 9 9 3 7 5 1 0 5 8 2 0 9 7 4 9 4 Columns 61 through 90 4 5 9 2 3 0 7 8 1 6 4 0 6 2 8 6 2 0 8 9 9 8 6 2 8 0 3 4 8 2 Columns 91 through 120 5 3 4 2 1 1 7 0 6 7 9 8 2 1 4 8 0 8 6 5 1 3 2 8 2 3 0 6 6 4 Columns 121 through 150 7 0 9 3 8 4 4 6 0 9 5 5 0 5 8 2 2 3 1 7 2 5 3 5 9 4 0 8 1 2 Columns 151 through 180 8 4 8 1 1 1 7 4 5 0 2 8 4 1 0 2 7 0 1 9 3 8 5 2 1 1 0 5 5 5 Columns 181 through 210 9 6 4 4 6 2 2 9 4 8 9 5 4 9 3 0 3 8 1 9 6 4 4 2 8 8 1 0 9 7 Columns 211 through 240 5 6 6 5 9 3 3 4 4 6 1 2 8 4 7 5 6 4 8 2 3 3 7 8 6 7 8 3 1 6 Columns 241 through 270 5 2 7 1 2 0 1 9 0 9 1 4 5 6 4 8 5 6 6 9 2 3 4 6 0 3 4 8 6 1 Columns 271 through 300 0 4 5 4 3 2 6 6 4 8 2 1 3 3 9 3 6 0 7 2 6 0 2 4 9 1 4 1 2 7 Columns 301 through 330 3 7 2 4 5 8 7 0 0 6 6 0 6 3 1 5 5 8 8 1 7 4 8 8 1 5 2 0 9 2 Columns 331 through 360 0 9 6 2 8 2 9 2 5 4 0 9 1 7 1 5 3 6 4 3 6 7 8 9 2 5 9 0 3 6 Columns 361 through 390 0 0 1 1 3 3 0 5 3 0 5 4 8 8 2 0 4 6 6 5 2 1 3 8 4 1 4 6 9 5 Columns 391 through 420 1 9 4 1 5 1 1 6 0 9 4 3 3 0 5 7 2 7 0 3 6 5 7 5 9 5 9 1 9 5 Columns 421 through 450 3 0 9 2 1 8 6 1 1 7 3 8 1 9 3 2 6 1 1 7 9 3 1 0 5 1 1 8 5 4 Columns 451 through 480 8 0 7 4 4 6 2 3 7 9 9 6 2 7 4 9 5 6 7 3 5 1 8 8 5 7 5 2 7 2 Columns 481 through 510 4 8 9 1 2 2 7 9 3 8 1 8 3 0 1 1 9 4 9 1 2 9 8 3 3 6 7 3 3 6 Columns 511 through 540 2 4 4 0 6 5 6 6 4 3 0 8 6 0 2 1 3 9 4 9 4 6 3 9 5 2 2 4 7 3 Columns 541 through 570 7 1 9 0 7 0 2 1 7 9 8 6 0 9 4 3 7 0 2 7 7 0 5 3 9 2 1 7 1 7 Columns 571 through 600 6 2 9 3 1 7 6 7 5 2 3 8 4 6 7 4 8 1 8 4 6 7 6 6 9 4 0 5 1 3 Columns 601 through 630 2 0 0 0 5 6 8 1 2 7 1 4 5 2 6 3 5 6 0 8 2 7 7 8 5 7 7 1 3 4 Columns 631 through 660 2 7 5 7 7 8 9 6 0 9 1 7 3 6 3 7 1 7 8 7 2 1 4 6 8 4 4 0 9 0 Columns 661 through 690 1 2 2 4 9 5 3 4 3 0 1 4 6 5 4 9 5 8 5 3 7 1 0 5 0 7 9 2 2 7 Columns 691 through 720 9 6 8 9 2 5 8 9 2 3 5 4 2 0 1 9 9 5 6 1 1 2 1 2 9 0 2 1 9 6 Columns 721 through 750 0 8 6 4 0 3 4 4 1 8 1 5 9 8 1 3 6 2 9 7 7 4 7 7 1 3 0 9 9 6 Columns 751 through 780 0 5 1 8 7 0 7 2 1 1 3 4 9 9 9 9 9 9 8 3 7 2 9 7 8 0 4 9 9 5 Columns 781 through 810 1 0 5 9 7 3 1 7 3 2 8 1 6 0 9 6 3 1 8 5 9 5 0 2 4 4 5 9 4 5 Columns 811 through 840 5 3 4 6 9 0 8 3 0 2 6 4 2 5 2 2 3 0 8 2 5 3 3 4 4 6 8 5 0 3 Columns 841 through 870 5 2 6 1 9 3 1 1 8 8 1 7 1 0 1 0 0 0 3 1 3 7 8 3 8 7 5 2 8 8 Columns 871 through 900 6 5 8 7 5 3 3 2 0 8 3 8 1 4 2 0 6 1 7 1 7 7 6 6 9 1 4 7 3 0 Columns 901 through 930 3 5 9 8 2 5 3 4 9 0 4 2 8 7 5 5 4 6 8 7 3 1 1 5 9 5 6 2 8 6 Columns 931 through 960 3 8 8 2 3 5 3 7 8 7 5 9 3 7 5 1 9 5 7 7 8 1 8 5 7 7 8 0 5 3 Columns 961 through 990 2 1 7 1 2 2 6 8 0 6 6 1 3 0 0 1 9 2 7 8 7 6 6 1 1 1 9 5 9 0 Columns 991 through 1020 9 2 1 6 4 2 0 1 9 8 9 3 8 0 9 5 2 5 7 2 0 1 0 6 5 4 8 5 8 6 Columns 1021 through 1050 3 2 7 8 8 6 5 9 3 6 1 5 3 3 8 1 8 2 7 9 6 8 2 3 0 3 0 1 9 5 Columns 1051 through 1080 2 0 3 5 3 0 1 8 5 2 9 6 8 9 9 5 7 7 3 6 2 2 5 9 9 4 1 3 8 9 Columns 1081 through 1110 1 2 4 9 7 2 1 7 7 5 2 8 3 4 7 9 1 3 1 5 1 5 5 7 4 8 5 7 2 4 Columns 1111 through 1140 2 4 5 4 1 5 0 6 9 5 9 5 0 8 2 9 5 3 3 1 1 6 8 6 1 7 2 7 8 5 Columns 1141 through 1170 5 8 8 9 0 7 5 0 9 8 3 8 1 7 5 4 6 3 7 4 6 4 9 3 9 3 1 9 2 5 Columns 1171 through 1200 5 0 6 0 4 0 0 9 2 7 7 0 1 6 7 1 1 3 9 0 0 9 8 4 8 8 2 4 0 1 Columns 1201 through 1230 2 8 5 8 3 6 1 6 0 3 5 6 3 7 0 7 6 6 0 1 0 4 7 1 0 1 8 1 9 4 Columns 1231 through 1260 2 9 5 5 5 9 6 1 9 8 9 4 6 7 6 7 8 3 7 4 4 9 4 4 8 2 5 5 3 7 Columns 1261 through 1290 9 7 7 4 7 2 6 8 4 7 1 0 4 0 4 7 5 3 4 6 4 6 2 0 8 0 4 6 6 8 Columns 1291 through 1320 4 2 5 9 0 6 9 4 9 1 2 9 3 3 1 3 6 7 7 0 2 8 9 8 9 1 5 2 1 0 Columns 1321 through 1350 4 7 5 2 1 6 2 0 5 6 9 6 6 0 2 4 0 5 8 0 3 8 1 5 0 1 9 3 5 1 Columns 1351 through 1380 1 2 5 3 3 8 2 4 3 0 0 3 5 5 8 7 6 4 0 2 4 7 4 9 6 4 7 3 2 6 Columns 1381 through 1402 3 9 1 4 1 9 9 2 7 2 6 0 4 2 6 9 9 2 2 7 9 6 k = 1402 tf = 0

13   Pass
n_str = '10100101010110101010010110101001011010100101001011010100110101001010'; assert(isequal(divisible_by_5(n_str),1))

a = Columns 1 through 30 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 Columns 31 through 60 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0 1 1 0 1 Columns 61 through 68 0 1 0 0 1 0 1 0 k = 68 tf = 1

14   Pass
ind = randi(4); switch ind case 1 n_str = '12'; assert(isequal(divisible_by_5(n_str),0)) case 2 n_str = '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901'; assert(isequal(divisible_by_5(n_str),0)) case 3 n_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; assert(isequal(divisible_by_5(n_str),1)) case 4 n_str = '225'; assert(isequal(divisible_by_5(n_str),1)) end

a = 2 2 5 k = 3 tf = 1

15   Pass
ind = randi(4); switch ind case 1 n_str = '10100101010110101010010110101001011010100101001011010100110101001010'; assert(isequal(divisible_by_5(n_str),1)) case 2 n_str = '12'; assert(isequal(divisible_by_5(n_str),0)) case 3 n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'; assert(isequal(divisible_by_5(n_str),0)) case 4 n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; assert(isequal(divisible_by_5(n_str),1)) end

a = Columns 1 through 30 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 Columns 31 through 60 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0 1 1 0 1 Columns 61 through 68 0 1 0 0 1 0 1 0 k = 68 tf = 1

16   Pass
ind = randi(4); switch ind case 1 n_str = '13'; assert(isequal(divisible_by_5(n_str),0)) case 2 n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; assert(isequal(divisible_by_5(n_str),1)) case 3 n_str = '123678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'; assert(isequal(divisible_by_5(n_str),0)) case 4 n_str = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; assert(isequal(divisible_by_5(n_str),1)) end

a = Columns 1 through 30 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 31 through 60 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 61 through 90 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 91 through 120 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 121 through 150 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Columns 151 through 180 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 k = 180 tf = 1