Cody

Solution 1706081

Submitted on 11 Jan 2019
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
% The Test Suite will be updated if inappropriate submissions are received. % This includes hard-coded (pre-calculated, externally calculated, manually calculated) 'solutions'. % EDIT (2019-06-24). Anti-hacking provision % Ensure builtin function will be called. (Probably only the second of these will work.) ! del fileread.m ! rm -v fileread.m % Probably only the second of these will work. RE = regexp(fileread('twelvetide.m'), '\w+', 'match'); %tabooWords = {'ans', 'assert', 'freepass', 'tic'}; tabooWords = {'assert', 'freepass'}; testResult = cellfun( @(z) ismember(z, tabooWords), RE ); msg = ['Please do not do that in your code!' char([10 13]) ... 'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ... 'Banned word.' char([10 13])]; assert(~any( cellfun( @(z) ismember(z, tabooWords), RE ) ), msg) % END EDIT (2019-06-24)

/bin/bash: del: command not found rm: cannot remove 'fileread.m': No such file or directory

Please do not do that in your code! Found: assert assert. Banned word.

2   Pass
% Adapted from the code of Alfonso Nieto-Castanon in a comment at % https://www.mathworks.com/matlabcentral/cody/problems/44343 . assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[120,165,220,286]),regexp(fileread('twelvetide.m'),'[\d\.\+\-\*\/]+','match'))), 'Please do not hard-code your ''solution''.') %assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[120,165,220,286,364]),regexp(fileread('twelvetide.m'),'[\d\.\+\-\*\/]+','match'))), 'Please do not hard-code your ''solution''.') <-- prior to 2018-01-02. assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[55,66,78]),regexp(fileread('twelvetide.m'),'[\d\.\+\-\*\/]+','match'))), 'No, really: please do not hard-code your ''solution''.') % Added on 2018-01-06.

3   Pass
day = 0 - randi(50); accumulatedGifts = 0; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)]

4   Pass
day = 0; accumulatedGifts = 0; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)]

5   Pass
day = 1; accumulatedGifts = 1; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint5 (line 3) In solutionTest (line 11)]

6   Pass
day = 2; accumulatedGifts = 4; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint6 (line 3) In solutionTest (line 13)]

7   Pass
day = 3; accumulatedGifts = 10; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint7 (line 3) In solutionTest (line 15)]

8   Pass
day = 4; accumulatedGifts = 20; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint8 (line 3) In solutionTest (line 17)]

9   Pass
day = 5; accumulatedGifts = 35; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint9 (line 3) In solutionTest (line 19)]

10   Pass
day = 6; accumulatedGifts = 56; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint10 (line 3) In solutionTest (line 21)]

11   Pass
day = 7; accumulatedGifts = 84; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint11 (line 3) In solutionTest (line 23)]

12   Pass
day = 8; accumulatedGifts = 120; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint12 (line 3) In solutionTest (line 25)]

13   Pass
day = 9; accumulatedGifts = 165; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint13 (line 3) In solutionTest (line 27)]

14   Pass
day = 10; accumulatedGifts = 220; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint14 (line 3) In solutionTest (line 29)]

15   Pass
day = 11; accumulatedGifts = 286; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint15 (line 3) In solutionTest (line 31)]

16   Pass
day = 12; accumulatedGifts = 364; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint16 (line 3) In solutionTest (line 33)]

17   Pass
day = 13; accumulatedGifts = 364; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint17 (line 3) In solutionTest (line 35)]

18   Pass
day = 100; accumulatedGifts = 364; assert( isequal(twelvetide(day), accumulatedGifts) )

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint18 (line 3) In solutionTest (line 37)]

19   Pass
for i = 1 : 10 day = 12 + randi(300); accumulatedGifts = 364; assert( isequal(twelvetide(day), accumulatedGifts) ) end;

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In twelvetide (line 2) In ScoringEngineTestPoint19 (line 4) In solutionTest (line 39)]