Guest User

Untitled

a guest
Dec 6th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. M = importdata('input.txt');
  2. Part1 = 0; allM = M;
  3. while 1
  4. Part1 = Part1+1;
  5. [z,i] = max(M);
  6. M(i) = 0;
  7. j = i+1;
  8. while z>0
  9. if j>length(M);j=1;end
  10. M(j) = M(j)+1;
  11. z = z-1;
  12. j = j+1;
  13. end
  14. if any(all(repmat(M,size(allM,1),1)==allM,2));break;end
  15. allM = [allM;M];
  16. end
  17. allM = [allM;M];
  18. Part1
  19. Part2 = diff(find(all(repmat(M,size(allM,1),1)==allM,2)))
Advertisement
Add Comment
Please, Sign In to add comment