Given a 2D Array (Python List), I need to find a new 1D such that it contains elements unique in each column. For example: should give me for example, [1,-1,0,3,4]. My trials so far: results is a 2D array of size 3 rows and n columns. last is the array which stores the end result, better said the unique values
Tag: algorithm
Extend Euclid Algorithm with matrix inverse mod N
I am implementing an extended Eucilid algorithm with matrix mod N. This is my code implementation: Now, I need to calculate the matrix inverse mod 36 with the following matrix: (This is the video link:) matrix inverse mod N However, my code can only get x = -11, y = -4, exactly it is a solution of equation 13x =
How to read file in line and back to specific line to read it again
I am trying to find a specific string in a file(let’s say this is condition 1.1) and if that string was found, I need to find another string right after condition 1.1 string (let’s say this is condition 1.2). if condition 1.2 exist, I need to get back to condition 1.1 plus one line. and readline again from there in
How to find nearest point in segment in a 3d space
I am solving an algorithmic problem which sounds like this: Given a three-dimensional space and segments in it. Find the point with minimal distance to all of the segments. Example input: in the first line N – the number of segments, in the N next lines given the begin and the end of each segment: x1 y1 z1 x2 y2
what is the Time Complexity of a nested loop in a recursive function?
I have a recursive function with a nested loop.I’m looking for what is the time complexity? Here is the function Answer Suppose n is the length of input_str. The algorithm can iterate n times recursively in the worst case, i.e., in each recursive call letter will be increased by 1 and it can be continued up to n. In each
Reconstruct input string given ngrams of that string
Given a string, e.g. i am a string. I can generate the n-grams of this string like so, using the nltk package, where n is variable as per a specified range. Gives the output: Is there a way to ‘reconstruct’ the original string using combinations of the generated ngrams? Or, in the words of the below commenter, is there a
Finding locations of words as lists of coordinates in a grid of letters
Given a grid of letters and a list of words, find the location of each word as a list of coordinates. Resulting list can be in any order, but coordinates for individual words must be given in order. Letters cannot be reused across words, and letters. Each given word is guaranteed to be in the grid. Consecutive letters of words
Python finding numbers from a list that satisfy a specific condition [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about programming within the scope defined in the help center. Closed 2 years ago. Locked. There are disputes about this question’s content being resolved at this time. It is not currently accepting new answers or interactions. Good evening,
Binary Insertion Sort vs. Quicksort
I was looking at different sorting algorithms and their performance (link) and then I tried to implement some sorting algorithms myself. I wanted to improve them as well and so, as I was coding the insertion sort, I thought why not to use binary search, as the first part of array is already sorted, and in order to get rid
Algorithm for integer solutions of a circle?
I am trying to search for integer solutions to the equation: If I search this in wolfram alpha, they are all found almost immediately even for very large n. When I implemented a brute force approach it was very slow: So I assume there is a much faster way to get all of the integer solutions to the equation above.