Comments (2)
Hello Stefano,
Thank you for the feedback.
As for k-permutations. There is no a special generator for this type of permutation in the library, but you can always generate them using the existing Combination and Permutation generators together. For example, 2-Permutations without repetitions of the lists (1, 2, 3) can be generated using the following code:
Generator.combination(1, 2, 3)
.simple(2)
.stream()
.forEach(combination -> Generator.permutation(combination)
.simple()
.forEach(System.out::println));
it will print the following six 2-permutations of (1, 2, 3):
[1, 2]
[2, 1]
[1, 3]
[3, 1]
[2, 3]
[3, 2]
Similarly, you can get 2-Permutations with repetitions of the lists (1, 2, 3):
Generator.combination(1, 2, 3)
.multi(2)
.stream()
.forEach(combination -> Generator.permutation(combination)
.simple()
.forEach(System.out::println));
it will print the following nine 2-permutations with repetitions of (1, 2, 3):
[1, 1]
[1, 2]
[2, 1]
[1, 3]
[3, 1]
[2, 2]
[2, 3]
[3, 2]
[3, 3]
I have added these examples here.
Let me know if you still think this is not what you need and a special generator should be added to the library.
from combinatoricslib3.
Hey, thank you for your answer!
This is indeed what I was doing, but in two separate steps. I didn't think about the full power of Streams, and as long as this is possible I think it would be enough.
Thumbs up :)
from combinatoricslib3.
Related Issues (14)
- k-Permutations - ordering of elements
- Subsets - give all subsets containing exactly n elements. HOT 2
- Add a cartesian product with collection input parameter. HOT 2
- BitSet Support HOT 1
- Subsets number HOT 2
- IndexOutOfBoundsException when generating permutation for empty list HOT 1
- Return Stream[] or List<Stream> chunks for combinations
- Apache 2.0 compatible license option? HOT 1
- Is version 3.1.0 ready ? HOT 2
- Combinations of lists? HOT 3
- Best way to determine "the rest of the sequence" generated with the `subset()` method?
- Make k-permutation API more easy to use HOT 3
- One more example on K-Permutation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from combinatoricslib3.