tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
16
Task/Run-length-encoding/AWK/run-length-encoding-1.awk
Normal file
16
Task/Run-length-encoding/AWK/run-length-encoding-1.awk
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
BEGIN {
|
||||
FS=""
|
||||
}
|
||||
/^[^0-9]+$/ {
|
||||
cp = $1; j = 0
|
||||
for(i=1; i <= NF; i++) {
|
||||
if ( $i == cp ) {
|
||||
j++;
|
||||
} else {
|
||||
printf("%d%c", j, cp)
|
||||
j = 1
|
||||
}
|
||||
cp = $i
|
||||
}
|
||||
printf("%d%c", j, cp)
|
||||
}
|
||||
13
Task/Run-length-encoding/AWK/run-length-encoding-2.awk
Normal file
13
Task/Run-length-encoding/AWK/run-length-encoding-2.awk
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
BEGIN {
|
||||
RS="[0-9]+[^0-9]"
|
||||
final = "";
|
||||
}
|
||||
{
|
||||
match(RT, /([0-9]+)([^0-9])/, r)
|
||||
for(i=0; i < int(r[1]); i++) {
|
||||
final = final r[2]
|
||||
}
|
||||
}
|
||||
END {
|
||||
print final
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue