Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
|||
encode = (str) ->
|
||||
str.replace /(.)\1*/g, (w) ->
|
||||
w[0] + w.length
|
||||
|
||||
decode = (str) ->
|
||||
str.replace /(.)(\d+)/g, (m,w,n) ->
|
||||
new Array(+n+1).join(w)
|
||||
|
||||
console.log s = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"
|
||||
console.log encode s
|
||||
console.log decode encode s
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
encode = (str, offset = 75) ->
|
||||
str.replace /(.)\1*/g, (w) ->
|
||||
w[0] + String.fromCharCode(offset+w.length)
|
||||
|
||||
decode = (str, offset = 75) ->
|
||||
str.split('').map((w,i) ->
|
||||
if not (i%2) then w else new Array(+w.charCodeAt(0)-offset).join(str[i-1])
|
||||
).join('')
|
||||
Loading…
Add table
Add a link
Reference in a new issue