Jump to content

Python Question

Wictorian

I have a variable a

a = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48"""

I have it seperated as columns and rows.

 

I also need it diagonally. 

I am using this code:

while(true):
    for f in range(i-1):
        try:
            dList1[h].append(columnLists[f][20-i+f])
        except:
            pass
    if state == 1:
        i+=1
        if i == 20:
            state = 2
    elif state == 2:
        i -= 1
        if i == 0:
            state = 3
    elif state == 3:
        i += 1
        if i == 5:
            break
    h += 1

at first I am supposed to get 04, 69,35,71 (the bottom of first column) but I dont get 71 and this problem occurs on other lines too. Can you spot the problem?

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Wictorian said:

at first I am supposed to get 04, 69,35,71 (the bottom of first column) but I dont get 71 and this problem occurs on other lines too. Can you spot the problem?

Can you post the entire code? there are a lot of variables missing so I'm unsure of what it's supposed to be doing

Quote or Tag people so they know that you've replied.

Link to comment
Share on other sites

Link to post
Share on other sites

Well for a start nothing in this code refers to that `a` variable...

F@H
Desktop: i9-13900K, ASUS Z790-E, 64GB DDR5-6000 CL36, RTX3080, 2TB MP600 Pro XT, 2TB SX8200Pro, 2x16TB Ironwolf RAID0, Corsair HX1200, Antec Vortex 360 AIO, Thermaltake Versa H25 TG, Samsung 4K curved 49" TV, 23" secondary, Mountain Everest Max

Mobile SFF rig: i9-9900K, Noctua NH-L9i, Asrock Z390 Phantom ITX-AC, 32GB, GTX1070, 2x1TB SX8200Pro RAID0, 2x5TB 2.5" HDD RAID0, Athena 500W Flex (Noctua fan), Custom 4.7l 3D printed case

 

Asus Zenbook UM325UA, Ryzen 7 5700u, 16GB, 1TB, OLED

 

GPD Win 2

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, .Apex. said:

Can you post the entire code? there are a lot of variables missing so I'm unsure of what it's supposed to be doing

a = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48"""
rowLists = []
columnLists = []
dList1 = []
dList2 = []
true = True
i = 4
state = 1
rows = a.replace("\r", "").split("\n")
for row in rows:
    if(not len(row)):
        continue
    rowLists.append(row.split())
for c in range(19):
    columnLists.append([rowLists[0][c]])
for d in range(19):
    for e in range(18):
        e += 1
        columnLists[d].append(rowLists[e][d])
for g in range(32):
    dList1.append([])
h = 0
while(true):
    for f in range(i-1):
        try:
            dList1[h].append(columnLists[f][20-i+f])
        except:
            pass
    if state == 1:
        i+=1
        if i == 20:
            state = 2
    elif state == 2:
        i -= 1
        if i == 0:
            state = 3
    elif state == 3:
        i += 1
        if i == 5:
            break
    h += 1
    print(dList1)
    
        








It is also breaking it into rows and columns

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Kilrah said:

Well for a start nothing in this code refers to that `a` variable...

columnLists is made out of a

Link to comment
Share on other sites

Link to post
Share on other sites

Use a debugger and go trough it step by step.

 

There is an empty line at the beginning.


a = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
...

Can your code handle this correctly?

 

ಠ_ಠ

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, shadow_ray said:

Use a debugger and go trough it step by step.

 

There is an empty line at the beginning.


a = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
...

Can your code handle this correctly?

 

how can I break it down diagonally? its only 1 line

 

columns and rows are doing ok

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Wictorian said:

how can I break it down diagonally? its only 1 line

 

columns and rows are doing ok

That's not what I'm talking about.

image.png.b8afd7cd1d60dd0b76273dc96f68d2b9.png

The string starts with a line break.

 

ಠ_ಠ

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, shadow_ray said:

That's not what I'm talking about.

image.png.b8afd7cd1d60dd0b76273dc96f68d2b9.png

The string starts with a line break.

 

yeah it used to do that and some guy helped me with this code:

rows = a.replace("\r", "").split("\n")
for row in rows:
    if(not len(row)):
        continue
    rowLists.append(row.split())

 

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Wictorian said:

how can I break it down diagonally? its only 1 line

 

columns and rows are doing ok

[['04', '69', '35', '71'], ['88', '42', '36', '29', '83'], ['04', '36', '16', '41', '78', '51'], ['19', '52', '68', '73', '72', '31', '54'], ['86', '80', '08', '87', '38', '30', '90', '69'], ['16', '56', '81', '83', '57', '25', '23', '01', '16'], ['78', '39', '00', '68', '97', '62', '39', '88', '74', '92'], ['21', '17', '05', '48', '05', '35', '20', '11', '34', '31', '33'], ['24', '36', '53', '42', '35', '94', '99', '72', '24', '62', '49', '48'], ['67', '55', '23', '28', '96', '71', '47', '16', '03', '94', '99', '71', '61'], ['32', '26', '58', '09', '22', '35', '89', '69', '07', '46', '72', '69', '48', '43'], ['24', '98', '20', '05', '75', '75', '31', '07', '28', '97', '33', '18', '82', '86', '52'], ['22', '47', '81', '68', '66', '00', '31', '47', '05', '73', '57', '67', '08', '67', '81', '01'], ['52', '31', '32', '28', '02', '73', '76', '67', '55', '44', '92', '32', '46', '46', '59', '16', '89'], ['81', '70', '16', '60', '64', '62', '99', '44', '15', '58', '44', '13', '16', '55', '29', '85', '23', '19'], ['49', '49', '95', '71', '99', '23', '12', '26', '20', '94', '88', '37', '86', '26', '12', '32', '74', '57', '67'], ['08', '49', '31', '23', '51', '03', '67', '20', '97', '45', '03', '24', '44', '52', '26', '32', '40', '04', '05', '48'], ['49', '49', '95', '71', '99', '23', '12', '26', '20', '94', '88', '37', '86', '26', '12', '32', '74', '57', '67'], ['81', '70', '16', '60', '64', '62', '99', '44', '15', '58', '44', '13', '16', '55', '29', '85', '23', '19'], ['52', '31', '32', '28', '02', '73', '76', '67', '55', '44', '92', '32', '46', '46', '59', '16', '89'], ['22', '47', '81', '68', '66', '00', '31', '47', '05', '73', '57', '67', '08', '67', '81', '01'], ['24', '98', '20', '05', '75', '75', '31', '07', '28', '97', '33', '18', '82', '86', '52'], ['32', '26', '58', '09', '22', '35', '89', '69', '07', '46', '72', '69', '48', '43'], ['67', '55', '23', '28', '96', '71', '47', '16', '03', '94', '99', '71', '61'], ['24', '36', '53', '42', '35', '94', '99', '72', '24', '62', '49', '48'], ['21', '17', '05', '48', '05', '35', '20', '11', '34', '31', '33'], ['78', '39', '00', '68', '97', '62', '39', '88', '74', '92'], ['16', '56', '81', '83', '57', '25', '23', '01', '16'], ['86', '80', '08', '87', '38', '30', '90', '69'], ['19', '52', '68', '73', '72', '31', '54'], ['04', '36', '16', '41', '78', '51'], ['88', '42', '36', '29', '83']]

 

 

Is this the result you're expecting? the 04,69,35,71 is correct, but what about the rest of it?

Quote or Tag people so they know that you've replied.

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, Wictorian said:

yeah it used to do that and some guy helped me with this code:


rows = a.replace("\r", "").split("\n")
for row in rows:
    if(not len(row)):
        continue
    rowLists.append(row.split())

 

nvm then

ಠ_ಠ

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, .Apex. said:

Is this the result you're expecting? the 04,69,35,71 is correct, but what about the rest of it?

a = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48"""
rowLists = []
columnLists = []
dList1 = []
dList2 = []
true = True
i = 4
state = 1
rows = a.replace("\r", "").split("\n")
for row in rows:
    if(not len(row)):
        continue
    rowLists.append(row.split())


for c in range(20):
    columnLists.append([rowLists[0][c]])   

   
for d in range(20):
    for e in range(19):
        e += 1
        columnLists[d].append(rowLists[e][d])

       
for g in range(32):
    dList1.append([])
h = 0
while(true):
    for f in range(i):
        try:
            dList1[h].append(columnLists[f][20-i+f])
        except:
            pass
    if state == 1:
        i+=1
        if i == 20:
            state = 2
    elif state == 2:
        i -= 1
        if i == 0:
            state = 3
    elif state == 3:
        i += 1
        if i == 5:
            break
    h += 1
print(dList1)

Either way this is the final code where I ended up with that result, I've altered the ranges because you've used range(19) when it should be range(20) for c and d, the range starts at 0 so range(20) would be from 0 to 19 which is the correct number for the column and row lists.

 

I've also altered "for e in range(18)" to range(19) for the same reasons.

 

And the last bit that finally got it to work that way is I've removed 1 in "for f in range(i-1)".

Quote or Tag people so they know that you've replied.

Link to comment
Share on other sites

Link to post
Share on other sites

 I've used numpy to make it simple

a = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48"""

matrix = [row.split(" ") for row in a.split("\n")[1:]]

import numpy as np

for i in range(-19, 19+1):
    print(np.diagonal(matrix, offset=i))
    
    

 

ಠ_ಠ

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, .Apex. said:

a = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48"""
rowLists = []
columnLists = []
dList1 = []
dList2 = []
true = True
i = 4
state = 1
rows = a.replace("\r", "").split("\n")
for row in rows:
    if(not len(row)):
        continue
    rowLists.append(row.split())


for c in range(20):
    columnLists.append([rowLists[0][c]])   

   
for d in range(20):
    for e in range(19):
        e += 1
        columnLists[d].append(rowLists[e][d])

       
for g in range(32):
    dList1.append([])
h = 0
while(true):
    for f in range(i):
        try:
            dList1[h].append(columnLists[f][20-i+f])
        except:
            pass
    if state == 1:
        i+=1
        if i == 20:
            state = 2
    elif state == 2:
        i -= 1
        if i == 0:
            state = 3
    elif state == 3:
        i += 1
        if i == 5:
            break
    h += 1
print(dList1)

Either way this is the final code where I ended up with that result, I've altered the ranges because you've used range(19) when it should be range(20) for c and d, the range starts at 0 so range(20) would be from 0 to 19 which is the correct number for the column and row lists.

 

I've also altered "for e in range(18)" to range(19) for the same reasons.

 

And the last bit that finally got it to work that way is I've removed 1 in "for f in range(i-1)".

 I am not sure if it is, the order doesnt matter but I need all diagonal lines.

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, shadow_ray said:

 I've used numpy to make it simple


a = """
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48"""

matrix = [row.split(" ") for row in a.split("\n")[1:]]

import numpy as np

for i in range(-19, 19+1):
    print(np.diagonal(matrix, offset=i))
    
    

 

Is there a simple way to get the opposite also?

 

(not like this \ but like this /)

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, Wictorian said:

 I am not sure if it is, the order doesnt matter but I need all diagonal lines.

Well then it's working as intended but it's not getting all of them because you've specified i=4

Quote or Tag people so they know that you've replied.

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, Wictorian said:

Is there a simple way to get the opposite also?

 

(not like this \ but like this /)

For the opposite direction you need to do

 

import numpy as np
matrix = [row.split(" ") for row in a.split("\n")[1:]]
lrmatrix = np.fliplr(matrix)

for i in range(-19, 19+1):
	print(np.diagonal(lrmatrix, offset=i))

 

Quote or Tag people so they know that you've replied.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, .Apex. said:

Well then it's working as intended but it's not getting all of them because you've specified i=4

How should I change it?

Link to comment
Share on other sites

Link to post
Share on other sites

Moving diagonally is not hard.

The problem is that there are four diagonals:

  1. Down and to the right
    • Assuming that you want to move diagonally down and to the right, the algorithm is to continually increment both indices (row, column) until either one is out of range.
  2. Down and to the left
    • Assuming that you want to move diagonally down and to the left, the algorithm is to increment row while decrementing column, until either one is out of range.
  3. Up and to the right
    • Assuming that you want to move diagonally up and to the right, the algorithm is to decrement row while increment column, until either one is out of range.
  4. Up and to the left.
    • Assuming that you want to move diagonally up and to the left, the algorithm is to decrement both row and column, until either one is out of range.

 

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Wictorian said:

How should I change it?

If you set i = 1 it would start at the bottom left corner, though it seems like the algorithm would only reach half way caused by another fault in the code, it never reaches the opposite corner, I suggest you use the np.diagonal function instead

Quote or Tag people so they know that you've replied.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×