Integers without repeating consecutively
Ältere Kommentare anzeigen
A pincode consists of N integers between 1 and 9. In a valid pincode, no integer is allowed to repeat consecutively. For example, 1, 4, 5, 5, 6, 7 is invalid because 5 occurs twice. I tested the example but it does not outputs what the example shows. Any suggestions.
.png)
1 Kommentar
Image Analyst
am 15 Okt. 2019
Insert code or attach the m-file. Make it easy for people to help you, not hard.
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 17 Okt. 2019
function [repPos, pinCodeFix] = pinCodeCheck(pinCode)
lo = [true;diff(pinCode(:)) ~= 0];
repPos = find(~lo);
pinCodeFix = pinCode(lo);
end
1 Kommentar
Blaine Warner
am 8 Okt. 2021
i don't think we are supposed to have learned any of that yet, if we are going in order of what we've learned how to impliment in the chapters, (and this homework requires using arrays which arent taught until the next chapter anyway, to the professor made these extra credit) all we are supposed to use is loops, arrays, and branches
Kategorien
Mehr zu Solver Outputs and Iterative Display finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!