Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- G = zeros(5000,60);
- x = sort(importdata('input.txt'));
- L = size(x,1);
- for i=1:L
- idx = strfind(x{i},'#');
- if idx
- awake = true;
- ID = sscanf(x{i}(idx+1:end),'%f');
- continue
- end
- t = str2double(x{i}(16:17));
- if awake
- awake = false;
- G(ID,t+1:end) = G(ID,t+1:end)+1;
- else
- awake = true;
- G(ID,t+1:end) = G(ID,t+1:end)-1;
- end
- end
- [a,b_idx] = max(sum(G,2));
- [c,c_idx] = max(G(b_idx,:));
- disp((c_idx-1)*b_idx) % Part 1
- [d,d_idx]=max(max(G,[],2));
- [e,e_idx] = max(G(d_idx,:));
- disp((e_idx-1)*d_idx) % Part 2
Advertisement
Add Comment
Please, Sign In to add comment