{
"env": {
"test": {
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
}
}
npm install --save-dev @babel/plugin-transform-modules-commonjs
Q
?const magic = size => {
const rows = [];
const template = '.'.repeat(size);
for (let row = 0; row < size; row++) {
const index = Math.floor(Math.random() * size);
const value = `${template.slice(0, index)}Q${template.slice(index + 1)}`;
rows.push(value);
}
return rows.join('\n');
};
console.log(magic(10));
/*
...Q......
......Q...
Q.........
.........Q
....Q.....
......Q...
.Q........
.....Q....
..Q.......
....Q.....
*/