Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help whit array
#1
Folks,

I came across a problem involving arrays that I am having trouble finding solution, could it help me? Or give me some tips?

Basically, I have an array below that repeats the same pattern of diagonals with increasing rows and columns. You need to create a program that gets the user the number of rows and columns and automatically creates an array with this pattern.

-4 1 0 0 0 1 0 0
1 -4 1 0 0 0 1 0
0 1 -4 1 0 0 0 1
0 0 1 -4 1 0 0 0
0 0 0 1 -4 0 0 0
1 0 0 0 0 -4 1 0
0 1 0 0 0 1 -4 1
0 0 1 0 0 0 1 -4



I enter values ​​on the main diagonal with an np.fill_diagonal function, but I can't include the values ​​in the other diagonals.

Thanks !!
Reply
#2
looks like a homework assignment. What have you tried so far?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  help whit pip lateublegende 3 2,581 Jan-08-2019, 05:23 PM
Last Post: lateublegende
  A help whit vars and strings dhoyosg 10 5,351 May-05-2018, 08:52 AM
Last Post: dhoyosg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020