Created
December 3, 2018 09:51
-
-
Save stefanoschrs/765a3bedd91b53374d76cf679f9cf8b5 to your computer and use it in GitHub Desktop.
Flex grid fill last row
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 W = 4 | |
function fill(x) { | |
for(let i=0; i<x; i+=W){ | |
for(let j=0; j<W && i + j < x; j++) { | |
process.stdout.write('x') | |
} | |
if (i < x - W && parseInt(i/W) === i/W) { | |
console.log() | |
} | |
} | |
for(let i=0; i<(W-x%W) && x % W !== 0; i++) { | |
process.stdout.write('o') | |
} | |
} | |
for(let i=1; i<=10; i++){ | |
console.log(`>> ${i} <<`) | |
fill(i) | |
console.log() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment