Aww.. ran out of memory.
%the part of the code i cut out, should work in theory ..
fliplist = fliplr(list);
idx = triu(ones(length(list)),0);
for j = 1:length(idx)
idx2 = unique(perms(idx(j,:)),'rows');
[a b] = size(idx2);
for i = 1 : a
idxi = boolean(idx2(i,:)');
list2 = list;
list2(idxi,:) = fliplist(idxi,:);
list2 = list2';
list2 = list2(:);
dlist = abs(diff(list2));
val2 = sum(dlist(2:2:end));
if val2 < val
val = val2;
orientation = idxi';
end
if val == 0
return
end
end
end
Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
%%
list = [5 2
3 7
4 9
2 3
8 2
3 5
8 2
7 8
4 2
8 2];
y_correct = [0 0 1 1 1 1 1 1 0 1];
assert(isequal(findBestDominoeOrientation(list),y_correct))
Error: Assertion failed.
|
2 | Fail |
%%
list = [0 8
4 8
2 0
8 0
5 7
7 2
1 6
2 6
2 7
0 2];
y_correct = [0 1 0 1 1 1 1 0 1 1];
assert(isequal(findBestDominoeOrientation(list),y_correct))
Error: Assertion failed.
|
3 | Fail |
%%
list = [7 5
3 1
5 1
6 5
4 8
2 6
5 1
1 3
5 9
9 2
0 7
1 7];
y_correct = [0 0 1 1 1 0 0 0 0 0 0 1];
assert(isequal(findBestDominoeOrientation(list),y_correct))
Error: Assertion failed.
|
4 | Fail |
%%
list = [0 4
0 3
8 2
2 5];
y_correct = [1 0 1 1];
assert(isequal(findBestDominoeOrientation(list),y_correct))
Error: Assertion failed.
|
163 Solvers
Matrix indexing with two vectors of indices
485 Solvers
Return the first and last character of a string
3453 Solvers
Number of digits in an integer
336 Solvers
Flip the vector from right to left
2670 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!