Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = importdata('input.txt');
- L = size(x,1);
- N = 25;
- P25 = x(1:N);
- %Part A:
- for idx = N+1:L
- z = repmat(P25,1,N);
- T = z+z';
- T(1:N+1:N^2)=-1;
- if ~any(any(x(idx)==T))
- answerPartA = x(idx)
- break
- end
- P25 = x(idx+1-N:idx);
- end
- %Part B:
- for i=1:L
- for j=i+1:L
- if sum(x(i:j))<answerPartA
- continue
- elseif sum(x(i:j))==answerPartA
- answerPartB = min(x(i:j))+max(x(i:j))
- else
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment