Last active
September 27, 2021 07:10
-
-
Save dn1t/77d7ddfa039297d0aefeb8599aac409f to your computer and use it in GitHub Desktop.
솔브인코딩
This file contains 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
textToSolve('솔바브보') // 바보바보바보솔브바보바보솔브솔브바보솔브솔브솔브솔브바보바보솔브바보솔브솔브바보솔브바보솔브솔브바보바보바보솔브바보솔브바보바보바보솔브바보바보솔브솔브솔브솔브바보솔브솔브바보솔브바보솔브솔브바보바보바보솔브바보솔브바보바보바보솔브바보바보바보솔브솔브솔브바보솔브솔브솔브바보바보솔브솔브바보바보바보솔브바보솔브바보바보바보솔브바보바보솔브솔브바보바보바보솔브바보바보솔브바보솔브솔브 | |
solveToText('바보바보바보솔브바보바보솔브솔브바보솔브솔브솔브솔브바보바보솔브바보솔브솔브바보솔브바보솔브솔브바보바보바보솔브바보솔브바보바보바보솔브바보바보솔브솔브솔브솔브바보솔브솔브바보솔브바보솔브솔브바보바보바보솔브바보솔브바보바보바보솔브바보바보바보솔브솔브솔브바보솔브솔브솔브바보바보솔브솔브바보바보바보솔브바보솔브바보바보바보솔브바보바보솔브솔브바보바보바보솔브바보바보솔브바보솔브솔브') // 솔바브보 |
This file contains 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 _zero = '솔브', | |
_one = '바보'; | |
const textToSolve = (text) => | |
Array.from(new TextEncoder().encode(text)) | |
.flatMap((b) => b.toString(2).padStart(8, 0).split('')) | |
.map((b) => (Number(b) === 0 ? _zero : _one)) | |
.join(''); | |
const solveToText = (solve) => { | |
const bitArray = solve.replaceAll(_zero, 0).replaceAll(_one, 1).split('').map(Number); | |
const byteArray = (() => { | |
const chunk = []; | |
for (let i = 0; i < bitArray.length; i += 8) chunk.push(bitArray.slice(i, 8 + i).join('')); | |
return chunk; | |
})().map((b) => parseInt(b, 2)); | |
const result = new TextDecoder().decode(Uint8Array.from(byteArray)); | |
return result; | |
}; |
soy0ka
commented
Sep 27, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment