Autogram checker: Difference between revisions
m
syntax highlighting fixup automation
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: various simplifications) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 66:
In other words, we explicitly ignore details which were not specified in the task description as requirements of all autograms.
Implementation: <
normalize=: {{ tolower ' '(I.(tolower=toupper)y)}y }}
normalize=: tolower@#~ tolower~:toupper
Line 92:
grams=: (, }.@rplc&('Zone';'Zsingle')@('Z'&,)L:0) grams
*/+./+./@E.&(normalizep2 Y) every grams
}}</
Task examples:<
1
autogram {{)n This sentence employs two a's, two c's, two d's, twenty eight e's, five f's, three g's, eight h's, eleven i's, three l's, two m's, thirteen n's, nine o's, two p's, five r's, twenty five s's, twenty three t's, six v's, ten w's, two x's, five y's, and one z.}}
Line 109:
0
autogram {{)n Sixteen e's, five f's, three g's, six h's, nine i's, five n's, four o's, six r's, eighteen s's, eight t's, three u's, three v's, two w's, four z's.}}
0</
As an aside, this illustrates that rosettacode's J syntax highlighter does not properly handle J's {{)n delimited character literals (a recent language feature, introduced in J903).
Line 115:
=={{header|Julia}}==
Validating the total letter count when used.
<
using DataStructures
Line 192:
println("Test phrase $i is", isautogram(t[1], t[2]) ? " " : " not ", "a valid autogram.\n")
end
</
<pre>
Test phrase 1 is a valid autogram.
Line 214:
=={{header|Perl}}==
<
use experimental <builtin for_list>;
use Sub::Util 'subname';
Line 278:
if $str =~ /(\d+) letters/;
say "\n" . '=' x 101;
}</
{{out}}
<pre style="height:60ex">This sentence employs two a's, two c's, two d's, twenty-eight e's, five f's, three g's, eight h's,
Line 415:
=={{header|Phix}}==
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">tests</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">split</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">substitute</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"""
Line 522:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Autogram? %t%s\n\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">autogram</span><span style="color: #0000FF;">,</span><span style="color: #000000;">diff</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</
{{out}}
<pre>
Line 560:
Using [https://raku.land/github:jkramer/Text::Wrap Text::Wrap] from the ecosystem. Install command: <code>zef install -v git://github.com/jkramer/p6-Text-Wrap.git</code>.
<
:12twelve, :13thirteen, :14fourteen, :15fifteen, :16sixteen, :17seventeen, :18eighteen, :19nineteen,
:20twenty, :30thirty, :40forty, :50fifty, :60sixty, :70seventy, :80eighty, :90ninety, :100hundred, :1single;
Line 610:
say '=' x 100;
}</
{{out}}
<pre style="height:50ex;overflow:scroll;">====================================================================================================
Line 738:
{{libheader|Wren-str}}
Frankly, not a bullet-proof solution but good enough to check the required sentences.
<
var numbers = [
Line 854:
autogram.call(t[0], t[1])
System.print("=" * 80)
}</
{{out}}
|