Jump to content

English cardinal anagrams: Difference between revisions

(→‎{{header|Wren}}: 'Numbers to names' routines now built into 'Fmt' module.)
Line 25:
 
=={{header|J}}==
{{incorrect|J|Counts for English cardinal anagrams in 0 through 1000 and 0 through 10000 seem way off, though admittedly it is difficult to tell as nothing is labeled}}
<small>PL: I also got 680 at first, from using sum(filter(lengths,">",1)) instead of length(filter(lengths,">",1)), but also 9228, not 9662...<br></small>
Using the definitions at [[Number_names#J]] and
<syntaxhighlight lang=J>sampleukgram=: I.(e. ~. #~ 1<#/.~)/:~@uk&.> i. 1e6
 
sample=: I.(e. ~. #~ 1<#/.~)ukgram i. 1e6
sam1e3=: I.(e. ~. #~ 1<#/.~)ukgram i. 1e3
sam1e4=: I.(e. ~. #~ 1<#/.~)ukgram i. 1e4
 
largegroups=: {{
Line 44 ⟶ 46:
106 107 108 109 112 122 123 124 125 126
127 128 129 132 133 134 135 136 137 138
+/1000>:sample NB. count of values in OEIS::A169936 less than 1000
680
#~.ukgram (#~ 1000>:])sample NB. count of distinct anagrams for those values
317
largegroups (#~ 1000&>:) sample
679 697 769 796 967 976
Line 52 ⟶ 56:
Stretch:
 
If we consider all values in values in OEIS::A169936 which are less than 1e4
<syntaxhighlight lang=J> +/10000>:sample
 
<syntaxhighlight lang=J> +/10000>:sample NB. distinct members in subsequence
9662
largegroups#~.ukgram (#~ 10000&>:]) sample NB. distinct anagrams in subsequence
2968
largegroups (#~ 10000&>:) sample NB. anagram groups with most members in subsequence
1679 1697 1769 1796 1967 1976 6179 6197 6791 6971 7169 7196 7691 7961 9167 9176 9671 9761
2679 2697 2769 2796 2967 2976 6279 6297 6792 6972 7269 7296 7692 7962 9267 9276 9672 9762
Line 62 ⟶ 70:
6798 6879 6897 6978 7698 7869 7896 7968 8679 8697 8769 8796 8967 8976 9678 9768 9867 9876
</syntaxhighlight>
 
If we explicitly exclude anagrams whose only partner is greater than 1e4, we get a slightly smaller subsequence:
 
<syntaxhighlight lang=J> +/10000>:sample#sam1e4
9228
#~.ukgram sam1e4
2534</syntaxhighlight>
 
Note however that for values less than 1000, we every member of the OEIS::A169936 sequence had a partner which was also less than 1000:
 
<syntaxhighlight lang=J> #sam1e3
680
+/1000>:sample
680</sample>
 
=={{header|Julia}}==
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.