Created
December 17, 2019 10:58
-
-
Save gkucmierz/1c4c5c06d956f26191ea0cb37e09dd0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const print2dGrid = (grid, pad = 2) => { | |
const p = ' '.repeat(pad); | |
console.log(['', ...grid.map(r => r.map(n => (p+n).substr(-pad)).join` `), ''].join`\n`); | |
}; | |
const square = [ | |
[1, 2, 3, 6, 2, 8, 1], | |
[4, 8, 2, 4, 3, 1, 9], | |
[1, 5, 3, 7, 9, 3, 1], | |
[4, 9, 2, 1, 6, 9, 5], | |
[7, 6, 8, 4, 7, 2, 6], | |
[2, 1, 6, 2, 4, 8, 7], | |
[8, 4, 3, 9, 2, 5, 8]]; | |
print2dGrid(square); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment