Sep-14-2023, 10:17 PM
In the following code data must be an non static attribute of the class Node:
class Node: total = 0 def __init__(self,parent,data): Node.total=Node.total+1 self.index=Node.total self.data = data if self.index!=1: self.parent = parent.index self.depth=parent.depth+1 else: self.parent=1 self.depth=0 list=[Node(0,[2,2,2,2,2,2])] i=0 while list[i].depth<2: for j in range(0,6): p_data=list[i].data num=p_data[j] if num!=0: p_data[j]=0 for k in range(1,num+1): p_data[(j+k)%6]=p_data[(j+k)%6]+1 list.append(Node(list[i],p_data)) i=i+1For every class instance in list all member have the same value for member data and also become static.