Perl, 32 + 32 = 64
A sequência é esperada em STDIN. A saída é gravada em STDOUT. O espaço em branco é ignorado. Minha interpretação da tarefa é que o programa deve ser capaz de rodar sozinho para obter a pontuação.
$/ = $,;
$_ = <>;
s x\sxxg;
$\ = length;
print s x[0-9a-z]xxgi,
' + ',
s x.xxg,
' = '
Ungolfed com comentários
$/ = $,; # The input separator becomes undefined, because the default for $, is "undef"
$_ = <>; # now $_ takes the whole file (STDIN) instead of the first line
s x\sxxg; # $_ =~ s/\s//g;
# white space is removed from $_
$\ = length; # The number of the other characters are put into $\,
# which is automatically printed the end of "print".
print s x[0-9a-z]xxgi, # s/[0-9a-z]//gi
# Remove alphanumeric characters and return their count
' + ',
s x.xxg, # s/.//g
# Remove the remaining special characters and return their count.
# "." does not catch new lines, but we have already
# removed white spaces including new lines.
' = '
Encontrei várias variações com a mesma contagem de bytes, por exemplo:
$/ = $x;
$_ = <>, s x\sxxg;
$\ = split $x;
print s x[\da-z]xxgi,
" + ",
s x.xxg,
' = '
Exemplos
Exemplo da pergunta:
echo 'http://stackexchange.com' | perl a.pl
20 + 4 = 24
Executando em si mesmo ( a.pl
):
cat a.pl | perl a.pl
32 + 32 = 64
O tamanho do arquivo é 104 bytes, portanto, 40 bytes são ignorados como espaço em branco.
Perl, 29 + 29 = 58
$_=<>;s x\sxxg;$\=length;print s x[0-9a-z]xxgi,' + ',s/.//g,' = '
A sequência é esperada em STDIN e é limitada à primeira linha. O resultado é impresso em STDOUT. O espaço em branco é ignorado.
Ungolfed
$_ = <>;
s x\sxxg; # same as s/\s//gx; removes white space;
$\ = length($_); # sum is automatically appended at the end of print
print sx[0-9a-z]xxgi, # same as s/[0-9a-z]//gi;
# the number of alphanumeric characters
' + ',
s/.//g, # the number of the remaining special characters
' = '
Exemplos
O arquivo a.pl
contém o script Perl.
Exemplo da pergunta:
echo 'http://stackexchange.com' | perl a.pl
20 + 4 = 24
Executando em si mesmo:
cat a.pl | perl a.pl
29 + 29 = 58
O tamanho do arquivo a.pl
é de 65 bytes, portanto, 7 bytes são ignorados como espaço em branco.
O.
,O?
e,O!
em seguida, qualquer gravação programa que eu atenda a restrição classe de personagem ... Claro que é provável que perca no negócio do comprimento.