Questions tagged [circular-permutations]

A cyclic permutation (or circular permutation) is a permutation built on a set of elements in cyclic order.

A cyclic permutation (or circular permutation) is a permutation built on a set of elements in cyclic order.

Wikipedia: http://en.wikipedia.org/wiki/Cyclic_permutation

29 questions
1
vote
0 answers

Permutations of a large number of rows

An array of int (between 0 and 30) has N rows and 4 columns. It has a head and a tail, a start and an end. All the rows but two have to be permutated between the head and the tail. The rows identified as the head and the tail can be moved, but the…
user3790428
0
votes
0 answers

How to assign a variable for each single permutation?

I'm using the code below to find the permutations. from itertools import permutations seq = permutations(['1','2','3']) print(seq) for p in list(seq): print(p) Output: ('1', '2', '3') ('1', '3', '2') ('2', '1', '3') ('2', '3', '1') ('3',…
0
votes
3 answers

Permutations without cycles

I want to generate all possible permutations of a list, where cyclic permutations (going from left to right) should only occur once. Here is an example: Let the list be [A, B, C]. Then I want to have permutations such as [A, C, B] but not [B, C, A]…
Gilfoyle
  • 3,282
  • 3
  • 47
  • 83
0
votes
0 answers

Number of ways of putting 1-16 into 16 sectors of a circle such that the sum of any 3 consecutive sectors is less than 27

In how many ways can you put the numbers 1-16 into 16 sectors of circle such that the sum of any 3 consecutive sectors is less than 27 ? Any two sectors cannot have the same number. [Source : AoPS] I wanted to solve this problem using programming.…
Bunny
  • 1,180
  • 8
  • 22
0
votes
3 answers

Get permutation of 4 digits numbers without repetition with all possible combination

function permuteString($str) { $aStr = str_split($str); $iSize = count($aStr); $aResult = array(); for ($i = 0; $i < $iSize; ++$i) { $sFirst = array_shift($aStr); $aInner = $aStr; $iInner =…
0
votes
0 answers

I want to compare the permutations of decks

The goal is to (dis)prove a concept by comparing permutations of decks of cards. A deck contains a number of blue cards(b) and red cards(r). These can be any permutation of that amount of b and r. If it's a 3 card deck with two blue cards and one…
Zovc
  • 11
  • 1
0
votes
1 answer

Composition of cycle permutation

What is a good Python program to calculate the composition( from right to left) of cycle permutations? I know how to calculate the answer, but I don't know the algorithm for a Python program. For example; '(1,6,5,3)(1,4,2,3)' has the solution…
twister
  • 3
  • 2
0
votes
1 answer

circular permutation of similar objects

I need to an R code for circular permutation of similar objects which defines this code exactly. The number of circular permutations that can be formed using 'n' objects out of which 'p' are identical and of one kind and 'q' are identical and of…
amir
  • 3
  • 2
0
votes
2 answers

How can I improve my "rotate (roll / cyclic permutation) array" solution?

I am doing some stuff on leetcode and came up with solution it works fine but some cases. Here is the problem itself: But in case like this it doesn't: It doesn't make sense how can I rotate elements if k is bigger than length of array. If you…
Ulukbek Abylbekov
  • 449
  • 1
  • 6
  • 19
0
votes
1 answer

Generating all unique orders of looping series of characters (all circular permutations)

I have a string that is made out of Xs and Ys. For the sake of the question let's say this string is constructed of Four-Xs and Two-Ys: XXYYYY How can I generate all of the possible unique strings that are made out of Four-Xs and Two-Ys given…
Michael Seltenreich
  • 3,013
  • 2
  • 29
  • 55
0
votes
0 answers

javascript how to do permutations on objects

I've got an array of 220 objects in javascript. Each object is of the form like this... var foo = { foo: string bar: string i: number } I want to be able to find all permutations where (starting at the second item in the list) bar ==…
Joff
  • 11,247
  • 16
  • 60
  • 103
-1
votes
1 answer

Cartesian product but remove duplicates up to cyclic permutations

Given two integers n and r, I want to generate all possible combinations with the following rules: There are n distinct numbers to choose from, 1, 2, ..., n; Each combination should have r elements; A combination may contain more than one of an…
user19044944
-1
votes
1 answer

Permutation to disjoint cycles in Haskell

I was trying to implement permutation to cycles in Haskell without using Monad. The problem is as follow: given a permutation of numbers [1..n], output the correspondence disjoint cycles. The function is defined like permToCycles :: [Int] ->…
-2
votes
2 answers

How to get prime numbers from string using permutations and combinations

Complete the following function to return a list of strings lesser than 999 which form prime numbers from a given string of numbers. For example if the given string is “23167”. All the prime numbers less than or equal to 999 in the string are…
Sagar
  • 9
  • 4
1
2