Sorry for resubmitting an old regexp solution. Seems, that previous one disappeared. I have to solve this problem the proper way.
I think that this solution is perfectly legitimate. Why try to solve it "properly"? It's not like you are using eval or something like that. regexprep is a perfectly legitimate tool to use.
I agree with your point of view. Regexprep is a powerful function here.
Unfortunately I've used also '(??@some_code)'. In this case, it's not as bad as playing 'size=11' solution, but it is still a kind of size-cheating for me. I used to play solutions like that, but now I try to avoid this.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
deck = [1 4 7 10 13 16 19 22 25 28 3 6 9 12 15 18 21 24 27 2 5 8 11 14 17 20 23 26];
n = 10;
out = [8 26 1 4 7 23 8 8 4 24];
assert(isequal(solitaire(deck, n),out))
|
2 | Pass |
%%
deck = 1:28;
n = 10;
out = [3 22 9 4 23 7 25 16 14 14];
assert(isequal(solitaire(deck, n),out))
|
3 | Pass |
%%
deck = 1:28;
n = 9;
out = [3 22 9 4 23 7 25 16 14];
assert(isequal(solitaire(deck, n),out))
|
284 Solvers
Solve the set of simultaneous linear equations
274 Solvers
Compute a dot product of two vectors x and y
750 Solvers
250 Solvers
664 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!