All Questions
24
questions
8
votes
3
answers
143
views
Compressed output of set in Python
In order to provide a better output of sets with many consecutive elements (a similar class could be written for a list or tuple,...
2
votes
1
answer
190
views
Yet another Wordle Game
This Jupyter Notebook code for the Wordle game works. After a lot of fixes, I have it working as it should. The code is a jumbled mess. I am open to any suggestions and/or criticism of my code. I am ...
1
vote
1
answer
60
views
SortedIntSet: a set of integers that can be iterated in ascending order in O(N) time
I needed a set with the following properties:
can be iterated in ascending or descending order in \$O(N)\$ time
the usual set operations (contains, add, remove, discard) can still be done in \$O(1)\$
...
5
votes
2
answers
763
views
Filtering a List based on a Suffix and avoid duplicates
I was wondering if there is a better way to solve this issue.
I have a list like this:
...
1
vote
0
answers
37
views
Set operations on a tree / Hierarchical set class
Initially, I posted this question on StackOverflow. I wanted to know if there's an existing library that implements the concept I have in mind, which is the following.
I want to define a hierarchy/...
2
votes
0
answers
110
views
Solving Exact Cover by Three Products in Python
I'm a computer-science hobbyist and found an NP-complete problem that is similar to both subset-product and Exact Cover by 3-sets.
Here is a Reduction of Exact-Cover into my problem. I am multiplying ...
1
vote
1
answer
42
views
Finding data relations of json paths in python
I am kind of new to python, so I am pretty sure there are way better elegant ways to do this.
I have made a function that is able to compare two list of possible json object paths, and detect what ...
2
votes
2
answers
220
views
Python set based solution to Subset Sum
Working on the 2 element subset sum problem (finding two numbers in a list that sum to a given value), I came up with a relatively short solution code-wise.
The code could fit on a single line but I'...
0
votes
2
answers
2k
views
Finding Repeat and missing numbers in an array
Problem Statement:
You are given a read-only array of n integers from 1 to n. Each
integer appears exactly once except A which appears twice and B which
is missing.
Return A and B.
...
4
votes
2
answers
6k
views
From a set of words, output all words that fit a string of random letters (like Scrabble)
I am in my first year of programming with Python 3 and am wondering if anyone had a better way to program this problem. When the user provides up to 7 random letters as a single string, the program ...
3
votes
3
answers
306
views
Finding the number of ways to partition {1,2, ..., N} into p1 and p2 such that sum(p1) == sum(p2)
I am trying to write a space and time efficient algorithm to calculate the number of ways to partition a set of integers {1, 2, ..., N} into two partitions such that the sums of integers in the two ...
6
votes
2
answers
395
views
is_subset Python implementation
I wanted to ask for a code review for my implementation of Set:
...
2
votes
1
answer
134
views
Python implementation for Set
I wanted to ask for a code review for my implementation of Set:
...
6
votes
2
answers
4k
views
4
votes
1
answer
5k
views
Compute power set of a given set in Python
Problem:
Given a set (let's say of integers), return the list of all of its subsets also known as the power set.
It looks to be working, but I would like feedback on the algorithm and Python ...