Summarize and say sequence: Difference between revisions

m
→‎{{header|q}}: link to discussion article
m (→‎{{header|q}}: no longer assumed)
m (→‎{{header|q}}: link to discussion article)
Line 3,179:
rpt["Iterations"]string top
rpt["Sequence"]"\n\n","\n"sv raze seq where its=top</lang>
The iteration is a bit brutal. Assumes all sequences converge within 30 iterations then uses <code>count distinct</code> to measure the convergence length. Probably more efficient than testing each iteration for convergence.
 
Sorting each seed into descending order and taking the unique items from the result (<code>distinct desc each</code>) reduces the number of seeds to use from 1,000,000 to 8,002.
{{out}}
<pre>
Line 3,212 ⟶ 3,209:
19182716152413228110
</pre>
* [https://code.kx.com/q/ref/maps/#each referenceLanguage for EachReference]
References:
* [https://code.kx.com/q/reflearn/pb/sum-say/ The Q ReferencePlaybook: Summarize and Say – Cardanalysis]
* [https://code.kx.com/q/ref/distinct/ reference for] <code>distinct</code>
* [https://code.kx.com/q/ref/maps/#each reference for Each]
* [https://code.kx.com/q/ref/accumulators/#do reference for Do]
* [https://code.kx.com/q/wp/iterators/ White paper on iterators]
 
=={{header|Racket}}==
39

edits