Problem 2701. Go to the head of the class!
You're given a matrix and a single number. If that number is in the matrix, reorder the matrix so that number is in the first row and first column of the matrix, and keep all of the other numbers in the same relative position. For example, your matrix is magic(3):
8 1 6 3 5 7 4 9 2
and the number is nine. You want to change the matrix to
9 2 4 1 6 8 5 7 3
Nine is now in the (1,1) position, and all of the other numbers are in the same relative position to nine. If the number is not in the matrix, just return the original matrix. Likewise, if the number appears more than once, make sure the first instance of the number is the one that is moved to the front. Good luck!
Solution Stats
Problem Comments
-
2 Comments
How is this different from problem 2493 (which is also in Matrix Manipulation II)?
This problem is exactly the same as the previous one, "Must be in the fornt row..."
Solution Comments
Show commentsGroup

Project Euler II
- 12 Problems
- 51 Finishers
- Find the longest sequence of 1's in a binary sequence.
- Convert given decimal number to binary number.
- Find out sum and carry of Binary adder
- Binary numbers
- Given an unsigned integer x, find the largest y by rearranging the bits in x
- Bit Reversal
- Relative ratio of "1" in binary number
- Binary code (array)
- Converting binary to decimals
- There are 10 types of people in the world
Problem Recent Solvers132
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!