Answer the question
In order to leave comments, you need to log in
How to perform placement of k elements out of n?
Hello! It is necessary to create an elegant algorithm for finding placement. Specifically, you need to place 7 elements out of 8. The algorithms that I saw on the Internet work with numeric arrays, and I have an array of characters (chars). All combinations must be saved, because. then a selection will be made among them. Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Google "placement generation algorithm". For example, this is located .
Working with symbols is no different from working with numbers. In all languages, characters can be compared by their codes, and there is nothing in algorithms other than comparison.
Or you can generate placements from {1,2,3,...N} and then use those numbers in the placements as character indexes. Draw characters from the given string at these positions and get the placement of characters, not numbers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question