Talk:Hofstadter Figure-Figure sequences: Difference between revisions

Content added Content deleted
(→‎timings for the REXX solutions: added a new section. -- ~~~~)
m (→‎timings for the REXX solutions: changed IF statement to use short circuit. -- ~~~~)
Line 35: Line 35:
I normally don't including timings for the REXX solutions that I post, but when I saw the 2<sup>nd</sup> REXX example's timings,
I normally don't including timings for the REXX solutions that I post, but when I saw the 2<sup>nd</sup> REXX example's timings,
<br>I decided to go back and include the timings here as the 2<sup>nd</sup> example's timings seemed a bit high.
<br>I decided to go back and include the timings here as the 2<sup>nd</sup> example's timings seemed a bit high.
<br>I didn't expect a magnitude difference.
<br><br>I didn't expect a difference of magnitude.
<lang rexx>/*REXX pgm to calculate & verify the Hofstadter Figure-Figure sequences.*/
<lang rexx>/*REXX pgm to calculate & verify the Hofstadter Figure-Figure sequences.*/
call time 'Reset'
call time 'Reset'
Line 81: Line 81:
ffs: procedure expose r. s. rr. ss.; parse arg n
ffs: procedure expose r. s. rr. ss.; parse arg n
do k=1 for n while s.n==0 /*search for not null R │ S num.*/
do k=1 for n while s.n==0 /*search for not null R │ S num.*/
if s.k\==0 & ffr(k)\==0 then iterate
if s.k\==0 then if ffr(k)\==0 then iterate /*short circuit*/
km=k-1; _=s.km+1 /*the next SS number, possibly.*/
km=k-1; _=s.km+1 /*the next SS number, possibly.*/
_=_+rr._ /*maybe adjust for the FRR num.*/
_=_+rr._ /*maybe adjust for the FRR num.*/
Line 106: Line 106:
took 1.58 seconds.
took 1.58 seconds.
</pre>
</pre>
The (above) example was run under Windows 7 on my HP box (3.2GHz) using Regina.
The (above) example was run under Windows 7 on a HP box (3.2GHz) using Regina.
<br><br>
<br><br>