Final Test Dev: 1. Dynamic Table
Final Test Dev: 1. Dynamic Table
1. Dynamic Table
Please create a function that will create a dynamic table that contains numbers. It has 2 parameters,
parameter 1 is an array of numbers as the content of the table, and parameter 2 is a number as the maximum
number of column per row.
Details:
F(X, y)
Additional rules:
a. Maximum length that a column can contains is the longest length of a number in the array.
b. You will put a star ( * ) for any number in a column that not as long as the maximum length of the
column.
c. The numbers will be placed in the table sequentially same as the way you put it in the array, start
from top left of the first row, go to the max column, then going down. So last number should be at
the bottom (most right) of the last row.
Sample input:
|667543|**8637|*****0|***369|
** 7 516 | ***335
2. Castle Builder
Please create a function that will count how many castle that you can build. It has 1 parameter which is an
array of numbers as the land height per 1 block length.
Details:
F(X)
Additional rules:
b. Hill contains block(s) with the height is taller than the neighbors blocks.
c. Valley contains block(s) with the height is shorter than the neighbors blocks.
d. Incomplete hill or valley at the first and the last block, still can be used to build a castle (considered as
hill or valley)
Sample input: