Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- z1 = zeros(1000); % overlap count
- z = zeros(1000); % latest index
- t = textscan(fopen('input.txt'),'#%f%*s%f,%f:%fx%f');
- id = t{1};
- L = t{2}+1;
- T = t{3}+1;
- w = t{4};
- h = t{5};
- for i=1:length(t{1})
- z1(T(i):T(i)+h(i)-1,L(i):L(i)+w(i)-1) = z1(T(i):T(i)+h(i)-1,L(i):L(i)+w(i)-1)+1;
- z(T(i):T(i)+h(i)-1,L(i):L(i)+w(i)-1) = id(i);
- end
- disp(sum(sum(z1>1))) % Part 1
- z = z.*(z1==1); %only consider spaces that have not been overlapped
- for i=1:length(t{1})
- if sum(sum(z==id(i))) == w(i)*h(i)
- disp(id(i)) % Part 2
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement