Perl, 71 6262 61 bytes
includes +1 for -n
$;=length($b+=y///c;$w+=split$"c);$w+=split$"}{$;=length$b;printf"%$;dprintf"%$;d %$;d $b",$.,$w
Commented:
while (<>) { # implicit because of -n
$b$; +== y///c;length( # countprintf charactersformatting: width
$w += split $"$b += y///c # count wordscharacters
}{ );
$w += split $" # count words
}{ # explicit: end while, begin END block
$; = length $b; # prepareexplicit: printfend formattingwhile, withbegin barewordEND block
printf "%$;d %$;d $b", $., $w # $. = $INPUT_LINE_NUMBER
} # implicit because of -n
- Save another byte, again thanks to @TonHospel.
- Save 9 bytes thanks to @TonHospel showing me a few tricks of the trade!