Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- M = importdata('input.txt');
- Part1 = 0; allM = M;
- while 1
- Part1 = Part1+1;
- [z,i] = max(M);
- M(i) = 0;
- j = i+1;
- while z>0
- if j>length(M);j=1;end
- M(j) = M(j)+1;
- z = z-1;
- j = j+1;
- end
- if any(all(repmat(M,size(allM,1),1)==allM,2));break;end
- allM = [allM;M];
- end
- allM = [allM;M];
- Part1
- Part2 = diff(find(all(repmat(M,size(allM,1),1)==allM,2)))
Advertisement
Add Comment
Please, Sign In to add comment