Cody

Problem 535. Rotate and display numbered tile

Imagine a square tile with four numbers on it, one on each edge. We will call these edges north, east, south, and west.

If the four numbers were [1 5 7 9], this vector would be displayed with the numbers going around clockwise from the north like so:

    1  
  9   5
    7  

But the tile can appear in four different orientations. Let's say that when the north is 1, then the first number appears in the north position. If north is 2, then the second number appears in the north position, and so on. So if the tile numbers are [1 5 7 9] and the orientation parameter north is 3, then it would display like so, since 7 is the third number:

    7  
  5   9
    1  

The numbers you are given will always be one or two digit positive integers. You must return a 3-by-6 character array that fits this template:

..NN..
WW..EE
..SS..

where dots are used to indicate spaces (ASCII 32). One digit numbers should be right aligned. In the example given immediately above, the output should look like this:

 Inputs t = [1 5 7 9], north = 3
 Output is  ['   7  '
             ' 5   9'
             '   1  ']

Solution Stats

34.99% Correct | 65.01% Incorrect
Last solution submitted on Oct 18, 2017

Problem Comments

Solution Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!