Cody

# Problem 788. Tiles Contest: Perfect Solutions for Large Unique Tile Boards

Solution 1376073

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