instruction stringlengths 0 29.8k ⌀ |
|---|
Is there an algorighm where I provide a list of squares, for example:
sq1 = [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]
sq2 = [(1, 0), (1, 1), (2, 1), (2, 0), (1, 0)]
sq3 = [(1, 1), (1, 2), (2, 2), (2, 1), (1, 1)]
[![enter image description here][1]][1]
and it will return some sort of "collinear c... |
I recently discovered linear programming and it seemed perfect for a CS problem I wanted to solve a few months ago. This task involved solving a large quantity of inequalities at once.
For example, one such system could be
X1,X2,X3,X4 >= 0
X1 >= X3 + 3.0 or X1 < X3 - 7.2
X2 >= X4 + 5
X2 >= X3 +... |
Can a linear programming method be used to solve systems of inequalities with OR (disparate) compound inequalities? |
|algorithms|linear-programming|linear-algebra| |
Is there an algorighm where I provide a list of squares, for example:
sq1 = [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]
sq2 = [(1, 0), (1, 1), (2, 1), (2, 0), (1, 0)]
sq3 = [(1, 1), (1, 2), (2, 2), (2, 1), (1, 1)]
[![enter image description here][1]][1]
and it will return some sort of "collinear c... |
Is there an algorighm where I provide a list of squares, for example:
sq1 = [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]
sq2 = [(1, 0), (1, 1), (2, 1), (2, 0), (1, 0)]
sq3 = [(1, 1), (1, 2), (2, 2), (2, 1), (1, 1)]
[![enter image description here][1]][1]
and it will return some sort of "collinear c... |
All of the discussion is in the context of [this][1] paper.
I think that the whole procedure that the paper describes is not decidable, because if we can have an algorithm for it, then we can solve halting problem.
I begin with the definition of termination, which has not been expressed in the paper.
First thing... |
First off, a couple of observations.
If you allow three inequalities in each "compound inequality", then the problem of finding a feasible solution is NP-complete, since any 3-SAT problem can be recast as this problem.
The problem in parentheses, where you try to fit the maximum number of constraints, is NP-hard,... |
null |
I have a problem where part of it requires answering the question: *does graph $G=(V,E)$ contain a clique of size at least $k$?*
Obviously, answering this question is a NP-Complete problem. I am no trying to find a polynomial time algorithm. I am trying to find an empirically fast algorithm that works well for moder... |
Fast $k$-clique checking algorithm? |
|algorithms|graphs|clique| |
Are there known algorithms to find a line that intersects a given set of segments?
In:
A finite set of segments.
Out:
A line that cross all these segments or explicit answer that there is no such line.
I've tried wiki and general algorithms books but found none. |
The model I'm building first selects a secret word at random from a list. The model which uses an API then returns a row of underscores (space separated)—one for each letter in the secret word—and asks the user to guess a letter. If the user guesses a letter that is in the word, the word is redisplayed with all instanc... |
Design an algorithm to predict words based on a skeleton from a given dictionary |
|algorithms|strings|python|mathematical-analysis| |
I am currently working on proving that the bounded halting problem is $EXP$-Complete. The bounded halting problem is defined by the language $L$ as follows:
$$L = \{\langle M,x,t \rangle : \text{determenstic TM }M \text{ halts on }x \text{ after at most }t \text{ steps}\}$$
I have successfully shown that this lan... |
Proving EXP-Completeness for the Bounded Halting Problem |
|complexity-theory|time-complexity|turing-machines|complexity-classes| |
The model I'm building first selects a secret word at random from a list. The model which uses an API then returns a row of underscores (space separated)—one for each letter in the secret word—and asks the user to guess a letter. If the user guesses a letter that is in the word, the word is redisplayed with all instanc... |
null |
The problem is to find the outer boundary of the union of the squares. We state two claims that help design an $O(n)$ algorithm, where $n$ are the number of given squares.
Let $S_1,\dotsc,S_n$ be the set of given squares. Each square boundary is composed of four line segments. Let $L = \{\ell_1,\dotsc,\ell_m\}$ be t... |
Is there an algorithm where I provide a list of non-overlapping squares, for example:
sq1 = [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]
sq2 = [(1, 0), (1, 1), (2, 1), (2, 0), (1, 0)]
sq3 = [(1, 1), (1, 2), (2, 2), (2, 1), (1, 1)]
[![enter image description here][1]][1]
and it will return some sort... |
null |
null |
The basic idea here is that you are trying to show that there are infinitely many indistinguishable sets in $L$.
Distinguishable Strings: Let $L$ be a language over an alphabet $\sum$. We say that two strings $x$ and $y$ are distinguishable with respect to $L$ if there is a string $z$ such that $xz \in L$ and $yz ... |
null |
Given a DiGraph $G=(V,E)$, I'm wondering if there's a way to determine the largest number of disconnected edges? There is a similar problem for vertices (Maximum Independent Set). However, I'm unable to think of the corresponding problem for edges.
When I say "disconnected edges" I mean the following:
- $(u,v)$ ... |
null |
Given a DiGraph $G=(V,E)$, I'm wondering if there's a way to determine the the largest size of a set of edges that are disconnected pairwise. There is a similar problem for vertices (Maximum Independent Set). However, I'm unable to think of the corresponding problem for edges.
When I say "two disconnected edges" I ... |
The problem can be reduced to the *maximum independent set problem*. Let $G = (V,E)$ be the input instance of the problem. Then, create a new graph $G'$ such that each vertex in $G'$ corresponds to an edge in $G$. Two vertices in $G'$ have an edge between them if and only if the corresponding edges are connected in $G$... |
null |
null |
I've been working on a fun [esolang](https://github.com/CharlesAverill/GoFR#assembly-example) that operates under the idea that it only has program memory (an infinite, sequential list of registers that instructions and instruction arguments are loaded into). Any data needed for computation is loaded into a special `Id... |
Can a modified Turing Machine be Turing-Complete if its Program and Data memory share the same tape? |
|formal-languages|turing-machines| |
null |
Suppose we have the following variant of the "count-unique" problem, which the HyperLogLog algorithm famously solves.
We have two arrays of integers, and we want to know how many unique integers there are between the two (or how many are shared between the two). The arrays are not guaranteed to be sorted in any part... |
Estimating the number of elements shared in two sets using a random sample |
|algorithms|terminology|reference-request|approximation| |
Given a directed graph $G=(V,E)$, I'm wondering if there's a way to determine the largest size of a set of edges that are disconnected pairwise. There is a similar problem for vertices (Maximum Independent Set). However, I'm unable to think of the corresponding problem for edges.
When I say "two disconnected edges"... |
A directed tree (also called an arborescence) of G is a directed subgraph of G in which there exists a vertex v such that there is a unique path from v to every other vertex in the graph.
Please help with an O(|V| + |E|) algorithm that finds a directed spanning tree in G or notifies if there is none.
Thanks
|
Find spanning tree of unweighted directed graph in O(|V| + |E|) |
|algorithms|graphs| |
A directed tree (also called an arborescence) of $G$ is a directed subgraph of $G$ in which there exists a vertex $v$ such that there is a unique path from $v$ to every other vertex in the graph.
Please help with an $O(|V| + |E|)$ algorithm that finds a directed spanning tree in $G$ or notifies if there is none.
... |
Find spanning tree of unweighted directed graph in $O(|V| + |E|)$ |
Find directed spanning tree of unweighted directed graph in $O(|V| + |E|)$ |
If an arborescence exists in $G$, its root must be a node in a strongly connected component with in-degree $0$, as any node inside it is unreachable from the outside. Similarly we find that if more than one strongly connected component with in-degree $0$ exists, no arborescence is possible, as either strongly connected... |
The [MinHash](https://en.wikipedia.org/wiki/MinHash) algorithm is precisely the HyperLogLog-style probabilistic algorithm for approximating the cardinality of the intersection of multiple sets you're looking for. |
null |
null |
Unable to find out how the C-language lexical analyzer would tokenize the declaration of a static array. Say, int i[3]= {1,2,3};
The lexical analyzer would need to differentiate between just an integer identifier i, and a static array of size 3.
Am confused how the lexical analyzer would tokenize.
Tried Holub'... |
C language tokenizer output for static integer array |
|lexical-analysis| |
I had to solve this problem recently. Here's the Python implementation I came up with, which includes a (rough) proof using a mixture of Python and mathematical notation:
```
def is_prefix_free(values: Iterable[str]) -> bool:
'''determine if a list of strings is prefix-free
(i.e., no element of 'values... |
I had to solve this problem recently. Here's the Python implementation I came up with, which includes a (rough) proof using a mixture of Python and mathematical notation:
```
def is_prefix_free(values: Iterable[str]) -> bool:
'''determine if a list of strings is prefix-free
(i.e., no element of 'values... |
Here's another proof that doesn't use contradiction:
```
Given:
values[q].startswith(values[p]) [1]
Assumptions:
Let s := sorted(values) [2]
Let i := s.index(values[p]) [... |
A directed tree (also called an arborescence) of $G$ is a directed subgraph of $G$ in which there exists a vertex $v$ such that there is a unique path from $v$ to every other vertex in the graph.
Please help with an $O(|V| + |E|)$ algorithm that finds a directed spanning tree in $G$ or notifies if there is none. |
Suppose we have two sets $A$ and $B$. We should presume the sets are stored in random order on disk, so even if they are identical, the second can be a nontrivial permutation of the first. We want to estimate how many elements they share in common, meaning the size of the intersection $A \cap B$. Equivalently, we want ... |
I suggest you use a brute-force greedy algorithm, where you brute-force explore all possible guesses and all possible candidates for the secret word and see which guess leads to the most ambiguity about the secret word. See https://en.wikipedia.org/wiki/Mastermind_(board_game)#Algorithms_and_strategies, https://cs.sta... |
I suggest you use an upper bound of
$$U = \max(N/(\ln(N) - 1.1), N/\ln(N) + 2000).$$
This will be quite close to the true number. For instance, for $N=10^7$, it is only 1284 larger than the true number. Using a few thousand extra words of memory is hardly worth worrying about.
Moreover, I expect that the chanc... |
I have a problem where part of it requires answering the question: *does graph $G=(V,E)$ contain a clique of size at least $k$?*
Obviously, answering this question is a NP-Complete problem. I am no trying to find a polynomial time algorithm. I am trying to find an empirically fast algorithm that works well for moder... |
I'm working on an algorithm which is permitted to use a training set of approximately 250,000 dictionary words.
I have built and providing here with a basic, working algorithm. This algorithm will match the provided masked string (e.g. a _ _ l e) to all possible words in the dictionary, tabulate the frequency of let... |
null |
null |
Very often I see solutions to optimization problems that describe an algorithm but do not prove why the algorithm leads to an optimal answer. For example, the following problem showed up in an online competition a couple of days ago:
Let `quantity` be an array of positive integers of size `n`. We would like to gener... |
Proving the algorithm gives an optimal solution |
|algorithms|optimization| |
Very often I see solutions to optimization problems that describe an algorithm but do not prove why the algorithm leads to an optimal answer. For example, the following problem showed up in an online competition a couple of days ago:
Let `quantity` be an array of positive integers of size `n`. We would like to gener... |
null |
I'm looking for resources (books, papers, tutorials) on designing domain-specific query languages. I'm mostly interested in the design of syntax and grammar, rather than the implementation. Any UX-focused resources on designing general-purpose programming languages and text-based UIs would also be of some help. I tried... |
Resources on designing query languages |
|reference-request|programming-languages|language-design|domain-specific-languages| |
null |
I suspect you are likely to be out of luck. My advice is to try to find some other way to meet your business needs without requiring you to solve this computational task. The clique problem is NP-hard, so you should not expect any efficient algorithm for your problem.
In particular, testing whether there exists a ... |
null |
Very often I see solutions to optimization problems that describe an algorithm but do not prove why the algorithm leads to an optimal answer. For example, the following problem showed up in an online competition a couple of days ago:
Let `quantity` be an array of positive integers of size `n`. We would like to gener... |
I'm interested in what the typical solution is for priority resolution in interrupt controllers. I assume a hardware logic circuit is used, and not software. For interrupt controllers with fixed priority (by line ID), there is documentation easily available, such as https://en.wikipedia.org/wiki/Priority_encoder and ht... |
Logical circuit for priority resolution in interrupt controllers (with configurable priority, not fixed) |
|circuits|cpu|digital-circuits| |
I suggest you allocate space for
$$U = \max(N/(\ln(N) - 1.1), N/\ln(N) + 2000).$$
This will be quite close to the true number. For instance, for $N=10^7$, it is only 1284 larger than the true number. Using a few thousand extra words of memory is hardly worth worrying about.
Moreover, I expect that the chance t... |
null |
I would like to set up some type of automation/suggestion tool for buying items on a limited spending budget. To try to somewhat formalise the problem, one could suggest to reduce this to a 0/1 knapsack problem with item *i* having price $p_i$ and value $v_i$ and then finding a set of items that maximise the total valu... |
Help in defining value function for 0/1 knapsack |
|algorithms| |
I think you have a misunderstanding. In the knapsack problem, there is a value for each item. You get to define those values.
The value of a set of items is already defined. You don't get to define it. The value of a set of items is the sum of the values of the items in the set. Period. That is it. There is n... |
I understand that password storage generally uses hashing for security due to it being irreversible and that the stored hash is just compared to the hash of the password inputed by a user attempting to log in. As hashes are fixed length, does that mean that even if not specified when creating the password, all login sy... |
Do passwords need a max length? |
|hash|hashing|security| |
Suppose we have two sets $A$ and $B$. The sets share some number of elements between them, but within each set, any item appears at most once. We want to determine how many elements they share in common.
There are many algorithms to estimate this: MinHash, HyperLogLog, etc. However, all of these algorithms, and othe... |
No. There is no* limit on the length of the input to any good cryptographic hash functions. As a result, password hashing can support passwords of unlimited length and do not need to impose a limit on the maximum length of the password.
Of course collisions are possible and exist, but they are believed to be excep... |
Hashes are designed to avoid collisions as much as possible. A perfect hash would completely avoid any collision between passwords up to the length of the hash.
For typical hash lengths, that means that collisions on passwords longer than the original are so rare that they simply preclude any brute-force search. |
Hashes are designed to avoid collisions as much as possible. A perfect hash would completely avoid any collision between passwords up to the length of the hash.
For typical hash lengths, that means that collisions on passwords longer than the original are so rare that they simply preclude any brute-force search.
... |
Hashes are designed to avoid collisions as much as possible. A perfect hash would completely avoid any collision between passwords up to the length of the hash.
For typical hash lengths, that means that collisions on passwords longer than the original are so rare that they simply preclude any brute-force search.
... |
null |
null |
null |
Here is the technique I've been using. This is fairly preliminary but seems to give extremely good results, at least for my use case, where it has reduced the amount of data I need to parse by several orders of magnitude. The general technique seems quite sound and scalable to arbitrary size.
This turned out to be m... |
null |
On a finite 4-connected grid graph, given the source point and destination, it is allowed to consecutively move in one of the four orientions (up, down, left or right) to form a path. We get 1 bonus for each grid point which is NOT on the path but meanwhile has at least one neighbor on the path (bonus counting stops wh... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.