A pincode consists of N integers between 1 and 9. In a valid pincode, no integer is allowed to repeat consecutively. Ex: The sequence 1, 2,1, 3 is valid because even though 1 occurs twice, it is not consecutive. However, the sequence 1, 2, 2, 1 is invalid because 2 occurs twice, consecutively. Utilize a for loop and branch statements to write a function called pinCodeCheck to detect and eliminate all the consecutive repetitions in the row array pinCode. The function outputs should be two row arrays. The row array repPos contains the positions pinCode where the consecutive repeats occurs, and the row array pincodeFix is a valid pincode with all the consecutive repeats removed in pinCode. Hint: The empty array operator [] is will be helpful to use.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please answer in matlab code.

Pincode
A pincode consists of N integers between 1 and 9. In a valid pincode, no integer is allowed to repeat consecutively. Ex: The sequence 1,
2,1, 3 is valid because even though 1 occurs twice, it is not consecutive. However, the sequence 1, 2, 2, 1 is invalid because 2 occurs
twice, consecutively.
Utilize a for loop and branch statements to write a function called pinCodeCheck to detect and eliminate all the consecutive repetitions in
the row array pinCode. The function outputs should be two row arrays. The row array repPos contains the positions pinCode where the
consecutive repeats occurs, and the row array pincodeFix is a valid pincode with all the consecutive repeats removed in pincode.
Hint: The empty array operator [] is will be helpful to use.
Ex:
> pincode = [2,9,9,5,5,3];
[ repPos, pinCodeFix ] = pinCodeCheck( pinCode )
produces
repPos =
pincodeFix =
2
9
5
3
Function e
A Save
C Reset
I MATLAB Documentation
1 function [ repPos, pinCodeFix ]
pincodecheck( pincode )
=
2
3
% Your solution goes here
4
5 end
Code to call your function e
C Reset
1 pincode
2 [ repPos, pinCodeFix ] = pinCodeCheck( pinCode )
[2,9,9,5,5,3];
%3D
Transcribed Image Text:Pincode A pincode consists of N integers between 1 and 9. In a valid pincode, no integer is allowed to repeat consecutively. Ex: The sequence 1, 2,1, 3 is valid because even though 1 occurs twice, it is not consecutive. However, the sequence 1, 2, 2, 1 is invalid because 2 occurs twice, consecutively. Utilize a for loop and branch statements to write a function called pinCodeCheck to detect and eliminate all the consecutive repetitions in the row array pinCode. The function outputs should be two row arrays. The row array repPos contains the positions pinCode where the consecutive repeats occurs, and the row array pincodeFix is a valid pincode with all the consecutive repeats removed in pincode. Hint: The empty array operator [] is will be helpful to use. Ex: > pincode = [2,9,9,5,5,3]; [ repPos, pinCodeFix ] = pinCodeCheck( pinCode ) produces repPos = pincodeFix = 2 9 5 3 Function e A Save C Reset I MATLAB Documentation 1 function [ repPos, pinCodeFix ] pincodecheck( pincode ) = 2 3 % Your solution goes here 4 5 end Code to call your function e C Reset 1 pincode 2 [ repPos, pinCodeFix ] = pinCodeCheck( pinCode ) [2,9,9,5,5,3]; %3D
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education