u/Indra_Kamikaze

Faced an issue while making a matrix using [0]*n

def get_matrix(n):
    rows, columns = n,n
    matrix = [[0]*n]*n
    for i in range(n):
        matrix[i][i] = 1
    return matrix

This was my code. I know that we can make a [0] list with n zeros by doing [0]*n.

I thought if I further multiply that, I would get a [0] n square matrix. Running the code always returned a matrix with all elements 1. I put the code to the visualizer and found that a single list of n zeros is created and every row of the matrix points to that same list which is why when I edit, it edits that list and every position becomes 1.

Is there any way to create the entire matrix in a single iteration without going through O(n2) complexity similar to what I was trying to attempt? I already know the double for loop approach

reddit.com
u/Indra_Kamikaze — 15 days ago
▲ 0 r/i3wm

I recently installed arch and tried no desktop environment, just i3wm. Installed firefox and tried to download a pdf but it's not working.

I asked gemini and ran the following suggested fixes but it still didn't work-

Solution 1: Install the Missing File Picker Portal (Most Likely Fix) Firefox uses the XDG Desktop Portal system to launch the "Save As" dialog. Without a DE (like GNOME or KDE), you likely lack the necessary backend.

`sudo pacman -S xdg-desktop-portal xdg-desktop-portal-gtk

systemctl --user restart xdg-desktop-portal`

It still didn't work.

I tried printing the pdf instead but came across this in the destination part - "save as pdf"

I am assuming firefox doesn't know where to save the pdf (and there's no way of selecting a destination currently) which is why this problem is arising but I am not very sure what to do about it.

reddit.com
u/Indra_Kamikaze — 21 days ago

I recently installed arch and tried no desktop environment, just i3wm. Installed firefox and tried to download a pdf but it's not working.

I asked gemini and ran the following suggested fixes but it still didn't work-

>Solution 1: Install the Missing File Picker Portal (Most Likely Fix)
Firefox uses the XDG Desktop Portal system to launch the "Save As" dialog. Without a DE (like GNOME or KDE), you likely lack the necessary backend.

>sudo pacman -S xdg-desktop-portal xdg-desktop-portal-gtk

>systemctl --user restart xdg-desktop-portal

It still didn't work.

I tried printing the pdf instead but came across this in the destination part - "save as pdf"

I am assuming firefox doesn't know where to save the pdf (and there's no way of selecting a destination currently) which is why this problem is arising but I am not very sure what to do about it.

reddit.com
u/Indra_Kamikaze — 22 days ago

I am pretty new here and have been running this for everyday since I installed it in order to avoid breaking the system when upgrading all at once​

reddit.com
u/Indra_Kamikaze — 22 days ago