Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ([w, h, x, y]) => {
- let rows = w;
- let cols = h;
- let starRow = x;
- let starCol = y;
- let output = '';
- for(let row = 0; row< rows; row++) {
- for(let col=0; col<cols; col++) {
- output += `${Math.max(Math.abs(row - starRow), Math.abs(col - starCol)) + 1} `;
- }
- output += '\n';
- }
- console.log(output);
- }
Add Comment
Please, Sign In to add comment