Skip to content

Instantly share code, notes, and snippets.

@rosd89
Created September 16, 2017 06:50
Show Gist options
  • Save rosd89/4acaab8923573257d945999f70313caa to your computer and use it in GitHub Desktop.
Save rosd89/4acaab8923573257d945999f70313caa to your computer and use it in GitHub Desktop.
const lenCheck = (n, str) => str.length < n ? '0'.repeat(n - str.length) + str : str;
function solution(n, arr1, arr2) {
const answer = [];
for(let i=0; i<arr1.length; i++) {
const n1 = lenCheck(n, (+arr1[i]).toString(2));
const n2 = lenCheck(n, (+arr2[i]).toString(2));
const l = [];
for(let j=0; j < n; j++) {
l.push(n1[j] === '1' || n2[j] === '1' ? '#' : ' ');
}
answer[i] = l.join('');
}
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment