Guest User

Untitled

a guest
Dec 4th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.63 KB | None | 0 0
  1. G = zeros(5000,60);
  2. x = sort(importdata('input.txt'));
  3. for i=1:size(x,1)
  4.     if strfind(x{i},'#')
  5.         awake   = true;
  6.         ID      = sscanf(x{i}(strfind(x{i},'#')+1:end),'%f');
  7.     else
  8.         G(ID,str2double(x{i}(16:17))+1:end) = G(ID,str2double(x{i}(16:17))+1:end)-1+2*awake;
  9.         awake                               = ~awake;
  10.     end
  11. end
  12. disp((find(max(G(find(max(sum(G,2))==sum(G,2)),:))==G(find(max(sum(G,2))==sum(G,2)),:))-1)*find(max(sum(G,2))==sum(G,2))) % Part 1
  13. disp((find(max(G(find(max(max(G,[],2))==max(G,[],2)),:))==G(find(max(max(G,[],2))==max(G,[],2)),:))-1)*find(max(max(G,[],2))==max(G,[],2))) % Part 2
Advertisement
Add Comment
Please, Sign In to add comment