Anonymous user
Topswops: Difference between revisions
m
→{{header|REXX}}: optimized the SWOPS function.
(→{{header|REXX}}: elided the need to undo the hex transformation, optimized the functions (about 20% faster).) |
m (→{{header|REXX}}: optimized the SWOPS function.) |
||
Line 1,766:
<br>and is optimized somewhat to take advantage by eliminating one-swop "decks".
<lang rexx>/*REXX program generates N decks of numbered cards and finds the maximum "swops". */
parse arg things .; if things=='' then things=10
do n=1 for things; #=decks(n, n) /*create a (things) number of "decks". */
Line 1,795:
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
swops: parse arg z; do u=1; parse var z t .; if
if word(z, t)==1 then return u /*found unity at T. */
z=changestr(h, z, d2x(h) ) /* [↑] any H's in
z=reverse(subword(z, 1, t)) subword(z, t+1)
end /*u*/</lang>
|