12
I managed a list of entries from an encyclopedia and I want to find the best way to separate the entries so that I choose a number of days and I have a schedule of which entries to read per day.
(The list is here: https://pastebin.com/4qNLqCJj)
The first item is the volume, the second entry, the third character number and the fourth is an id (generated from the date the entry was recorded on my pc).
I would like to make a script that generates a schedule, I would enter the number of days and it would divide the total number of characters of the encyclopedia and separate the entries from the number of characters of the average.
Example: I’ll enter the number of days, 120. The script will generate a script so that I can read all the characters of the three volumes of the encyclopedia in 120 days. For example:
The program should have 120 days, and each day will have an X number of entries having their number of characters summed equaling a number as close as possible to the average of characters per day.
Entries can be read in any order and in any volume, what matters is that they are distributed so that an almost equal amount of jails is read each day.
I asked an earlier question related to this and a user suggested the prediction error algorithm, but I’m not able to adapt it to this script.
Behold: What is the algorithm for distributing paragraphs?
How could I do that?
If I understand correctly, what you want to do involves these steps: 1) Calculate the average of characters per day needed for the entire encyclopedia to be read in 120 days; 2) Group entries per day, so that each day has entries that make up approximately the same number of characters as the average. If this understanding is correct, you probably know how to do (1) but are having trouble doing it (2).
– Luiz Vieira
A "simple" solution is to sort the entries from the smallest to the largest (that is, fewer characters for more characters) and allocate them on days until they exceed the calculated average in (1). Of course there may be entries that alone already exceed the average or that cannot be combined with any other without surpassing it, so in that case you have to use some other heuristic to make the best division. Better division algorithms are more complex and relate to the famous Backpack problem. Maybe this reading will help you.
– Luiz Vieira