eoincampbell / combinatorics Goto Github PK
View Code? Open in Web Editor NEWCombinatorics Library for Microsoft .NET.
Home Page: https://www.nuget.org/packages/Combinatorics
License: Apache License 2.0
Combinatorics Library for Microsoft .NET.
Home Page: https://www.nuget.org/packages/Combinatorics
License: Apache License 2.0
Would it be a good idea to strong name the assembly included in the Nuget package, so all the consumers who have a strong-named project don't have to do it?
Hi,
I don't know if this is the right place to address my issue.
I am using you package on VS in a vb.net application. I've tried to do what you did in here:
https://trycatch.me/combinatorics-in-net-part-i-permutations-combinations-variations/
When it comes to send the combination to a MsgBox, I get errors. I am trying this:
Dim np As New List(Of Integer)
For i = 0 To 5
np.Add(i)
Next
Dim q As New Combinations(Of Integer)(np, 3)
For Each v As Integer In q
MsgBox(String.Join(",", v))
Next
To mimic what you did there, but it's not working.
I have also tried:
Dim str As String = String.Join(",", q)
MsgBox(str)
But the result is just a sequence of "System.Collections.Generic.List`1[System.Int32]". They are in the number of q.count.
The list of combinations I get is an IReadOnlyList(Of Integer), the program doesn't let me do anything except q.count, so far.
The final aim is to work with the elements of the combinations to mime nested loops, so I need to convert, somehow, the combinations into a matrix (number of combinations, number of elements in each combination), or similar. The MsgBox in the example is just to try and see what happens, but nothing happens unfortunately.
I am really sorry if this is a stupid question, I am not an expert.
Thanks for you time
@eoincampbell @StephenCleary I was thinking of an Xunit DataAttribute extension that calls this library to generate combinatoric input. In the past, I've manually generated InlineData values.
Thoughts on whether this would be OK to add to this project?
Some maintainers get upset at adding more code/APIs to a project, as it means more code to support, but this project was relatively quiet until Stephen and I came along recently, so I am hopeful there is some interest in sprucing things up.
Could use some updates: IReadOnlyList
, netstandard 2, source linking, etc.
Is this library still maintained? If not, I could fork and update it.
Suppose I have a tree with a single root node A. A has 3 child nodes, B, C and D. B as 2 child nodes, E and F. So:
A
/ | \
B C D
/ \
E F
Now let's say every node could have a value of 0 or 1. If the node value is 0, child nodes should be ignored and not included in the permutation.
I want to compute every possible permutation of this tree, so it would go something like this:
Permutation 1: Value of node A = 0. Therefore, the complete tree of P1 is node A only, since we ignore it's child nodes.
A(0)
Permutation 2: Node values are A = 1, B=0, C=0 and D=0. We ignore B's children since B=0, giving us a tree of A, B, C and D only.
A(1)
/ | \
B(0) C(0) D(0)
Permutation 3: Values are A=1, B=0, C=0 and D=1.
A(1)
/ | \
B(0) C(0) D(1)
Permutation 4: Values are A=1, B=0, C=1 and D=0.
A(1)
/ | \
B(0) C(1) D(0)
Permutation 5:
A(1)
/ | \
B(0) C(1) D(1)
Permutation 6:
A(1)
/ | \
B(1) C(0) D(0)
/ \
E(0) F(0)
and so on until the final permutation would be:
A(1)
/ | \
B(1) C(1) D(1)
/ \
E(1) F(1)
Which would be the 11th permutation. Can I use the Permutations class in this library against a tree data structure, and have it handle conditional logic during it's computation?
It would be nice to be able to write the following:
var variations = Variations<MyEnum>(4, GenerateOption.WithRepetution);
In particular, I can see this useful in generating AutoFixture fixtures for EF entities where the property is an Enum. I usually want to write something to the effect of One.Of<MyEnum>
, or UniqueList.Of<MyEnum(size: 4)
, etc.
Hello,
First, thank you for making this library available.
I have a unique use for the library which would be easier satisfied if the permutation collection could utilize indexing. Being able to go to permutation at 1,000,540 like you do with an array would be helpful. I understand this may be difficult as the permutations appear to be created on demand iteratively.
The next option would be generating the permutations in a parallel multi-threaded manner which preserves order so that when I search through the collection again for item 1,000,540 that I get the same permutation as before.
I have played around with PLINQ to something multithreaded (separate from this library) but the order of the generated permutations was never the same.
Building the list with your library and persisting it to disk in a database is an option but not the preferred one.
Any suggestions would be appreciated!
Nothing special, just say: thanks for your lib !
Hi guys,
Am I missing something here? I would have expected the result to be found.
Thanks for a great project.
void Main()
{
var letters = "acdegilmnoprstuw".ToCharArray();
var allCombinations = new Combinations(letters.ToList(),7,GenerateOption.WithRepetition);
allCombinations.Single (c => new string(c.ToArray())=="leepadg").Dump("foundit"); // why does this fail???
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.