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
1 vote
1 answer
78 views

I want to perform large-scale image similarities detection. For context, I have a large database containing almost 13,000,000 flats. Every time a new flat is added to the database, I need to check ...
Guillaume M'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
1 answer
94 views

I'm working on implementing a mathematical approach to bit flipping in IEEE 754 FP16 floating-point numbers without using direct bit manipulation. The goal is to flip a specific bit (particularly in ...
Zak's user avatar
  • 1
0 votes
2 answers
134 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
1 vote
2 answers
196 views

How can I find a non-exhaustive algorithm for the following problem? In the $N$-base number system, there are exactly $ N^{(N+1)} $ numbers with $N+1$ digits. I would like to select $N^2$ numbers such ...
László Szilágyi'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
0 votes
1 answer
83 views

I have the following Python (3.12) code for finding Fibonacci numbers recursively, and keeping track of how many times the function is called. ...
paw88789's user avatar
  • 103
1 vote
1 answer
107 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
1 answer
92 views

Ordinarily, edge list representations of graphs take $O(V+E)$ space, where $V$ is the number of vertices and $E$ is the number of edges. For example, consider a graph with 5 nodes and a single edge ...
Ellen Spertus's user avatar
1 vote
3 answers
402 views

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

I had a difficult assignment in my Data Structures and Algorithms class. We need to implement a program that computes a function f(n) based on the following known values of n and f(n): n : 9689 ...
Shiyao Ju's user avatar
0 votes
1 answer
154 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
0 votes
1 answer
128 views

I have an interesting real world problem. My brother is currently in school. The teachers perform the following procedure when giving him his grades. They take his list of grades ...
Pranav Jain's user avatar
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
1 answer
130 views

The question mathematically has been answered here: https://math.stackexchange.com/questions/4886084/guaranteed-graph-labyrinth-solving-sequence/4887473#4887473 To summarize, in an unknown strongly ...
user555076'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
0 votes
1 answer
236 views

I'm creating a plagiarism detection algorithm in Python, which scores how much of document A has been plagiarised in document B, and returns all the copied sections in B that were plagiarised from A. ...
dben's user avatar
  • 11
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
78 views

I am trying to learn Scikit_Learn and build an ML model. I am learning from "Hands-On Machine Learning with SciKit-Learn, Keras & TensorFlow". In Chapter 2, there is a review of an ...
EngineerP's user avatar
0 votes
1 answer
163 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
3 votes
1 answer
152 views

What is the algorithm behind this routine and is there documentation available for it?
oogabooga's user avatar
2 votes
1 answer
157 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
0 votes
0 answers
31 views

I have a data set showing different clusters of data points and was attempting to find a way to get the peak of at every cluster. Comparing the moving average between a set of points does not work as ...
Nader's user avatar
  • 101
2 votes
2 answers
493 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
0 votes
0 answers
59 views

There is this paper in which HIV is modelled using cellular automaton. I am trying to replicate this work but I am not getting the same results as the authors. In this paper the authors describe the ...
Max's user avatar
  • 1
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
1 vote
1 answer
122 views

Let's say I have a set of two columns - Name, Surname. I have a list of possible values for Name -> Jacob, John Surname -> Mayerson, Kindle. I want to generate a set of unique combinations for ...
lapots's user avatar
  • 135
0 votes
2 answers
90 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
1 answer
894 views

What is the reason for this behavior? Usually, in other programming languages, it is either 4/8 bytes, if I am correct.
kjkjkjkjkj's user avatar
0 votes
3 answers
174 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
1 vote
2 answers
249 views

This is an example algorithm of a recursive insertion sort I'm trying to understand. I've have tried understanding this with the help of print statements (which I've commented). ...
river_bell's user avatar
0 votes
1 answer
77 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
0 votes
0 answers
125 views

Problem Statement Martha is interviewing at Subway. One of the rounds of the interview requires her to cut a bread of size $\ell \times b$ into smaller identical pieces such that each piece is a ...
Math-Learner's user avatar
-2 votes
4 answers
237 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
-1 votes
1 answer
857 views

I'm working on an algorithm which is permitted to use a training set of approximately 250,000 dictionary words. I have built and providing here with a basic, working algorithm. This algorithm will ...
driver's user avatar
  • 99
2 votes
1 answer
245 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
-1 votes
1 answer
147 views

I have an object that is moving towards target points and I want to determine when it will reach or pass through them. I receive points in real time, which represent the current position of the object....
theateist's user avatar
0 votes
0 answers
182 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
2 answers
248 views

r1 and r2 both are assigned 0.05 initially. If r1 is incremented by 0.01 in this way "r1 = r1 +0.01" we have 0.060000000000000005 as answer not 0.06.
Pulakesh Bag's user avatar
0 votes
3 answers
156 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
0 votes
2 answers
92 views

Suppose, I have a list of lists where multiple lists can have same elements. In my final output, I just want one list with the same element. An example is the following: Input: A=[[1,2,0], [0,1,2], [2,...
Becker Mammat's user avatar
1 vote
2 answers
212 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
0 votes
1 answer
409 views

From the NumPy documentation: "NumPy arrays have a fixed size at creation, unlike Python lists (which can grow dynamically). Changing the size of an ndarray will create a new array and delete ...
NaiveBae's user avatar
  • 101
12 votes
5 answers
4k views

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

I am working on a Sparse Autoencoder but Andrew NG's notes are hard to understand. My question is about the following equation: Loss Function. In sparse autoencoder, the goal is to inactive some ...
p200401Samuel's user avatar
1 vote
1 answer
87 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
85 views

I have a matrix with three possible elements: A, B and C. The size of the matrix could be a maximum of 15x16. $$ \begin{bmatrix} A & A & C & A\\ A & C & B & C\\ A & C & ...
Superluminal's user avatar
1 vote
1 answer
226 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
0 votes
1 answer
240 views

Suppose I have the mesh of an geometrical object (Interval in 1d, Region in 2d, Volume in 3d). How can I find out whether a point lies on its boundary or not? I am looking for algorithms with ...
FreeMind's user avatar
  • 111

1
2 3 4 5