4 ms·
I'm not sure the problem reflect anything, while updating a data structure like this is fairly standard, the lesson counter is reset globally, which is not a co
by _old_dude_ 6y ago
I'm not sure the problem reflect anything, while updating a data structure like this is fairly standard, the lesson counter is reset globally, which is not a common operation.
For me the problem is too artificial to be meaningful.
- nickjj 6y ago> For me the problem is too artificial to be meaningful. The problem came from implementing a real feature into a course platform. The data structure contains a list of sections and lessons to build a table of contents. The position stores the order they are being displayed in. In the course viewing page lessons are annotated with a "#N" where N is the position and it goes from 1 all the way until the last lesson's count. This way folks could be watching the course and be like "Hey, I'm on lesson #56 and have a question". But on the course description page the table of contents was displayed in such a way where the position / lesson count was reset for each section. Although in the real life implementation this code is wrapped into a function and the reset_lesson_position is being supplied by a boolean function argument which controls whether or not the lesson's position gets reset for every section. We added it as an attribute to the section directly for the sake of this example to keep the problem more scoped to the core idea of the problem.
- _old_dude_ 6y agoIt makes a lot of more sense. `resetLessonPosition` is not a member of the data structure but a parameter of the function that generates the positions and it has an effect on all sections.