PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 9, 2022

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

 July 09, 2022     arrays, python, reference     No comments   

Issue

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]

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]

note: you need to return a[0] in your function



Answered By - sahasrara62
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing