00:33:30 simone cargnin: can you explain with some example the second part? please 00:33:59 simone cargnin: from node,side= free.pop() to the end 00:40:23 simone cargnin: yes 00:40:32 simone cargnin: yes yes 00:40:48 Stefano Colonnelli: cant we specify a random index inside pop? 00:43:06 Francesco Danese: sorry sometimes the function return me an attributeError, is it a problem of randint? 00:43:06 Stefano Colonnelli: yesyes i meant by using randint in range of the list 00:43:18 Stefano Colonnelli: set 00:43:33 Stefano Colonnelli: i wanted to do what we have done now lmao 00:44:24 Francesco Danese: Sometimes the function generates the tree correctly but sometimes, even with the same parameter it returns: AttributeError: 'NoneType' object has no attribute 'right'. 00:46:11 Francesco Danese: ok i restart spyder 00:46:19 Angelo Spognardi: from bintree import BinTree from random import randint def gen_random_tree(n, a, b, root = None, free = None): if n == 0: return root if root == None: root = BinTree(randint(a,b)) free = [(root, 0), (root, 1)] else: node, side = free.pop(randint(0,len(free)-1)) new_node = BinTree(randint(a,b)) free.extend([(new_node,0), (new_node,1)]) if side: node.right = new_node else: node.left = new_node return gen_random_tree(n-1, a,b,root,free) 01:06:25 simone cargnin: maybe before we do the tree and after we compute the value 01:17:22 Ginevra Cepparulo: I am sorry I have a question can the values of the nodes be 0? 01:19:37 Alessandro vecchi: On the right it’s n+1 01:21:26 Alessandro vecchi: nono 01:21:43 Alessandro vecchi: I wrote this 5 minutes ago 01:21:45 Alessandro vecchi: My bad 01:24:36 Alessandro vecchi: Return root 01:34:11 Ginevra Cepparulo: so we have to construct this position tree and then find the difference between the most positive and most negative values? 01:36:30 Alessandro vecchi: def tree_width(tree, num): min_of_sx = max_of_sx = min_of_dx = max_of_dx = 0 if tree.sx: min_of_sx, max_of_sx = tree_width(tree, num-1) if tree.dx: min_of_dx, max_of_dx = tree_width(tree, num+1) return max(max_of_sx, max_of_dx)-min(min_of_sx, min_of_dx) 01:36:41 Alessandro vecchi: Should work(?) 01:37:06 Francesco Danese: can we avoid to construct another tree? 01:37:34 Francesco Danese: for esample just ''read'' the tree and add in a set the positions and at the end get the max and min 01:43:13 Alessandro vecchi: Oh sorry I forgot tree.sx and tree.dx in the recursion step 01:45:15 simone cargnin: why not? 01:45:19 simone cargnin: idn't it 3 01:45:27 Alessandro vecchi: Yes it’s right 01:45:29 simone cargnin: *isn't 01:45:34 Alessandro vecchi: 1-(-2) 01:48:14 Alessandro vecchi: But can we do return max-min in the first def and have only one def? Or not? 01:49:41 Alessandro vecchi: Max(pos) minus min(pos) 01:49:58 Alessandro vecchi: Instead of position 01:50:17 Alessandro vecchi: Return directly max(pos)-min(pos) 01:51:14 Alessandro vecchi: Nono pos=positions 01:51:51 Alessandro vecchi: Return directly max(positions)-min(positions) in def evaluate_positions 01:53:00 Alessandro vecchi: Oh really? 01:53:46 Alessandro vecchi: Perhaps I got it 01:56:32 Alessandro vecchi: Ahhhh I got it 01:56:36 Alessandro vecchi: I’m dumb 02:04:38 Nicholas Tiveron: Thanks, bye! 02:04:40 simone cargnin: sorry prof 02:04:42 Giuseppina Iannotti: Thanks bye 02:04:43 simone cargnin: one thing 02:04:43 Alessandro vecchi: Thanks bye! 02:04:55 simone cargnin: sorry can i ask you a question about a thing in a programm i cannot do 02:05:18 simone cargnin: can i explain in italian?