Perl,32 + 32 = 64
该字符串应在STDIN中使用。输出写入STDOUT。空格被忽略。我对任务的解释是该程序应该能够自行运行以获取分数。
$/ = $,;
$_ = <>;
s x\sxxg;
$\ = length;
print s x[0-9a-z]xxgi,
' + ',
s x.xxg,
' = '
取消评论
$/ = $,; # 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.
' = '
我发现了几个具有相同字节数的变体,例如:
$/ = $x;
$_ = <>, s x\sxxg;
$\ = split $x;
print s x[\da-z]xxgi,
" + ",
s x.xxg,
' = '
例子
Perl,29 + 29 = 58
$_=<>;s x\sxxg;$\=length;print s x[0-9a-z]xxgi,' + ',s/.//g,' = '
该字符串应在STDIN中使用,并且仅限于第一行。结果打印到STDOUT。空格被忽略。
不打高尔夫球
$_ = <>;
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
' = '
例子
文件a.pl
包含Perl脚本。
来自问题的示例:
echo 'http://stackexchange.com' | perl a.pl
20 + 4 = 24
自行运行:
cat a.pl | perl a.pl
29 + 29 = 58
文件大小a.pl
为65字节,因此7个字节被忽略为空白。
O.
,O?
以及O!
再任何程序我写符合角色职业限制......当然这是有可能失去在长度业务。