All Questions
Tagged with python-3.xalgorithm
15 questions with no upvoted or accepted answers
6votes
0answers
266views
Selection sort with reduced comparison count: Python iteration 2
Follow up to Selection sort with reduced comparison count - semi-final Iteration? My goal (and excuse not to tag reinventing…) is to have presentable code to argue the viability of reducing the number ...
5votes
0answers
831views
Selecting child contours in OpenCV
I'm really new to OpenCV. :) I have been working on this for almost an entire day. After hours of sleepless work I would like to know if I can further improve my code. I have written some code to ...
4votes
0answers
222views
Finding where column slices of elements in multi-dimensional array are equal
Skippable Intro: I have a dataset that corresponds to an observed time-series. The dataset is organized into a dictionary - which contains an array of years, an array of months, an array of days, an ...
4votes
0answers
2kviews
Sanitize and standardize street addresses using Google Maps lookups
Take in incomplete user input street addresses, clean it, segregate based on word count and run it into Google maps places api and output completed & standardised addresses based on Json object ...
3votes
0answers
2kviews
Optimizing recursive backtrack search algorithm in Skyscraper puzzle
I'm trying to solve a skyscraper puzzle for 6x6 boards using constraint programming and then backtracking. My solution works but is too slow, for certain cases, it takes up to 2 seconds and I was ...
3votes
0answers
295views
Calculating the total sum of inversion count for all subarrays
My approach was to visit all inversion count pair and count how many subarrays these pair contribute. Visiting every pair requires \$\mathcal{O}(n^2)\$ time, but I want an optimized version of this, ...
3votes
0answers
652views
Finding the submatrix with the maximum sum
Given an arbitrary \$N \times N\$ matrix, find the maximum sum submatrix. This particular approach uses the Kadane's algorithm. What could be improved both in terms of algorithm and code style? ...
3votes
0answers
2kviews
Breadth-first search: traditional and bidirectional in Python - follow-up
I have refactored the version of the previous (and initial) iteration according to the answer by alexwlchan. As a reminder, this snippet compares breadth-first search against its bidirectional variant....
2votes
0answers
135views
Snake game with constant time complexity algorithm
https://github.com/speedrun-program/constant_time_snake_game Memory efficient snake game with O(1) algorithm for snake movement and bug placement. Three grids are used: a grid representing the game ...
2votes
0answers
222views
Implement priority queue as min-heap in python
The standard library heapq in python doesn't support updating keys as a public method, which makes it hard to be used as a priority queue. Although the official ...
2votes
0answers
101views
Traverse materialized path hierarchy for children nodes
I have a sorted list of materialized hierarchy paths: ...
2votes
0answers
1kviews
Binary Expression Tree
I implemented a binary expression tree, I've used my previous shunting-yard parser to provide it the post-fix expression. I have a few specific questions outside of just comments about making it ...
2votes
0answers
2kviews
C++ implementation of Monte Carlo Tree Search with Python wrapper
Important Prebuilt Python Extensions built for Python 3.6 Includes Python f-strings (3.6+) Complementary GitHub link https://github.com/thejhonnyguy/CPyMCTS Notable: Previous attempt with stock ...
1vote
0answers
136views
Generating Unique Subsets using Bitmasking
Given an array arr[] of integers of size N that might contain duplicates, the task is to find all possible unique subsets. Link to the judge: LINK Note: Each subset should be sorted. Example 1: ...
1vote
0answers
378views
Directed graph and Dijkstra algorithm using heap
I have implemented directed graph and Dijkstra algorithm using heap in Python. I first implemented an abstract base class WeightedGraph, of which ...