Cody

Solution 191863

Submitted on 16 Jan 2013 by Peter Wittenberg
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
!cp diff_digits.m safe !rm *.* !mv safe diff_digits.m % Clean user's function from some known jailbreaking mechanisms fid = fopen('diff_digits.m'); st = regexprep(char(fread(fid)'), '!', 'error(''No shell commands!''); %'); st = regexprep(st, 'feval', 'error(''No fancy functions!''); %'); st = regexprep(st, 'str2func', 'error(''No fancy functions!''); %'); st = regexprep(st, 'regex', 'error(''No fancy functions!''); %'); st = regexprep(st, 'system', 'error(''No shell commands!''); %'); st = regexprep(st, 'dos', 'error(''No shell commands!''); %'); st = regexprep(st, 'unix', 'error(''No shell commands!''); %'); st = regexprep(st, 'perl', 'error(''No external languages commands!''); %'); st = regexprep(st, 'java', 'error(''No external languages commands!''); %'); st = regexprep(st, 'assert', 'error(''No overwriting!''); %'); fclose(fid) fid = fopen('diff_digits.m' , 'w'); fwrite(fid,st); fclose(fid)
ans = 0 ans = 0
2   Pass
%% start=1000; finish=1023; y_correct = 1; assert(isequal(diff_digits(start,finish),y_correct))
3   Pass
%% start=1000; finish=9999; y_correct = 4536; assert(isequal(diff_digits(start,finish),y_correct))
4   Pass
%% start=1234; finish=5678; y_correct = 2273; assert(isequal(diff_digits(start,finish),y_correct))
5   Pass
%% assert(isequal(diff_digits(4321,6789),1210))
6   Pass
%% assert(isequal(diff_digits(1988,2012),0))