Cody

# Problem 44466. The twelve days of Christmas

Solution 1404172

Submitted on 4 Jan 2018 by Alfonso Nieto-Castanon
• Size: 17
• This is the leading solution.
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
% 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

2   Pass

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!