Cody

# Problem 44466. The twelve days of Christmas

Solution 1706080

Submitted on 11 Jan 2019 by HH
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### Test Suite

Test Status Code Input and Output
1   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.

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

ans = 0

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

ans = 0

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

ans = 1

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

ans = 4

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

ans = 10

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

ans = 20

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

ans = 35

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

ans = 56

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

ans = 84

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

ans = 120

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

ans = 165

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

ans = 220

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

ans = 286

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

ans = 364

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

ans = 364

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

ans = 364

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

ans = 364 ans = 364 ans = 364 ans = 364 ans = 364 ans = 364 ans = 364 ans = 364 ans = 364 ans = 364

### Community Treasure Hunt

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

Start Hunting!