Algorithm 切换待办事项时计算项目进度

Algorithm 切换待办事项时计算项目进度,algorithm,Algorithm,我正在制作一个todo应用程序,我想了一些方法来增加它的趣味性,所以我实现了一个项目进度特性。因此,在应用程序中,您可以创建项目每个项目都可以有todolist,每个todolist都可以有todos。 因此,当用户切换todo时,我会以这种方式重新计算项目的进度 const todoContirubutioToProjectPorgess=1/projectTodosTotalCount project.progress += todoContirubutioToProjectPorgess

我正在制作一个todo应用程序,我想了一些方法来增加它的趣味性,所以我实现了一个项目进度特性。因此,在应用程序中,您可以创建
项目
每个项目都可以有
todolist
,每个todolist都可以有
todos

因此,当用户切换todo时,我会以这种方式重新计算项目的进度

const todoContirubutioToProjectPorgess=1/projectTodosTotalCount
project.progress += todoContirubutioToProjectPorgess
如果项目中的ToLoListRoT具有相同数量的ToDOS,那么这很好,但是当它们不是真的时,这是没有意义的,因为,让我们考虑这些情况:
案例1

project : [
   todoList1[todo1,todo2],
   todoList2[todo3,todo4]
]
//todo1's contribution to project's progress is the same todo3's so it works here 

案例2

project : [
   todoList1[todo1,todo2],
   todoList2[todo3,todo4,todo5]
]
//todo1's contribution to project's progress is bigger than todo3 , since todo1 makes 50% of todoList1 and todo3 makes only 30% todoList2
我试过这个

const todoListContirubutioToProjectPorgess  =  todoListTodosCount/projectTodosTotalCount
const todoContirubutioToPorgess =  1/todoListContirubutioToProjectPorgess  
project.progress += todoContirubutioToPorgess

但是它并没有像我预期的那样起作用,你对此有什么看法?你会怎么做?让有
x
待办事项列表,任务的数量是
[t1,t2,t3,…tx]

每个待办事项列表的贡献=
100/x%

列表1中每个项目的贡献率=
(100/x)/t1%
=
100/(x*t1)%

清单2中每个项目的贡献率=
(100/x)/t2%
=
100/(x*t2)%

列表x中每个项目的贡献率=
(100/x)/tx%
=
100/(x*tx)%


对于每个任务,您只需要两个变量:列表总数和当前列表中的任务数。然后使用上述公式获得进度增量。

谢谢,这是有效的