AreWe

Orbit

Jun 9th, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ([w, h, x, y]) => {
  2.     let rows = w;
  3.     let cols = h;
  4.     let starRow = x;
  5.     let starCol = y;
  6.  
  7.     let output = '';
  8.  
  9.     for(let row = 0; row< rows; row++) {
  10.         for(let col=0; col<cols; col++) {
  11.             output += `${Math.max(Math.abs(row - starRow), Math.abs(col - starCol)) + 1} `;
  12.         }
  13.         output += '\n';
  14.     }
  15.  
  16.     console.log(output);
  17. }
Add Comment
Please, Sign In to add comment