Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve in typescript. Thank you Task description You have an array of numbers and you would like to print these numbers in a tabular
Please solve in typescript. Thank you
Task description
You have an array of numbers and you would like to print these numbers in a tabular format to make them look more organized. Each cell of the table contains exactly one number and is surrounded by exactly four edges:
As you can see above, each corner of the cell is represented by a sign, vertical edges by signs and horizontal edges by signs. The width of the cell adjusts to accommodate the number of digits of the number written within it There can be many cells in a row. Adjacent cells share an edge:
Note that each cell has the same width. The width of the cell adjusts to match the width of the longest number in the table. The numbers in cells are aligned to the right, with any unused area in each cell filled with spaces.
The table can consist of many rows, and adjacent rows share an edge:
Your goal is to output a table containing all the numbers from a given array such that each row contains exactly K numbers. The last row can contain fewer numbers.
Write a function:
function solutionA K;
that, given a nonempty array A consisting of N integers and an integer K prints a string representing the formatted array. The numbers in the table should appear in the same order as the numbers in the array.
For example, given array A and K the resultant table will contain exactly one row, as shown below:
For A K the table would appear as follows:
Given A and K the table would appear as follows:
The function shouldn't return any value.
You can print a string to the output without or with the endofline character as follows:
process.stdout.writesample string'; process.stdout.writewhole line
;
Assume that:
N is an integer within the range ;
K is an integer within the range ;
each element of array A is an integer within the range
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started