Cody

Solution 1376075

Submitted on 11 Dec 2017
  • Size: 4
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
feval(@assignin,'caller','score',2000);

2   Fail
format short format compact global net_time %fn='http://tinyurl.com/zapor-Tiles-sample-mat'; fn='http://tinyurl.com/matlab-tiles-mat'; testSuiteFile = 'raz_tiles.mat'; urlwrite(fn,testSuiteFile); brd=59; tests = load(testSuiteFile,'testsuite'); tiles = tests.testsuite(brd).tiles; rows = tests.testsuite(brd).r; cols = tests.testsuite(brd).c; boardSize = [rows, cols]; [board,orientation]=board_perfect(boardSize,tiles); % run twice for timing t0=clock; [board,orientation]=board_perfect(boardSize,tiles); dt=etime(clock,t0)*1e3; % verify score t=tiles; ntiles=size(tiles,1); te = [t; t(:,[2:4,1]); t(:,[3:4,1:2]); t(:,[4,1:3])]; % build check arrays UD, LR LR=zeros(rows,2*cols); UD=zeros(2*rows,cols); for r=1:rows for c=1:cols tptr=board(r,c); tor=orientation(tptr); UD(2*r-1,c)=te(tptr+ntiles*(tor-1),1); UD(2*r,c)=te(tptr+ntiles*(tor-1),3); LR(r,2*c-1)=te(tptr+ntiles*(tor-1),4); LR(r,2*c)=te(tptr+ntiles*(tor-1),2); end end checksum=sum([LR(:,1)' LR(:,end)' UD(1,:) UD(end,:)]); for idx=2:2:2*rows-2 % LR Square array assumed here checksum=checksum+sum(LR(:,idx)-LR(:,idx+1))+sum(UD(idx,:)-UD(idx+1,:)); end assert(checksum==0,sprintf('Checksum = %s\n',num2str(checksum))); net_time=dt

Error using load Unable to read MAT-file /users/mss.system.1SylF1/raz_tiles.mat. Not a binary MAT-file. Try load -ASCII to read as text. Error in Test2 (line 14) tests = load(testSuiteFile,'testsuite');

3   Fail
global net_time temp=net_time; % anti-cheat %fn='http://tinyurl.com/zapor-Tiles-contest-mat'; fn='http://tinyurl.com/matlab-tilesC-mat'; testSuiteFile = 'raz_tiles.mat'; urlwrite(fn,testSuiteFile); brd=6; tests = load(testSuiteFile,'testsuite'); tiles = tests.testsuite(brd).tiles; rows = tests.testsuite(brd).r; cols = tests.testsuite(brd).c; boardSize = [rows, cols]; [board,orientation]=board_perfect(boardSize,tiles); % run twice for timing t0=clock; [board,orientation]=board_perfect(boardSize,tiles); dt=etime(clock,t0)*1e3 % verify score t=tiles; ntiles=size(tiles,1); te = [t; t(:,[2:4,1]); t(:,[3:4,1:2]); t(:,[4,1:3])]; % build check arrays UD, LR LR=zeros(rows,2*cols); UD=zeros(2*rows,cols); for r=1:rows for c=1:cols tptr=board(r,c); tor=orientation(tptr); UD(2*r-1,c)=te(tptr+ntiles*(tor-1),1); UD(2*r,c)=te(tptr+ntiles*(tor-1),3); LR(r,2*c-1)=te(tptr+ntiles*(tor-1),4); LR(r,2*c)=te(tptr+ntiles*(tor-1),2); end end checksum=sum([LR(:,1)' LR(:,end)' UD(1,:) UD(end,:)]); for idx=2:2:2*rows-2 % LR Square array assumed here checksum=checksum+sum(LR(:,idx)-LR(:,idx+1))+sum(UD(idx,:)-UD(idx+1,:)); end assert(checksum==0,sprintf('Checksum = %s\n',num2str(checksum))); net_time=(dt+temp)/2

Error using load Unable to read MAT-file /users/mss.system.1SylF1/raz_tiles.mat. Not a binary MAT-file. Try load -ASCII to read as text. Error in Test3 (line 13) tests = load(testSuiteFile,'testsuite');

4   Fail
global net_time % Limit Score to 2000 for graph quality t=mtree('board_perfect.m','-file'); scr=floor(length(t.nodesize)/10+net_time); scr=min(scr,2000) feval(@assignin,'caller','score',floor(scr)); %fh=fopen('board_perfect.m','wt'); %fprintf(fh,'%s\n',repmat('1;',[1,round(scr/2)])); %fclose(fh);

Error using mtree (line 80) cannot read input file board_perfect.m Error in Test4 (line 4) t=mtree('board_perfect.m','-file');