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