All Questions
163 questions
5
votes
4
answers
948
views
Decrease Computation Time for Python Tic-Tac-Toe Minimax Algorithm
Background
I am currently participating in a tic-tac-toe coding challenge. During their move, each participant is given the board state and their team, X or O. The blank board is:
...
2
votes
1
answer
184
views
LeetCode 839: Similar String Groups III
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you!
Problem
Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that ...
2
votes
2
answers
178
views
Python - Hexadecimal to Decimal conversions
I have written a python 2 program for a school project to convert from hexadecimal to decimal without using built-in functions and vice versa in python. I would like to know how I can make my code ...
1
vote
3
answers
62
views
`set_includes` (string subsequence-containment) in Python 2
I've implemented C++'s std::includes algorithm in Python, so that I can use it to efficiently implement a Scrabble "can I make this word" function:
...
2
votes
2
answers
2k
views
Heap Sort Implementation in Python
Objective: Create a heap sort that returns a unsorted list to sorted from greatest to least.
Does this implementation look correct? Do you have any tips for optimizing this?
...
8
votes
3
answers
188
views
Python methods to reduce running times KTNS algorithm
I have been trying to develop an algorithm called keep the tool needed soonest (for more information about the KTNS explanation (page 3)) but during the simulations, I have realized that it takes too ...
4
votes
1
answer
180
views
2D discrete motion planner
I am writing a 2D discrete motion planner for a task with specific instructions. The instructions for the search algorithm are contained entirely in the docstring for the ...
4
votes
2
answers
1k
views
Finding palindromic strings of even length
Given a string of digits. Find the length of longest substring of even length i.e. 0,2,... which is a palindrome or which can be rearranged to form a palindrome (see example below).
Here is my code: ...
1
vote
2
answers
5k
views
Reversing the bits of a 32-bit integer
Here is my code:
...
7
votes
4
answers
1k
views
Solving jumbled letters using a given dictionary
Given a dictionary, a method to do lookup in dictionary and a M x N board where every cell has one character. Find all possible words that can be formed by a sequence of adjacent characters.
Example:
...
1
vote
1
answer
999
views
The Substring Game! challenge
This is the Substring Game! challenge from HackerEarth:
Watson gives Sherlock a string (let's denote it by S). Watson calculates all the substrings of S in his favourite order.
According to the ...
2
votes
1
answer
1k
views
Project RoboNest - Nestable/Breakable For Loops + Basic While Loops for Robot Framework
I'm implementing things in Robot Framework that it does not support by default, including nestable For Loops and, now, While Loops. I'm looking for readability, algorithm, methodology, and/or ...
1
vote
1
answer
295
views
Greedy Algorithm - Tuple Comparator
I've completed the problem set 9 of the OCW 6.00sc course which requires the implementation of a greedy algorithm - see prompt.
When completing problem 2, it is asked to implement comparator ...
5
votes
2
answers
1k
views
Prime Number Generator (6n + 1 or 6n - 1)
This generator is like most where it brute forces an integer: it see whether the integer is divisible by any of the primes; if so, then it's not a prime and vice versa. This though only compares ...
3
votes
2
answers
23k
views
Using BFS to solve 8-puzzle game using Python 2
I'm trying to solve the 8-puzzle game using BFS, DFS and A* algorithms implemented using Python 2.7. For now, I have managed to solve a couple of test cases using BFS and I want to know how I can ...