All Questions
18 questions
1
vote
0
answers
29
views
Optimizing search algorithm for guessing list of strings via function returning bool if substring is in list [duplicate]
I trying to figure out the most effective way to accomplish this task:
A function, check(), contains a list of strings. Calling the function with a string as ...
2
votes
3
answers
404
views
Most effective search algorithm for guessing list of strings via function returning bool if substring is in list using Python
I trying to figure out the most effective way to accomplish this task:
A function, check(), contains a list of strings. Calling the function with a string as ...
1
vote
1
answer
54
views
Python Prime Search Slower Optimization
I have these 2 version of code. Both are looking for all primes under a certain ceiling value.
The first is testing against the set of all odd numbers.
The second in testing against the set of all 6k-...
4
votes
1
answer
89
views
Find optimum teams given calendar availabilities
I'm designing an algorithm that creates optimum teams based on everyone's availabilities (maximizes the amount of shared availability). To this end, I've made a function that takes in a dictionary of ...
3
votes
1
answer
75
views
Brute-force electronic component selection space search
Yesterday I hacked up a simple component selection program. An example is shown at the bottom for the application, though this can be used generally for a lot of different simple circuits I come ...
2
votes
1
answer
70
views
Is this breadth-first search correct?
I wrote a program that is supposed to be a breadth-first search algorithm, but I'm very new to search algorithm so I don't know if my method is very effective or if there is a simpler way to do this. ...
5
votes
0
answers
346
views
Rabin-Karp algorithm implementation
This code uses the Rabin-Karp algorithm to compare two text files. It takes a few minutes when both files contain around 1000 words. How can it be improved?
...
6
votes
2
answers
2k
views
Find the second largest number in an array with at most n + log2 n - 2 comparisons
This exercise is from Roughgarden's (excellent) course on algorithms on Coursera:
You are given as input an unsorted array of n distinct numbers, where
n is a power of 2. Give an algorithm that ...
2
votes
0
answers
2k
views
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 ...
3
votes
1
answer
576
views
Knuth–Morris–Pratt string search algorithm
I finally think I've implemented the Knuth–Morris–Pratt string search algorithm correctly, now time for that lovely criticism that causes me to learn! The code doesn't look all that pretty however it ...
7
votes
1
answer
4k
views
Approximate string search in Python
I have a long text (about 6,000,000 chars) and a short text (about 6,000 chars). The long text contains the short text, but not exactly - a small number of words are missing, abbreviated or just ...
3
votes
1
answer
2k
views
Parsing a Conditional statement with Python
Recently I built a Usenet newsreader in Python and for that I built a keyword search which supports AND and OR functionalities (e.g., python AND django should bring up articles containing both. I ...
8
votes
1
answer
15k
views
A* Search on 'Map of Romania' (Russel and Norvig ch3) in Python 3
I've implemented A* search using Python 3 in order to find the shortest path from 'Arad' to 'Bucharest'. The graph is the map of Romania as found in chapter 3 of the book: "Artificial Intelligence: A ...
5
votes
1
answer
8k
views
Python 3 - Get n greatest elements in dictionary
Given an dictionary with lists as values this piece of code is dedicated to find the n keys with the longest lists as values. It works, but there has to be a more elegant solution.
...
10
votes
2
answers
513
views
Naive implementation of KMP algorithm
After reading this answer to the question "High execution time to count overlapping substrings", I decided to implement the suggested Knuth-Morris-Pratt (KMP) algorithm. I used the pseudo-code listed ...