From 0185252461f4a160396925607cb023a620bc3533 Mon Sep 17 00:00:00 2001 From: g8up Date: Thu, 28 May 2020 01:57:12 +0800 Subject: [PATCH] =?UTF-8?q?Gitee=20=E7=94=9F=E6=97=A5=E5=BF=AB=E4=B9=90?= =?UTF-8?q?=EF=BC=81=20=E5=90=8C=E5=BF=97=E4=BB=AC=EF=BC=8C=E5=88=AB?= =?UTF-8?q?=E6=80=AA=E6=88=91=E5=89=A7=E9=80=8F=E5=95=8A=EF=BC=81=20?= =?UTF-8?q?=E6=88=91=E5=88=86=E4=BA=AB=E5=88=B0=E4=BA=86=E6=9C=8B=E5=8F=8B?= =?UTF-8?q?=E5=9C=88=EF=BC=8C=E5=8D=B4=E5=8F=AA=E9=9B=86=E4=BA=8610?= =?UTF-8?q?=E4=B8=AA=E8=B5=9E=E3=80=82=20=E5=AE=85=E5=88=B0=E6=B2=A1?= =?UTF-8?q?=E6=9C=8B=E5=8F=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...13\347\254\254\344\270\211\345\205\263.md" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "\347\240\201\345\212\233\346\243\200\346\265\213\347\254\254\344\270\211\345\205\263.md" diff --git "a/\347\240\201\345\212\233\346\243\200\346\265\213\347\254\254\344\270\211\345\205\263.md" "b/\347\240\201\345\212\233\346\243\200\346\265\213\347\254\254\344\270\211\345\205\263.md" new file mode 100644 index 0000000..0bcfec3 --- /dev/null +++ "b/\347\240\201\345\212\233\346\243\200\346\265\213\347\254\254\344\270\211\345\205\263.md" @@ -0,0 +1,39 @@ +# Gitee 7 周年-码力检测第三关 +![书信](https://oschina.gitee.io/gitee-7th/img/level_3.53a48ed9.png) + +```js +/** 转换为平仄,映射 0、1 */ +const parseTone = (tone) => { + return [3, 4].includes(tone) ? 1 : 0; +}; + +const decode = (data) => { + return data.map(bins => { + return parseInt(bins.join(''), 2) + }); +}; + +const toChar = code => String.fromCharCode(code); + +/** 按声调标注(轻声发音按单字原音) */ +const tonesGroup = [ + [2, 4, 3, 2, 2, 1, 4, 1], + [2, 4, 4, 4, 2, 4, 2, 4], + [1, 4, 4, 1, 2, 4, 4, 4], + [2, 4, 4, 4, 2, 1, 2, 2], + [1, 4, 4, 2, 4, 4, 1, 2], + [2, 4, 4, 1, 2, 1, 2, 3], + [2, 3, 3, 2, 3, 4, 3, 2], + [1, 4, 4, 1, 1, 4, 1, 4], + [2, 4, 4, 4, 1, 4, 2, 1] +]; + +const binary = tonesGroup.map((tones) => { + return tones.map(parseTone); +}); + +const answer = decode(binary).map(toChar).join(''); + +// console.log( 'binary:\n', binary ); +console.log(answer); +``` \ No newline at end of file -- Gitee