permutation

How to re-order units based on their degree of desirable neighborhood ? (in Processing)

寵の児 提交于 2019-12-20 08:48:09
问题 I would need help to implement an algorithm allowing the generation of building plans, that I've recently stumbled on while reading Professor Kostas Terzidis' latest publication: Permutation Design: Buildings, Texts and Contexts (2014). CONTEXT Consider a site (b) that is divided into a grid system (a). Let's also consider a list of spaces to be placed within the limits of the site ( c ) and an adjacency matrix to determine the placement conditions and neighboring relations of these spaces (d

Listing permutations of different combination of characters

别说谁变了你拦得住时间么 提交于 2019-12-20 07:50:35
问题 The closest SO topic I found is here: Listing all permutations of a string/integer But how would I make use of this for different sets of characters for each position in a string? An example: I specify a string length of "3". The first two position should be either "a" or "b", but the last position should be either "1" or "2", e.g: aa1 ba1 ab1 bb1 aa2 ab2 ba2 bb2 回答1: Use this code: public static List<string> GenerateCombinations(char[][] characters) { var combinations = new List<string>();

Getting the ith permutation of a list

不想你离开。 提交于 2019-12-20 07:49:14
问题 I need a fortran code that calculates the ith permutation of a given list {1,2,3,...,n}, without computing all the permutations, that are n!. Is there anyone that can help me? Thank you in advance. 回答1: I solved my problem. In the following I show you both the Mathematica and Fortran codes I implemented. If you have any advise for improve them, do not esitate to comment. MATHEMATICA (example: 10° permutation of {1,2,3,4,5}) n = 5; i = 10; p = Range[n]; ithPermutation = p; Do[f = (n - k)!; d =

How To Find Words Combination In Php

為{幸葍}努か 提交于 2019-12-20 07:30:21
问题 I have a array $new_array=array('c','a','m','t','p'); Now I want to find the words combination which exists in the words table. I have tried to achieve but not succeeded. this is my php code . $words = array(); $set = powerSet($new_array,2); $mysql = new mysqli("localhost","root","","startup"); $sql = "SELECT wordid from words WHERE lemma = '%s'" ; foreach ($set as $key => $value) { $word = implode("", $value); $wordPermutation = permute($word); foreach($wordPermutation as $keyWord) { if(!in

Combinations Of String While Maintaining Order Of Words

我是研究僧i 提交于 2019-12-20 05:23:08
问题 Given a string: String words = "Mary had a little lamb"; how to obtain a combination of sentence fragments while the order of occurrence of words in the original sentence is maintained ??? example: {'Mary had a little lamb'} {'Mary had a little', 'lamb'} {'Mary had a', 'little lamb'}, {'Mary had a', 'little', 'lamb'} {'Mary had', 'a little lamb'}, {'Mary had', 'a little', 'lamb'}, {'Mary had', 'a', 'little lamb'}, {'Mary had', 'a', 'little', 'lamb'} {'Mary', 'had a little lamb'}, {'Mary',

c# list permutations with limited length

痞子三分冷 提交于 2019-12-20 04:53:11
问题 I have a list of Offers, from which I want to create "chains" (e.g. permutations) with limited chain lengths. I've gotten as far as creating the permutations using the Kw.Combinatorics project. However, the default behavior creates permutations in the length of the list count. I'm not sure how to limit the chain lengths to 'n'. Here's my current code: private static List<List<Offers>> GetPerms(List<Offers> list, int chainLength) { List<List<Offers>> response = new List<List<Offers>>();

c# list permutations with limited length

天涯浪子 提交于 2019-12-20 04:53:05
问题 I have a list of Offers, from which I want to create "chains" (e.g. permutations) with limited chain lengths. I've gotten as far as creating the permutations using the Kw.Combinatorics project. However, the default behavior creates permutations in the length of the list count. I'm not sure how to limit the chain lengths to 'n'. Here's my current code: private static List<List<Offers>> GetPerms(List<Offers> list, int chainLength) { List<List<Offers>> response = new List<List<Offers>>();

Zipping together unicode strings in Python

倾然丶 夕夏残阳落幕 提交于 2019-12-20 04:30:20
问题 I have the string: a = "ÀÁÂÃÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜ" b = "àáâãäèéçêëìíîïòóôõöùúûüÿ" and I want to create the string "ÀàÁáÂâ..." I.e split the string in two and then zip the halves together. I tried the naive zip(a, b) but this didn't work. I think this is due to a problem with unicode. Does anyone know how I can get the result I want? 回答1: In Python 2.x, strings are not unicode by default. When dealing with unicode data, you have to do the following: prefix string literals with u character: a = u

Algorithm to generate all permutation by selecting some or all charaters

天涯浪子 提交于 2019-12-20 04:16:14
问题 I need to generate all permutation of a string with selecting some of the elements. Like if my string is "abc" output would be { a,b,c,ab,ba,ac,ca,bc,cb,abc,acb,bac,bca,cab,cba }. I thought a basic algorithm in which I generate all possible combination of "abc" which are {a,b,c,ab,ac,bc,abc} and then permute all of them. So is there any efficient permutation algorithm by which I can generate all possible permutation with varying size. The code I wrote for this is : #include <iostream>

Create fixed length non-repeating permutation of larger set

二次信任 提交于 2019-12-20 03:38:11
问题 I know this topic is much discussed but I can't seem to find any implementation that fits my needs. I have the following set of characters: a b c d e f g h I want to get all possible permutations or combinations (non repeating), but on a limited (variable) set of characters , meaning if I input the characters and the number 2 , the results should look like ab ba ac ca ad da ae ea af fa ag ga ah ha bc cb bd db be eb bf fb bg gb bh hb cd dc ce ec cf fc cg gc ch hc de ed df fd dg gd dh hd ef fe