Skip to main content

Questions tagged [python]

Programming questions are off-topic here. Do not ask questions about how to write code in Python. However, conceptual questions about computer science are more appropriate. See our help center for the scope of this site.

Filter by
Sorted by
Tagged with
0 votes
0 answers
43 views

Several programming languages support a calling convention wherein values are bound to parameters via a keyword, rather than position in a tuple of arguments. I'm curious whether there is any formal ...
Osr Workshops's user avatar
2 votes
0 answers
125 views

Let $S$ be a set of nodes belonging to a directed graph $G = (V,E)$. A vertex $v$ of $G$ is said to be reachable from $S$ if and only if $v \in S$, or if each predecessor of $v$ is reachable from $S$ ...
contrapunctus's user avatar
0 votes
2 answers
131 views

My code for it: from math import gcd y = int(input()) w = int(input()) g = gcd(y, w) print(f"{y// g}/{w// g}") Could there be any other way of solving this problem without using gcd ?
user141710's user avatar
-4 votes
1 answer
111 views

How to write a Python Program for the following condition: Let me explain how I tried to write the code. $a=$ int$($input$($'enter the first integer between $1$ and $9$'$))$ $b=$ int$($input$($'enter ...
user avatar
1 vote
1 answer
106 views

Python has methods like getattr() which can be used to branch arbitrarily at runtime. As a result, static code analysis tools can't be certain what functions a ...
Travis's user avatar
  • 121
1 vote
3 answers
382 views

I am confused about calculating the time complexity of the following function. ...
Skaeler's user avatar
  • 13
0 votes
1 answer
139 views

In this question I was looking for an algorithm to solve what seems to be a XOR-SAT problem. Let's consider this equation system : ...
nowox's user avatar
  • 295
1 vote
1 answer
93 views

I am looking for a python NLP library that can generate a proper product description based on product features provided to it. Till now, i have tried transformers library and this is the code: ...
FaisalShakeel's user avatar
1 vote
0 answers
216 views

I don't know if this post belongs in this site because I feel it might be a programming question, but also I feel it might be related to the way Color Spaces work, if it does't belong here I can ...
Nau's user avatar
  • 111
3 votes
2 answers
1k views

So, we are given a 100 long array, with 97 0s and 3 1s of which we do not know the locations. We must find them using only a compare function, which I managed to write (in Python): ...
user555076's user avatar
0 votes
1 answer
162 views

I run the Python code below. x and y differ in their 4th and 5th number, and x has larger ...
Rocky's user avatar
  • 11
2 votes
1 answer
144 views

I've been working on the following challenge on LeetCode: Problem: Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together....
Ariana's user avatar
  • 123
2 votes
2 answers
475 views

I was wondering if there is a reason behind clearing all the values in a list and reusing it, as opposed to deleting the list and creating a new one. Are there any practical advantages of using ...
Akshay Katiha's user avatar
1 vote
0 answers
77 views

Recently, I began delving into complexity analysis with dictionaries. More specifically, I have been looking at auxiliary space complexity. For the most part, this type of analysis has been ...
LateGameLank's user avatar
0 votes
2 answers
89 views

In the context of adding sparse polynomials, you have two alternative approaches to combine the terms from two separate polynomials. One option is to use the line of code ...
alefvanoon's user avatar
0 votes
3 answers
173 views

I am looking for a method in Python/MATLAB to calculate the corner points of polytope which is an intersection of a polytope with half spaces. I have a polytope P1 of the form -1 <= x0 <= 1 -1 &...
Möbius's user avatar
  • 21
0 votes
1 answer
76 views

I am working on an floorplan application where I save elements on an infinite grid in a sparse manner. Specifically, I have the following Python class representing a sparse grid (basically a ...
Mate de Vita's user avatar
-2 votes
4 answers
233 views

As far as I know, the halting problem means we can't create a program that checks whether another program is stuck or halt based on given input. This means, the program expects two inputs and one ...
Muhammad Ikhwan Perwira's user avatar
2 votes
1 answer
230 views

I am trying to find the first and second-order partial derivatives of a function of four variables $S$ using pythons symbolic math package sympy. The issue is that sympy does not automatically see ...
G-Shillcock's user avatar
0 votes
0 answers
180 views

I'm a young programmer that was interested by machine learning. I watched videos and read articles about the theory behind simple neural networks. However, I can't manage to set it up correctly. I've ...
NolanGio's user avatar
0 votes
3 answers
154 views

In the counting number of islands problem, I noticed that one of the solution from internet is as follows ...
SKPS's user avatar
  • 103
1 vote
2 answers
207 views

I was tasked with writing a function that finds the value of an element that is the first duplicate in an array to be encountered. For the array [2, 1, 3, 5, 3, 2] ...
Lucky's user avatar
  • 111
12 votes
5 answers
4k views

Consider the Kadane's algorithm for finding maximum subarray within an array: ...
Eugene Yarmash's user avatar
1 vote
1 answer
84 views

Let $G$ be an abelian group. We say that $G$ has property $V_n$ if for every $m > n$ and a list $L\subset G$ of $m$ elements s.t. $\sum_{g\in L}g=0$ there is a proper subset $\emptyset\neq L'\...
levav ferber tas's user avatar
1 vote
1 answer
221 views

I'm reading Algorithm Design and Application, by Michael T. Goodrich and Robert Tamassia, and sometimes the pseudo-code in this book doesn't make sense at all. At chapter one they show us 3 solutions ...
André Carvalho's user avatar

1
2 3 4 5