tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 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