Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can code be built for a diagram with array elements looped?

enter image description here

In the image below, I came up with something like this but I know this produces an error. I am writing in python

    def return_this(arr,x,y):
        arr = [10, [30, [x,y], 40]]
        return arr[1][0]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

here is your solution, you need to create 4 array with values and for empty one put None at start.

Now once declare you need to reference the array to other array. and it is done
you can check them out but indexing the internal indexes where they point out

>>> 
>>> a =[None, None]
>>> b =[10, None]
>>> c = [None, 20]
>>> d = [30, None, 40]
>>> 
>>> a[0] = b
>>> a[1] =c
>>> b[1] = d
>>> c[0] =d
>>> d[1] = a
>>> 
>>> a
[[10, [30, [...], 40]], [[30, [...], 40], 20]]
>>> b
[10, [30, [[...], [[...], 20]], 40]]
>>> c
[[30, [[10, [...]], [...]], 40], 20]
>>> d
[30, [[10, [...]], [[...], 20]], 40]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading