example of a shitty code

Solutions on MaxInterview for example of a shitty code by the best coders in the world

showing results for - "example of a shitty code"
Nada
16 Jan 2020
1    game=[[1,1,1,1,1,1,1],
2         [1,'A',1,1,0,0,1],
3         [1,0,0,0,0,1,1],
4         [1,0,0,1,1,1,1],
5         [1,1,0,0,0,'B',1],
6         [1,1,1,1,1,1,1]]
7    rows=len(game)
8    cols=len(game[0])
9    graph={}
10    for i in range(1,rows-1):
11       for i in range(1,rows-1):
12          if(game[i][j]!=1):
13          adj=[]
14          for ele in [(i-1,j),(i+1,j),(i,j-1),(i,j+1)]:
15               if game[ele[0]][ele[1]] == 0 or game[ele[0]][ele[1]]=='B' :
16                       adj.append((ele[0],ele[1]))
17          graph[(i,j)]=adj
18    print(graph)
19
20    {(1, 1): [(2, 1)],
21    (1, 4): [(2, 4), (1, 5)],
22    (1, 5): [(1, 4)],
23    (2, 1): [(3, 1), (2, 2)],
24    (2, 2): [(3, 2), (2, 1), (2, 3)],
25    (2, 3): [(2, 2), (2, 4)],
26    (2, 4): [(1, 4), (2, 3)],
27    (3, 1): [(2, 1), (3, 2)],
28    (3, 2): [(2, 2), (4, 2), (3, 1)],
29    (4, 2): [(3, 2), (4, 3)],
30    (4, 3): [(4, 2), (4, 4)],
31    (4, 4): [(4, 3), (4, 5)],
32    (4, 5): [(4, 4)]}
33
similar questions
queries leading to this page
example of a shitty code