Yellowstone sequence: Difference between revisions

m
→‎{{header|REXX}}: added a REXX version that displays a vertical histograph (histogram) plot.
m (→‎{{header|REXX}}: added a REXX version that displays a vertical histograph (histogram) plot.)
Line 783:
 
=={{header|REXX}}==
===horizontal list of numbers===
<lang rexx>/*REXX program calculates any number of terms in the Yellowstone (permutation) sequence.*/
parse arg m . /*obtain optional argument from the CL.*/
Line 805 ⟶ 806:
<pre>
1 2 3 4 9 8 15 14 5 6 25 12 35 16 7 10 21 20 27 22 39 11 13 33 26 45 28 51 32 17
</pre>
 
===vertical histogram plot===
<lang rexx>/*REXX program calculates any number of terms in the Yellowstone (permutation) sequence.*/
parse arg m . /*obtain optional argument from the CL.*/
if m=='' | m=="," then m= 100 /*Not specified? Then use the default.*/
!.= 0 /*initialize an array of numbers(used).*/
# = 0 /*count of Yellowstone numbers in seq. */
$= /*list " " " " " */
do j=1 until #==m; prev= # - 1
if j<5 then do; #= #+1; @.#= j; !.#= j; !.j= 1; $= strip($ j); iterate; end
 
do k=1; if !.k then iterate /*Already used? Then skip this number.*/
if gcd(k, @.#)\==1 | gcd(k, @.prev)<2 then iterate /*not meet requirement?*/
#= #+1; @.#= k; !.k= 1; $= $ k /*bump ctr; assign; mark used; add list*/
leave /*find the next Yellowstone seq. number*/
end /*k*/
end /*j*/
 
call $histo $ '(vertical)' /*invoke a REXX vertical histogram plot*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
gcd: parse arg x,y; do until y==0; parse value x//y y with y x; end; return x</lang>
{{out|output|text=&nbsp; when using the default input:}}
 
The terminal screen size has a height of 55 characters (including values), the plot is shown at three quarter scale.
<pre style="font-size:75%">
│ ■
■ │ │
│ │ ■ │
│ │ │ │
│ │ │ │
│ │ ■ │ │
│ │ │ │ │
│ │ │ │ │
│ │ ■ │ │ │
■ │ │ │ │ │ │
│ │ │ ■ │ │ │ │
│ │ │ │ │ ■ │ │ │
│ │ │ ■ │ │ │ │ │ │
■ │ │ │ ■ │ │ │ │ │ │ │
■ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ ■ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ ■ │ │ │ │ │ │ │ │ │
│ ■ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
■ │ ■ │ │ │ │ │ │ │ │ │ │ │■│ │ │■│
■ │ │ │ │ │ │ │ │ │ │ │ │ │ │││ │ │││
■ │ │ │ ■ │ │ │ │ │ │ │ │ │ │■ │■│││ │ │││
│ │ │ │ │ │ │ │ │ │ │ │ │ │ ││ ■│││││ │■│││
│ │ │ │ ■ │ │ │ │ │ │ │ │ │ │■││ ││││││■│││││
│ │ │ │ ■ │ │ │ │ ■ │ │ │ │ │ │■││││ ││││││││││││
│ │ │ │ │ │ │ │ │ │ │ │ │■│■│ ││││││ ││││││││││││
│ │ │ ■ │ │ │ │ │ │■│ │ │ │││││ ■││││││ ││││││││││││
│ ■ │ │ │ │ │ │ │ │■│││ │ │■│││││ │││││││ ││││││││││││
│ │ │ ■ │ │ │ │ │ │■ │││││ │ │││││││ │││││││ ││││││││││││
│ │ │ │ │ ■ │ │ │ │ ││ ■│││││ │■│││││││ │││││││ ││││││││││││
│ ■ │ │ │ │ │ │ │ │ │■││ ││││││■│││││││││ │││││││ ││││││││││││
■ │ │ │ │ │ │ │ │■ │■│ ││││ ││││││││││││││││ │││││││ ││││││││││││
│ │ │ │ │ ■ │ │ │ ││ ■│││ ││││ ││││││││││││││││ │││││││ ││││││││││││
■ │ │ │ │ │ │ │ │■│ ││ ││││■││││ ││││││││││││││││ │││││││ ■││││││││││││
│ │ │ │ │ │ │ │ ■│││■││ │││││││││ ││││││││││││││││ │││││││■│││││││││││││
■ │ │ │ │ │■│ │■│ │││││││ │││││││││ ││││││││││││││││■│││││││││││││││││││││
■ │ ■ │ │ │ │■│││ │││ │││││││ │││││││││ ││││││││││││││││││││││││││││││││││││││
│ │ │ │ │■ │ │││││■│││ │││││││ │││││││││■■││││││││││││││││││││││││││││││││││││││
│ ■ │ │■│■││ │ │││││││││ │││││││ │││││││││││││││││││││││││││││││││││││││││││││││││
■ │ │■│ ││││││ │■│││││││││ │││││││■│││││││││││││││││││││││││││││││││││││││││││││││││
│ │ ■■│││ ││││││ │││││││││││■│││││││││││││││││││││││││││││││││││││││││││││││││││││││││
■ │ │■ │││││ ││││││■■│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
│■ │■││ │││││ ■│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
■■││ ││││ ■│││││■││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
────┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴
1234981156213171222231132425311825363934361494546524157485862359696751616171713717181844818191718191
54 5256 0107291336581278545456109839254709038125616729183498741036627407016102613228322844546
5 9 3 1 5 5 1 7 3 9 5 5 5 5 5
</pre>