mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-26 02:29:50 +05:30
17 lines
451 B
D
17 lines
451 B
D
|
import std.algorithm.iteration : filter;
|
||
|
import std.algorithm.searching : count;
|
||
|
import std.ascii : isAlpha, isWhite;
|
||
|
import std.file : read;
|
||
|
import std.stdio : writefln;
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
auto fileContent = cast(string)read("file.txt");
|
||
|
auto totalLetters =
|
||
|
count(filter!(a => isAlpha(a) || isWhite(a))(fileContent));
|
||
|
auto percentage = (totalLetters * 100) / cast(double)fileContent.length;
|
||
|
|
||
|
writefln("Percentage of letters: %.0f", percentage);
|
||
|
}
|
||
|
|