0

Is it possible to build a function that calculates all possible combinations?

EXAMPLE

RED, BLUE, GREEN

It should be

RED BLUE GREEN 
RED BLUE 
RED GREEN 
RED 
BLUE GREEN 
BLUE 
GREEN
Rizier123
  • 58,877
  • 16
  • 101
  • 156
Tom
  • 25
  • 1
  • 7
  • this *homework* question has been asked may dozen times befor –  Mar 22 '16 at 00:12
  • 1
    Welcome to Stack Overflow! Take a moment to read through the [editing help](http://stackoverflow.com/editing-help) in the help center. Formatting on Stack Overflow is different than other sites. The better your post looks, the easier it is for others to read and understand it. – Rizier123 Mar 22 '16 at 00:12
  • 1
    PHP doesn't have a `build_me_a_pink_2_floor_tall_building_with_unicorns()` function, but it has functions like `hammer()`, `screwdriver()`. So yes you can build your function to calculate all combinations of *unicorns*, numbers. – Rizier123 Mar 22 '16 at 00:14
  • lol that was funny @Rizier123 Thanks! – Tom Mar 22 '16 at 00:16
  • 1
    @Dagon You picked the wrong dupe, you closed it with a duplicate about permutation, but OP is asking for combinations, where the order doesn't matter. So `BLUE GREEN` and `GREEN BLUE` is the same => combinations; Your dupe is about permutation `BLUE GREEN` and `GREEN BLUE` is NOT the same => permutation. (If you reopen it I can close it with a correct dupe) – Rizier123 Mar 22 '16 at 00:19
  • @Rizier123 thanks bro :-) –  Mar 22 '16 at 00:20

0 Answers0