It is required to go through all combinations of a group of characters from A to X where X can be any other letter.
Example: the ABCD sequence is given, the function should output AB, AC, AD, BC, BD, CD, ABC, BCD, CDA, ABD (like I forgot nothing), i.e. the position of the symbol in the group is not important - only the uniqueness of the group itself is important.
Google in the direction of placements and combinations. But I did not understand what exactly this is required of me. Sinner - did not learn mathematics. Clever people, explain on fingers or a code, I will be grateful.
Update: Usually they say - and the year has not passed. But I just passed. It took again, this time it went over in detail - here is the PHP code:
function gen_comb ($rest, $current = "", $container = []) { // ΠΡΠ»ΠΈ ΠΏΡΡΡΠΎΠΉ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΈ Π΅ΡΡΡ ΠΎΡΡΠ°ΡΠΎΠΊ if(!$current and $rest) { // Π’Π΅ΠΊΡΡΠ΅ΠΌΡ Π΄Π°Π΅ΠΌ ΠΏΠ΅ΡΠ²ΡΠΉ ΡΠΈΠΌΠ²ΠΎΠ» ΠΎΡΡΠ°ΡΠΊΠ° $current = substr($rest, 0, 1); // ΠΠΎΡΠΎΠΌ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ Π² ΠΎΡΡΠ°ΡΠΊΠ΅ for($i=strlen($rest); $i > 0; $i--) // ΡΠΎΡΠΌΠΈΡΡΠ΅ΠΌ ΠΏΠ°ΡΡ Ρ ΡΠ΅ΠΊΡΡΠΈΠΌ ΠΈ Π·Π°ΠΏΠΈΡΡΠ²Π°Π΅ΠΌ Π² Π²ΡΠ²ΠΎΠ΄ $container[] = $current . substr($rest, $i, strlen($rest)); // ΠΏΡΠΈ ΡΡΠΎΠΌ ΠΏΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ - Π΅ΡΠ»ΠΈ Π² ΠΎΡΡΠ°ΡΠΊΠ΅ ΠΎΠ΄ΠΈΠ½ if(strlen($rest) == 1 and $current) // Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅ΠΌ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ return $container; // Π΅ΡΠ»ΠΈ Π² ΠΎΡΡΠ°ΡΠΊΠ΅ Π±ΠΎΠ»ΡΡΠ΅ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈ ΠΏΡΠΈ Π²ΡΡΠ΅ΡΠ΅ Π΅ΡΠ΅ ΠΎΡΡΠ°Π½Π΅ΡΡΡ if(strlen($rest) - 1) // Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅ΠΌ ΡΠ΅ΠΊΡΡΡΠΈΠ²Π½ΡΠΉ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ Ρ ΡΠΌΠ΅Π½ΡΡΠ΅Π½Π½ΡΠΌ Π½Π° 1 ΠΎΡΡΠ°ΡΠΊΠΎΠΌ return gen_comb(substr($rest, 1, strlen($rest)), "", $container); } }
combinationsimply unmeasured, look through it, youβll definitely find it - splash58