Skip to content

Instantly share code, notes, and snippets.

@jikeytang
Last active August 29, 2015 14:04
Show Gist options
  • Save jikeytang/0144e458d9ab648eed85 to your computer and use it in GitHub Desktop.
Save jikeytang/0144e458d9ab648eed85 to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140730-题目1
// 感谢[广州—坚壳]贡献
编码字符串,要求能解码,且只能编码为字母和数字,
要求得到最短的编码长度。
如:
setcode('你好a') -> ‘232abc';
getcode('232abc') -> '你好a'
PS:
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。
```javascript
// you code
```
2. 粘贴代码时请使用shift+tab,缩进前面的空白。
@karrynew
Copy link

楼上的这个stringEncode传的字符串越多。执行函数出来的return 的字符串也越多,这样是不是失去意义了!!,如果这样的话 随便都可以弄一个了

stringEncode('dgd')
"310031033100"
stringEncode('dgddsfsf')
"31003103310031003115310231153102"
stringEncode('dgddsfsfdgdgdg')
"31003103310031003115310231153102310031033100310331003103"
stringEncode('dgddsfsfdgdgdg453t3tg')
"31003103310031003115310231153102310031033100310331003103252253251311625131163103"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment