Skip to main content

Posts

Strange multidimensional list element changing

I'm trying to make a solution for the n queens problem and I want to make a code writing a number of possible solutions for a n X n board and n queens. Here is my code: n = int(input()) piony = [[False for i in range(n)] for j in range(n)] skosy_lp = [[False for i in range(n)] for j in range(n)] skosy_pl = [[False for i in range(n)] for j in range(n)] figury = [-1] * n counter = 0 layer = 0 #list creating etc. piony list is containing vertical lines occupied by queens, skosy_lp #is containing lines oblique from left to right, skosy_pl - from right to left. #this is a backtracking algorithm #figury list is containing positions of queens. -1 means that the queen isn't placed while True: if layer == -1: break piony[layer] = piony[layer-1] skosy_pl[layer] = skosy_pl[layer-1] skosy_pl[layer].append(False) skosy_pl[layer].pop(0) skosy_lp[layer] = skosy_lp[layer-1] skosy_lp[layer].insert(0, False) skosy_lp[layer].pop(n) figury[layer]+=1

The issue to install conda on Google Colab

I have worked on the Colab for a long time. For some of my packages, I need to use Conda on Colab. I install it as usual by !pip install conda and it worked fine, but nowadays when I run this code I am having the following issue: Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/ ERROR: Could not find a version that satisfies the requirement conda (from versions: 3.0.6, 3.5.0, 3.7.0, 3.17.0, 4.0.0, 4.0.1, 4.0.2, 4.0.3, 4.0.4, 4.0.5, 4.0.7, 4.0.8, 4.0.9, 4.1.2, 4.1.6, 4.2.6, 4.2.7, 4.3.13, 4.3.16) ERROR: No matching distribution found for conda I am not sure where it comes from and I am wondering if, how can I fix that? (The version of Python in Colab is 3.10, Location: /usr/local/lib/python3.10/site-packages ) source https://stackoverflow.com/questions/76292131/the-issue-to-install-conda-on-google-colab

Check whether pattern is in csv field and output into a different file (whole row containing said pattern)

I want to search through a csv file, a particular column (code) for specific pattern(s). For example I would like to use python to extract rows 1 and 2 given they have the pattern '[0-9][0-9][A-Z]' in the column code but the last row does not adhere to the above so I would like to negate it and output it into a different csv; and output the criteria that is satisfied onto a new csv. Other patterns need to be included as well and may be present within the data so this is why I wanted to add it to a list variable and check the pattern that way. For instance a code critera could be '[0-9][0-9][A-Z] [0-9][0-9][A-Z]'. Wonder if it would be best to go with perhaps regex however with a list I feel if there are additional patterns to include or required this can then be added to said list? source https://stackoverflow.com/questions/76291647/check-whether-pattern-is-in-csv-field-and-output-into-a-different-file-whole-ro

why pytorch model gives out of range classes after converting into tflite

I trained yolov8 and then convert into tflite. After converting the tflite model gives me out of range classes. Like I am using only 4 classes but tflite model gives my classes like 21,11,9 etc. Can some one tell me why my model behaves like that after convert into tflite. I converted pretrained model yolov8s.pt into tflite and then test the model. Pretrained Model Also return out of range classes and Also gives wrongs scores. Like 2.32,15.23 etc. Why this is happened even on pretrained model. output source https://stackoverflow.com/questions/76275401/why-pytorch-model-gives-out-of-range-classes-after-converting-into-tflite

Why NextJS can't connect to Microsoft Azure Cloud Function?

When I try to make fetch to Microsoft Azure Cloud Function , I get code 500. If I open my cloud function url in the browser it gives me my response and works fine, and the authLevel is anonymous so everyone can make a request to this func. TypeError: fetch failed Error: connect ECONNREFUSED ::1:7071 API route export async function GET(request: Request) { try { // Connect to mcrft azure func endpoint const response = await fetch( `${process.env.VERCEL_URL || "http://localhost:7071" }/api/getChatGPTSuggestion`, { cache: "no-store", } ); const textData = await response.text(); return new Response(JSON.stringify(textData.trim()), { status: 200, }); } catch (error) { console.log("error inside get route", error) if (error instanceof Error) { return new Response(error.message, { status: 500 });

Is there a way to read a CSV or XLSX file in react native?

I'm trying to read a csv or xlsx file in my react native app, to use the data. It's not in my interest to use a server, the file is located within the app and is really small. So I'm spending too much time trying to make things work. I tried so many ways. First using the RNFS, fetch, blob, this things. But the error persists with the RNFS. I tried doing just fetch, but the erros happens with the network, even though the directory is local. I'm new at this thing and really don't know what to do. All the tools I'm using are the newest version, React, Expo, Node and libraries(I'm not so sure about this). Using NPM to install. Thank you for your time. Via Active questions tagged javascript - Stack Overflow https://ift.tt/BUMQ9DR

Web Scraping with Mechanical Soup

I'm trying to do a webscraping, but I'm not sure how I should proceed. My code is this: import mechanicalsoup browser = mechanicalsoup.StatefulBrowser() url = "https://www.sas.dk/book/flights/?search=OW_CPH-NYC- 20230703_a1c0i0y0&view=upsell&bookingFlow=points&sortBy=rec&filterBy=all" browser.open(url) #Get HTML print(browser.get_current_page()) the outcome is this: <!DOCTYPE html> <html data-cluster="new" data-country="dk" data-lang="da" data-market="dk-da" lang="da-DK"> <head> <title>Flight Selection | SAS</title> <base href="/"/> <meta charset="utf-8"/> <meta content="yes" name="apple-mobile-web-app-capable"/> <meta content="minimum-scale=1.0, width=device-width" name="viewport"/> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/> <link href=&