पर्ल, 32 + 32 = 64
एसटीडीआईएन में स्ट्रिंग की उम्मीद है। आउटपुट 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,
' = '
उदाहरण
प्रश्न से उदाहरण:
echo 'http://stackexchange.com' | perl a.pl
20 + 4 = 24
अपने आप चल रहा है ( a.pl):
cat a.pl | perl a.pl
32 + 32 = 64
फ़ाइल का आकार 104 बाइट्स है, इस प्रकार 40 बाइट्स को सफेद स्थान के रूप में अनदेखा किया जाता है।
पर्ल, 29 + 29 = 58
$_=<>;s x\sxxg;$\=length;print s x[0-9a-z]xxgi,' + ',s/.//g,' = '
STDIN पर स्ट्रिंग अपेक्षित है और यह पहली पंक्ति तक सीमित है। परिणाम STDOUT में मुद्रित होता है। सफेद स्थान की अनदेखी की जाती है।
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
' = '
उदाहरण
फ़ाइल a.plमें पर्ल स्क्रिप्ट है।
प्रश्न से उदाहरण:
echo 'http://stackexchange.com' | perl a.pl
20 + 4 = 24
स्वयं चल रहा है:
cat a.pl | perl a.pl
29 + 29 = 58
फ़ाइल का आकार a.pl65 बाइट्स है, इस प्रकार 7 बाइट्स को सफेद स्थान के रूप में अनदेखा किया जाता है।
O.,O?, औरO!और उसके बाद किसी भी कार्यक्रम मैं लिख चरित्र वर्ग प्रतिबंध को पूरा करती है ... बेशक यह संभावना है लंबाई कारोबार पर कम करने के लिए।