String length: Difference between revisions
→sed: de-obfuscate & simplify
m (→{{header|Kotlin}}: made the kotlin example not use java) |
(→sed: de-obfuscate & simplify) |
||
Line 3,029:
Text is read from standard input e.g. <code>echo "string" | sed -f script.sed</code> or <code>sed -f script.sed file.txt</code> (The solution given would be the contents of a text file <code>script.sed</code> in these cases).
For files with more than one line, sed will give a count for each line.
▲<syntaxhighlight lang="sed"># Change all characters to '|'.
:loop
▲s/./\|/g;
# divide by 10 (x = 10)
s/i\{10\}/x/g
# convert remainder to decimal digit
/i/!s/[0-9]*$/0&/
s/
s/
s/i\{7\}/7/
s/i\{6\}/6/
s/
s/iiii/4/
s/iii/3/
s/^$/0/</syntaxhighlight>▼
s/ii/2/
s/i/1/
# convert quotient (10s) to 1s
y/x/i/
# start over for the next magnitude (if any)
=={{header|Seed7}}==
|