10-06-2018, 12:48 PM
(10-06-2018 11:42 AM)Gerson W. Barbosa Wrote: [ -> ]This saves 47 bytes overall.
We can also use Werner's remark:
(10-01-2018 01:42 PM)Werner Wrote: [ -> ]The period for 23x28 and 28x33 days is also halved to 322 and 462, respectively.
Code:
\<< RCLF RAD
{ 190 305 454 569 949 }
{ 91 371 553 }
{ 63 259 385 }
5 ROLL DUP DATE DUP ROT ROT DDAYS
{ 322 462 759 } MOD
{ } 1 3
FOR i SWAP DUP i GET
6 ROLL SWAP - DUP 0 > *
WHILE DUP HEAD NOT
REPEAT TAIL
END 1 GET ROT +
NEXT SWAP DROP SORT HEAD DATE+ DUP ROT ROT DDAYS \PI *
{ 11.5 14 16.5 } / SIN 100 * 0 RND ROT STOF
\>>
Meanwhile I came up with something between your and 3298's solution:
Code:
«
DATE DDAYS
{
{ 63 259 385 }
{ 190 305 454 569 949 }
{ 91 371 553 }
}
OVER
{ 322 759 462 } MOD
2
« -
WHILE DUP HEAD DUP 0 ≤
REPEAT DROP TAIL
END SWAP DROP
» DOLIST
SORT HEAD DATE OVER DATE+ ROT ROT +
360 * { 23 28 33 } / SIN 100 * 0 RND
»
But I consider 3298's idea to calculate the difference, then the remainder, flatten the lists and only then sort the result more elegant. Only drawback is the use of:
Code:
1. +
Kind regards
Thomas