Problem 2153. Replace pattern 0 1 0 and 1 0 1
Find and replace a pattern in a row of zeroes and ones.
- Find 1 0 1 and replace it with 1 1 1
- Find 0 1 0 and replace it with 0 0 0
Example:
Input : [ 1 1 1 0 1 1 0 0 0 1 0 0 0 ] Output: [ 1 1 1 1 1 1 0 0 0 0 0 0 0 ]
Solution Stats
Problem Comments
-
2 Comments
goc3
on 15 Mar 2017
Additional test cases have been added.
Rafael S.T. Vieira
on 24 Jul 2020
What about intersecting cases? like 1 0 1 0 or 0 1 0 1 ?
Solution Comments
Show commentsGroup

Computer Games II
- 12 Problems
- 2 Finishers
- One track five lanes
- PONG 002: Rectangle, Interactive Download, Easier Play
- PONG 003: 3-Ball Rectangle, Interactive Download
- Capture the flag(s)
- GJam 2014 China Rd A: Maze with a Left Hand Rule
- GJam 2014 China Rd B: Dragon Maze
- 2048 tile game
- PACMAT - G03 Ghosts use minimum path to PACMAT; 3 Lives
- PACMAT 04 - Optimized Ghosts, Equal Speed, 10 Lives
- PACMAT 05 - Optimized Ghosts, PACMAT increasing speed, 12 Lives
- The sliding puzzle: 15
- Fifteen Parity Check
Problem Recent Solvers147
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!