Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Run-length-encoding/PowerShell/run-length-encoding.psh
Normal file
18
Task/Run-length-encoding/PowerShell/run-length-encoding.psh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
function Compress-RLE ($s) {
|
||||
$re = [regex] '(.)\1*'
|
||||
$ret = ""
|
||||
foreach ($m in $re.Matches($s)) {
|
||||
$ret += $m.Length
|
||||
$ret += $m.Value[0]
|
||||
}
|
||||
return $ret
|
||||
}
|
||||
|
||||
function Expand-RLE ($s) {
|
||||
$re = [regex] '(\d+)(.)'
|
||||
$ret = ""
|
||||
foreach ($m in $re.Matches($s)) {
|
||||
$ret += [string] $m.Groups[2] * [int] [string] $m.Groups[1]
|
||||
}
|
||||
return $ret
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue