Cody

Problem 45368. Sky full of stars - 01

Solution 2169333

Submitted on 22 Mar 2020 by Mehmed Saad
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
a= ['* ' '** ' '*** ' '**** ' '*****'] assert(isequal( star_pattern(5,'bl'),a))

a = 5×5 char array '* ' '** ' '*** ' '**** ' '*****' x = 0

2   Pass
a= [' *' ' **' ' ***' ' ****' ' *****' '******'] assert(isequal( star_pattern(6,'br'),a))

a = 6×6 char array ' *' ' **' ' ***' ' ****' ' *****' '******' x = 1

3   Pass
a= ['****' ' ***' ' **' ' *'] assert(isequal( star_pattern(4,'tr'),a))

a = 4×4 char array '****' ' ***' ' **' ' *' x = 2

4   Pass
a= [ '**********' '********* ' '******** ' '******* ' '****** ' '***** ' '**** ' '*** ' '** ' '* '] assert(isequal( star_pattern(10,'tl'),a))

a = 10×10 char array '**********' '********* ' '******** ' '******* ' '****** ' '***** ' '**** ' '*** ' '** ' '* ' x = 3

5   Pass
a= [ '***************' ' **************' ' *************' ' ************' ' ***********' ' **********' ' *********' ' ********' ' *******' ' ******' ' *****' ' ****' ' ***' ' **' ' *'] assert(isequal( star_pattern(15,'tr'),a))

a = 15×15 char array '***************' ' **************' ' *************' ' ************' ' ***********' ' **********' ' *********' ' ********' ' *******' ' ******' ' *****' ' ****' ' ***' ' **' ' *' x = 2

Suggested Problems

More from this Author149

Community Treasure Hunt

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

Start Hunting!