# Tagged Questions

1answer
36 views

### How many n-digit numbers can be formed using x single digit numbers? [on hold]

For instance, I have to form 4 digit numbers with the any 3 digits, say 1, 2 and 3. There are several possible numbers that can be formed by arranging these digits in various orders, but I am unable ...
1answer
58 views

### The number of ways people standing in a line can be holding hands

I'm writing a program to analyze the maximum unique sequences of data in a string, given certain sets of two can be interpreted in two ways. There's a bit of math that I can't figure out, I've ...
1answer
55 views

### How to check if $\text{position}\left(\frac{a + b} 2\right )$ is in range $\text{position}\left(a\right )$ and $\text{position}\left(b\right )$

Given a permutation of $n$ number $1, 2, 3,\dots,n$. How to check if it is exist $a,\ b$ with the same parity such that $\frac {a + b} 2$ is between $a, b$. How to solve this problem efficiently ? ...
0answers
59 views

### Sparse matrix algorithms involving data-driven or random access / walk

I am looking for some well-known algorithms in which sparse matrix elements are accessed in a non-structured way, i.e. row/column depends on a value of another (sparse) matrix/vector element or some ...
1answer
45 views

### Total number of possible sub sequence with given condition

Given a sequence of two letters A and B find the total number of possible sub sequences where number of letter A is two times the number of letter B without ...
2answers
106 views

### How to generate all possible combinations for X numbers in PHP? [duplicate]

I would like to make function in PHP which would print all possible combinations for X numbers. For example, for input 2 result would be: 12 21 For input 3 ...
2answers
107 views

### Count Number of Sequences

The question is: Given a sequence of positive integers A={1,2,3,...,N}. Count the number of sequences you can get after making K swaps between adjacent element on it for a given N ? My approach: My ...
0answers
219 views

### Count swap permutations

Given an array A = [1, 2, 3, ..., n]: ...
1answer
62 views

### What is the meaning of nCk X nPk?

I am trying to understand the bulls and cows document, Page 6 , equivalences . Can someone please tell me what author means when he says nCk x nPk like 4P0 X 4C0 , 4P1 X 4C1 ?
1answer
48 views

### Possible Ways to reach a Sum

Imagine that I have a N long set of numbers. I would like to know the possible ways that I could reach a specific sum using only the numbers in my set. As an example: ...
1answer
76 views

### Finding the 'n'th k-permutation of a set, and finding 'n' for a given k-permutation (lexicographical ordering)

Suppose you have a set, and want to order the k-permutations of the set (for example, the permutations of 5 elements of the set {1, 2, 3, ..., 16}). Is there a fast way of finding 'n' (the ...
2answers
78 views

### Algorithm to compute maximum permutation sum in matrix

Given a matrix $A_{n\times n}$ of real numbers, what fast algorithms do there exist to compute the maximum value of $a_{1,\sigma(1)}+a_{2,\sigma(2)}+\ldots+a_{n,\sigma(n)}$ over all permutations ...
0answers
49 views

### Composing permutations in factorial notation

Given two permutations $p_1$ and $p_2$ in factorial notation, is there a direct algorithm which computes their composition directly, i.e. without translating to a different notation or via computing ...
0answers
56 views

### Summing the product of combinations of matrix elements

I have a situation where I have an $NxN$ matrix $A$ where each element $a_{i,j}\in\mathbb{R}_{\leq 0}$. I would like to consider the set of all collections of elements such that each collection of $N$ ...
1answer
28 views

### Permutation query

Would anyone be able to help here with this one ? Let $A = \{a, …, z, A, …, Z, 0, …, 9\}$ be some alphabet and let $$q = q_1, …, q_m \text{ and } w = w_1, …, w_n$$ be finite-length words in $A^*$. ...
1answer
71 views

### Alternating Pair

I want to find the number of permutations of $1,2,\ldots,N$ having exactly $k$ triples satisfying the condition that either $n_{i-1}>n_i<n_{i+1}$ or $n_{i-1}<n_i>n_{i+1}.$ For example for ...
1answer
59 views

### Finding Required Permutation

I have numbers from $1$..$n$. I want to find number of permutation from all $n!$ permutation where the numbers have following arrangement. $L$ $G$ $L$ $G$ $L$ or $G$ $L$ $G$ $L$ $G$. Where L means ...
1answer
95 views

### Expected Value of this function

Let’s consider a random permutation p1, p2, …, pN of numbers 1, 2, …, N and Function F is calculated as F=(X[2]+…+X[N-1])^K, where ...
0answers
286 views

### Finding the number of arrangement of N people of different height such that K of them are visible from front

Moderator Note: This is a current contest question on codechef.com. [Initially, I had asked this question in stackoverflow, but someone suggested to post it here, and hence this question is ...
2answers
386 views

### How do I find the maximum number of knights on a chess board?

I came across this problem and after thinking a lot I could not get any idea how to calculate it. Please suggest to me the right way to calculate it. Given a position where a knight is placed on ...
1answer
54 views

### How to arrange $n$ pairs of numbers so that this expression is minimized

Consider $n$ pairs of positive integers, $(x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)$. Make a permutation $(a_1, b_1), (a_2, b_2), \dots, (a_n, b_n)$ of these pairs, such that for all $x_i, y_i$, a ...
3answers
88 views

### Distribute Gifts among students

$N$ students are to be provided with gifts We know that the $i$'th student wants to get at least $a_i$ gifts. The teacher wants to give distinct gifts meaning if he give $x$ gifts to one student then ...
0answers
92 views

### Permutation for arranging letters in such a way that no similar letters come together (except SPACE)

I would like to get a general expression for arranging n letters such that any similar letters in them never come together (except SPACE). For example : Lets take AABBCCC and three ...
4answers
153 views

### Divisibility by seven

Given number n, whose decimal representation contains digits only $1, 6, 8, 9$. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7. If number is m ...
1answer
184 views

### Numbers permutation

Given $n$ numbers and $k$ positions I want the total number of permutations of these n numbers on these $k$ positions if repetition is allowed and if the following two arrangements are considered ...
0answers
15 views

### If $A_j=\sum_{x,y,z}B_{x}B_{y}B_{z}$, where $x+y=z+j$, is there a closed form expression for $\frac{\partial A_j}{\partial{B_k}}$?

I am working on a problem involving equations whose interaction is governed by a conservation of momentum condition. Essentially I have two vectors $\mathbf{A}=\left\{A_j\right\}$ and ...
1answer
95 views

### number of derangements

In the normal derangement problem we have to count the number of derangement when each counter has just one correct house,what if some counters have shared houses. A derangement of n numbers is a ...
0answers
65 views

### number of ways to arrange

There are N 1s and N 0s We have to arrange them in a row such that at no position in this row the number of 0s from the beginning exceed the number of 1s from the beginning. Also the number of ...
2answers
129 views

### Maximum number of seating plans

15 people will be seat in a row of 15 chairs. Two seating plan are considered the same if two plans share same adjacent quadruples. What is the maximum number of seating plans can be made? For ...
0answers
69 views

### How is the algorithm for recursively printing permutations of a set of numbers this equation our professor gave us?

I'm having a great amount of trouble understanding where my prof got $T(m, n) = n(T(m+1, n-1) + m+1 + n)$ if $n > 1$ as the recursive formula for the algorithm for recursively printing the ...
4answers
580 views

### distributing z different objects among k people almost evenly

We have z objects (all different), and we want to distribute them among k people ( k < = z ) so that the distribution is ...
2answers
91 views

### Determine no of combinations for cutting stock algorithm

I have to buy $n$ wooden logs of size 2000 each, from which I have to cut different pieces of smaller size say: 255*10 750*7 550*13 In a manner that cutting will ...
1answer
100 views

### Explanation on step $\rho$ of the SHA-3 algorithm

I'm working on implementing SHA-3 in a PIC microcontroller. In the block permutation, I don't quite understand step $\rho$: Bitwise rotate each of the 25 words by a different triangular number 0, ...
1answer
107 views

### Minimum number of moves to convert a list of any integers into a permutation

Given a list of integers of size n, how to find the minimum number of moves to convert it to a Permutation? In one move, we are allowed to decrease or increase any element of the list by one. For ...
1answer
137 views

### Generating a random derangement

I'm having a problem about derangements that I'm trying to solve. Given a set $S = \{1,\ldots,n\}$, I want to generate a random derangement. I've considered generating a permutation and checking ...
1answer
195 views

0answers
227 views

### Anti-prime sequence

I have permutation from $x$ to $y$. And how to make sequence which $d$ summed numbers from this sequence ISN'T a prime number. if we have sequence $x_1,x_2,x_3,x_4,x_5 \dots y$ than $d$ means : ...
4answers
169 views

### Is this a kind of Permutation?

I'm trying to design an algorithm to generate something that I don't know how exactly to call! Ok, I'm not a mathematician, I'm studying computer science and thought this would be a great moment to ...
6answers
825 views

### Why is the number of possible subsequences $2^n$?

If anyone here is familiar with the Lowest Common Subsequence problem, they probably know that the number of posibble subsequences in a sequence is $2^n$; $n$ being the length of the sequence. ...