Draw a '2' in a zero matrix! - MATLAB Cody - MATLAB Central

Problem 50877. Draw a '2' in a zero matrix!

Difficulty:Rate
Given an x-by-x matrix filled with zeros (x is odd and > 3). Use 2s to draw the number 2 into it! Like this:
x = 5, y =
2 2 2 2 2
0 0 0 0 2
2 2 2 2 2
2 0 0 0 0
2 2 2 2 2
x = 7, y =
2 2 2 2 2 2 2
0 0 0 0 0 0 2
0 0 0 0 0 0 2
2 2 2 2 2 2 2
2 0 0 0 0 0 0
2 0 0 0 0 0 0
2 2 2 2 2 2 2

Solution Stats

65.42% Correct | 34.58% Incorrect
Last Solution submitted on Mar 01, 2025

Problem Comments

Solution Comments

Show comments
Primes and Rough Numbers, Basic ideas
What is a rough number? What can they be used...
3
5

Problem Recent Solvers480

Suggested Problems

More from this Author12

Problem Tags

x

Community Treasure Hunt

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

Start Hunting!
Go to top of page