convert 2D array of ones and zeros to checkerboard array of [1,2] where the original array was ones and zero elsewhere - MATLAB Cody - MATLAB Central

Problem 43995. convert 2D array of ones and zeros to checkerboard array of [1,2] where the original array was ones and zero elsewhere

Difficulty:Rate

Given a 2D array of ones and zeros, generate an equivalent sized checkerboard array of ones and twos. The checkerboard pattern starts with 2:

[2,1,2,1,2;
1,2,1,2,1;
2,1,2,1,2];

Then set this checkerboard array to zero wherever the original was zero.

Solution Stats

55.07% Correct | 44.93% Incorrect
Last Solution submitted on Jan 14, 2024

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
2
3

Problem Recent Solvers26

Suggested Problems

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!