GithubHelp home page GithubHelp logo

eoincampbell / combinatorics Goto Github PK

View Code? Open in Web Editor NEW
99.0 99.0 21.0 1.66 MB

Combinatorics Library for Microsoft .NET.

Home Page: https://www.nuget.org/packages/Combinatorics

License: Apache License 2.0

C# 100.00%

combinatorics's People

Contributors

eoincampbell avatar eoincgreenfinch avatar stephencleary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

combinatorics's Issues

Strong name the assembly?

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?

Operate with the combinations in vb.net

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

Xunit DataAttribute extension/nuget package

@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.

Still maintained?

Could use some updates: IReadOnlyList, netstandard 2, source linking, etc.

Is this library still maintained? If not, I could fork and update it.

Could this library be used to compute permutations of a tree based on node values?

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?

Enum syntactic sugar

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.

Parallel query or make indexable

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!

Combination not found

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???
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.