Count spelling errors in text; minimize the number of spelling errors in your code
Perl 6, 134 spelling errors



my token punctuation {&lt;[.,;:!?]&gt;}
my \text = slurp; my \mistakes=[]; for split /\.|\!|\?/, text { for .trim.match: :g, /&lt;:letter&gt;+/ -&gt; \word { (append mistakes, .comb when none words slurp pi given lc word) or (push mistakes, $_ if ((.from or word.from) xor m/&lt;[a..z]&gt;/) for word.match: :g, /./) }}
append mistakes, comb / &lt;after \s | &lt;punctuation&gt;&gt; &lt;punctuation&gt; | &lt;!before &lt;punctuation&gt; | &lt;:letter&gt; | \s&gt; . | &lt;!after \.|\!|\?&gt; \n | [&lt;before ^&gt; | &lt;after \s&gt;] \s /, text; say mistakes.Numeric


With extra whitespace for readability:

my token punctuation {&lt;[.,;:!?]&gt;}
my \text = slurp;
my \mistakes=[];
for split /\.|\!|\?/, text {
    for .trim.match: :g, /&lt;:letter&gt;+/ -&gt; \word {
        (append mistakes, .comb when none words slurp pi given lc word)
        or
        (push mistakes, $_ if ((.from or word.from) xor m/&lt;[a..z]&gt;/) for word.match: :g, /./)
    }
}
append mistakes, comb /
  &lt;after \s | &lt;punctuation&gt;&gt; &lt;punctuation&gt;
  | &lt;!before &lt;punctuation&gt; | &lt;:letter&gt; | \s&gt; .
  | &lt;!after \.|\!|\?&gt; \n
  | [&lt;before ^&gt; | &lt;after \s&gt;] \s
/, text;
say mistakes.Numeric


Notes:


Expects the dictionary in a file called 3.14159265358979 in the current working directory.
The only inspired part is the line
append mistakes, .comb when none words slurp pi given lc word,
the rest is pretty bad. But maybe it can at least serve as a baseline for better solutions... :)