Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
% This test suite can be updated if inappropriate 'hacks'
% are discovered in any submitted solutions,
% so the assessment of your submission may therefore change over time.
RE = regexp(fileread('decode.m'), '\w+', 'match');
tabooWords = {'ans', 'assert', 'freepass', 'tic'};
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)
|
2 | Pass |
x = {'qspdffe x/ pqfsbujpo', 'Psuipt jt HP!'};
s_correct.shift = uint8(1);
s_correct.message = {'proceed w/ operation', 'Orthos is GO!'};
s = decode(x);
%disp(' *** '); disp(s.message); disp(' *** ')
assert( isequal(s.shift, s_correct.shift) )
assert( isequal(s.message{1}, s_correct.message{1}) )
assert( isequal(s.message{2}, s_correct.message{2}) )
assert( isequal(s.message, s_correct.message) )
assert( isequal(s, s_correct) )
assert( isequal(class(s.shift), 'uint8') )
assert( isequal(class(s.message), 'cell') )
assert( isequal(class(s.message{1}), 'char') )
|
3 | Pass |
x = {'Hfqq Ons ts 555-7839 FXFU.', 'twymtx nx ts mtqi', 'bfnynsl ktw dtzw fianhj', 'TUJWFYNTS UTXYUTSJI'};
s_correct.shift = uint8(5);
s_correct.message = {'Call Jin on 555-7839 ASAP.', 'orthos is on hold', 'waiting for your advice', 'OPERATION POSTPONED'};
s = decode(x);
%disp(' *** '); disp(s.message); disp(' *** ')
assert( isequal(s.shift, s_correct.shift) )
assert( isequal(s.message, s_correct.message) )
|
4 | Pass |
x = {'Ocz kvnnrjmy rvn xcvibzy: "Knpdko" oj "Gjlzgk".', 'Jkzmvodji Kcjzids rvn npxxznnapg. Izso rdgg wz Jmocjn.', 'Edi Uvkxgzout rdgg wz gzvydib Ozvh V'};
s_correct.shift = uint8(21);
s_correct.message = {'The password was changed: "Psuipt" to "Loqelp".', 'Operation Phoenix was successful. Next will be Orthos.', 'Jin Zapcletzy will be leading Team A'};
s = decode(x);
assert( isequal(s.shift, s_correct.shift) )
assert( isequal(s.message, s_correct.message) )
|
5 | Pass |
x = {'bxmzzuzs r/ adftae az fdmow', 'adftae etxp oaybxqfq uz 2 iwe', 'abqdmfuaz pmfq eturfqp nmow 2 p.', 'naawe dqoquhqp. fwe Vuz' };
s_correct.shift = uint8(12);
s_correct.message = {'planning f/ orthos on track', 'orthos shld complete in 2 wks', 'operation date shifted back 2 d.', 'books received. tks Jin'};
s = decode(x);
assert( isequal(s.shift, s_correct.shift) )
assert( isequal(s.message, s_correct.message) )
|
6 | Pass |
x = {'Hdsffafy xgj Ghwjslagf Gjlzgk zsk gxxauasddq ugeewfuwv. Lzak oadd tw dwv tq Lwse S, kmhhgjlwv tq Lwse T sk fwwvwv.'};
s_correct.shift = uint8(18);
s_correct.message = {'Planning for Operation Orthos has officially commenced. This will be led by Team A, supported by Team B as needed.'};
s = decode(x);
assert( isequal(s.shift, s_correct.shift) )
assert( isequal(s.message, s_correct.message) )
|
7 | Pass |
x = {'Mncpyrgml Nfmclgv qryprcb rfpcc bywq yem. Yjj ncpqmllcj ypc rm pckygl ml bsrw slrgj Mncpyrgml Nfmclgv gq amknjcrcb.'};
s_correct.shift = nan;
s_correct.message = nan;
s = decode(x);
assert( isnan(s.shift) )
assert( isnan(s.message) )
|
8 | Pass |
x = {'Iutloxskj vgyycuxj oy tuc "Ruwkrv".', 'Vrgt lux uxznuy ruuqy UQ, haz tkkj suxk $$$', 'Ksgor Pot Fgvirkzfe ut xacqxb@sgzncuxqy.ius xk. Zakyjge', 'Zgrqkj zu Zkgs H. Ngvve zu yavvuxz uvkxgzout....', 'Xk. latjy, vry zxgtylkx zu giiuatz "YZOBKDSYX" - ZDY', 'jUT''Z cUXXE'};
s_correct.shift = uint8(6);
s_correct.message = {'Confirmed password is now "Loqelp".', 'Plan for orthos looks OK, but need more $$$', 'Email Jin Zapcletzy on ruwkrv@mathworks.com re. Tuesday', 'Talked to Team B. Happy to support operation....', 'Re. funds, pls transfer to account "STIVEXMSR" - TXS', 'dON''T wORRY'};
s = decode(x);
assert( isequal(s.shift, s_correct.shift) )
assert( isequal(s.message, s_correct.message) )
|
9 | Pass |
% Note: The Time Trial section does not check accuracy; that is done above.
% Acknowledgements
% Portions of this timing test code were inspired by:
% (1) Problem 937. "Rubik's Mini Cube: Solve Randomized Cube in 11 Moves or Less; Score is by Time (msec)" by Richard Zapor.
% (2) Problem 2733. "Evil Number" by Jan Orwat.
% (3) Feedback in comments from Peng Liu.
% (4) Problem Problem 1237. "It's race time! Write a faster function than the test suite call of unique()." by Jeremy.
% INITIALISE
x = {'qspdffe x/ pqfsbujpo', 'Psuipt jt HP!'};
qSmall = 50;
qBig = 10000;
%cutoffTimeBig = 10;
% EDIT (2018-06-17). Reduced time to pose reasonable challenge.
% Accounted for improving Cody server speed per Problem 44655.
cutoffTimeBig = 3; % Maximum allowable walltime (in seconds) to run function in a loop with qBig iterations.
tRef = datetime('2018-06-17', 'InputFormat','yyyy-MM-dd');
tNow = datetime('now');
yearsElapsed = (datenum(tNow) - datenum(tRef)) / 365.24;
fprintf('\r\n\r\n\r\nSubmission evaluated for speed on %s.\r\n', datestr(tNow, 'dd mmmm yyyy'))
rInf = 0.2; delta = cutoffTimeBig - rInf; tau = 3.6; % Data from Problem 44655, based on Problem 963.
qBig = floor( qBig * (cutoffTimeBig - rInf) * exp(yearsElapsed/tau) / delta );
fprintf('\r\n\r\n\r\nTo account for computational power increases over time, number of iterations increased to %u.\r\n', qBig)
% END EDIT (2018-06-17)
for dummy = 1 : 10, disp(' . '); end;
% *** PRELIMINARY TIMING WITH timeit ***
fDecode = @() decode(x);
dt_timeit = timeit( fDecode );
fprintf('APPROXIMATE time to decode %u message batches ~ %2.2f seconds, according to ''timeit''.\n\r', qBig, dt_timeit * qBig)
% *** PRELIMINARY TIMING WITH SHORT LOOP ***
% In case the submitted function has a lot of text output,
% get an estimate based on just a few iterations
% Initialise
t0 = clock;
% Loop
for i = 1 : qSmall
solution = decode( x );
end;
% Compute and display elapsed time.
dt = etime(clock, t0);
disp(' -----=====----- ')
%fprintf('Your wall time to decode %u message batches = %i seconds.\n\r', qSmall, floor(dt))
fprintf('APPROXIMATE wall time to decode %u message batches ~ %2.2f seconds, by extrapolating from %u batches.\n\r', qBig, dt * qBig / qSmall, qSmall)
disp(' -----=====----- ')
% *** 'OFFICIAL' TIMING ***
% Re-initialise timer
t0 = clock;
t0_cpu = cputime;
% Loop
for i = 1 : qBig
solution = decode( x );
end;
% Compute and display elapsed time.
for dummy = 1 : 10, disp(' . '); end;
disp(' -----=====|||||=====----- ')
dt = etime(clock, t0);
fprintf('Your wall time to decode %u message batches = %2.2f seconds.\n\r', qBig, dt)
dt_cpu = (cputime - t0_cpu);
fprintf(' ( Your CPU time for this = %2.2f seconds. ) \n\r', dt_cpu)
% Display (default) Cody size-based score.
all_nodes = mtree('decode.m', '-file');
size_score = count(all_nodes);
fprintf('Your Cody-standard size-based score = %i.\n\r', size_score)
% Report revised performance score
combinedScore = size_score + round(dt * 10);
fprintf('Your combined score = %i.\n\r', combinedScore)
disp(' -----=====|||||=====----- ')
% Now disallow any candidate solutions that are TOO SLOW!
if dt > cutoffTimeBig,
fprintf('Sorry, your submission is TOO SLOW. It must be able to finish within %u seconds.\n\r', cutoffTimeBig)
end;
assert( dt <= cutoffTimeBig )
Submission evaluated for speed on 12 July 2018.
To account for computational power increases over time, number of iterations increased to 10194.
.
.
.
.
.
.
.
.
.
.
APPROXIMATE time to decode 10194 message batches ~ 3.35 seconds, according to 'timeit'.
-----=====-----
APPROXIMATE wall time to decode 10194 message batches ~ 5.11 seconds, by extrapolating from 50 batches.
-----=====-----
.
.
.
.
.
.
.
.
.
.
-----=====|||||=====-----
Your wall time to decode 10194 message batches = 2.97 seconds.
( Your CPU time for this = 3.47 seconds. )
Your Cody-standard size-based score = 120.
Your combined score = 150.
-----=====|||||=====-----
|
5170 Solvers
Project Euler: Problem 1, Multiples of 3 and 5
1063 Solvers
Arrange Vector in descending order
1808 Solvers
631 Solvers
138 Solvers