Summarize and say sequence: Difference between revisions

Content added Content deleted
m (→‎{{header|q}}: no longer assumed)
m (→‎{{header|q}}: link to discussion article)
Line 3,179: Line 3,179:
rpt["Iterations"]string top
rpt["Iterations"]string top
rpt["Sequence"]"\n\n","\n"sv raze seq where its=top</lang>
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}}
{{out}}
<pre>
<pre>
Line 3,212: Line 3,209:
19182716152413228110
19182716152413228110
</pre>
</pre>
* [https://code.kx.com/q/ref/ Language Reference]
References:
* [https://code.kx.com/q/ref/ Q Reference Card]
* [https://code.kx.com/q/learn/pb/sum-say/ The Q Playbook: Summarize and Say – analysis]
* [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}}==
=={{header|Racket}}==