Autogram checker: Difference between revisions

m
Automated syntax highlighting fixup (second round - minor fixes)
m (syntax highlighting fixup automation)
m (Automated syntax highlighting fixup (second round - minor fixes))
Line 1:
{{draft task}}
[[Category: String manipulation]]
[[Category:Strings]]
{{draft task}}
;Definition
An '''autogram''' is a sentence that describes itself in the sense of providing an inventory of its own characters. An essential feature is the use of full cardinal number names such as "one", "two", etc., in recording character counts.
Line 66:
In other words, we explicitly ignore details which were not specified in the task description as requirements of all autograms.
 
Implementation: <syntaxhighlight lang=J"j">NB. requires uk and us from rosettacode Number_names#J
normalize=: {{ tolower ' '(I.(tolower=toupper)y)}y }}
normalize=: tolower@#~ tolower~:toupper
Line 94:
}}</syntaxhighlight>
 
Task examples:<syntaxhighlight lang="j"> 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.}}
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 115:
=={{header|Julia}}==
Validating the total letter count when used.
<syntaxhighlight lang="ruby">""" Rosetta Code task rosettacode.org/mw/index.php?title=Autogram_checker """
 
using DataStructures
Line 214:
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">use v5.36;
use experimental <builtin for_list>;
use Sub::Util 'subname';
Line 415:
 
=={{header|Phix}}==
<!--<syntaxhighlight lang=Phix"phix">(phixonline)-->
<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 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>.
 
<syntaxhighlight lang=perl6"raku" line>my %nums = :0zero, :1one, :2two, :3three, :4four, :5five, :6six, :7seven, :8eight, :9nine, :10ten, :11eleven,
:12twelve, :13thirteen, :14fourteen, :15fifteen, :16sixteen, :17seventeen, :18eighteen, :19nineteen,
:20twenty, :30thirty, :40forty, :50fifty, :60sixty, :70seventy, :80eighty, :90ninety, :100hundred, :1single;
Line 738:
{{libheader|Wren-str}}
Frankly, not a bullet-proof solution but good enough to check the required sentences.
<syntaxhighlight lang="ecmascript">import "./str" for Str
 
var numbers = [
10,333

edits