HI Manos,
I see the goalposts have migrated again. Some comments on this week's version of the question.
"What about if I want each lesson to have a STANDARD repetition? Not default (eg 5) but each of them to have its (eg 1st:5, 2nd:6) and not minimum. Exactly that number. Is there a solution?"
It depends on how many of the lesson you set these limits on, and what the limits are.
Evenly spread, each lesson will occur either seven or eight times in the sixty slots available.
If each every lesson is to have a STANDARD repetition, the sum of those STANDARD repetition numbers must be 60.
Finding 30 pairs to fit that requirement from the set of 56 possible permutations listed in SG's solution (and generated by his most recent script when the current parameters are set—8 lessons, (all) ordered pairs listed) will be close to impossible, I suspect.
As each repetition number is met, all unchosen pairs containing that lesson number would be blocked.
For example:, if the first five pairs containing 1 were picked 12, 13, 14, 15, 16 then the remaining pairs containing 1 (17, 18, 21, 31, 41, 51, 61, 71, 81) would be blocked, one pair containing a 2 is included in the pairs already picked, so there are five to add. 23, 24, 25, 26, 27, and several more to block: 28, 32, 42, 52, 62, 72, 82.
With only two numbers reaching their limit, there are 10 of the thirty slots filled, and the pool has been reduced by 26, leaving 30 pairs to fill the remaining 20 slots. Not necessarily "impossible," but still 'close to' impossible.
"I wonder if there is another way e.g. to counter in every step each lesson's counter and prohibit in next random pair to produce a lesson which had already reach its desirable counter value..."
The counters shown in SG's solution and in mine show the results after all calculations are completed. It might be possible to build the eight counters into eight columns, one for each lesson, and to write the formulas inserting the pairs to attend to the counts of each lesson in the current row and control the insertion of a random example from the reduced pool based on those counts, but I suspect the formula would be more complicated than this sentence.
Might be possible in a script, though, provided the issue noted regarding setting STANDARD limits turns out to be a non-issue.
You wrote: "(SGIII's) solution (and the thought to use all the available combinations) is the nearest one!"
Actually, it was my solution that used "all available combinations"; SG's chose from a list of all possible permutations.
There are 28 possible combinations of two items from a set of eight. Because each combination may be placed in either of two orders, there are 56 (twice as many) permutations.
Regards,
Barry