Created
March 6, 2014 16:17
-
-
Save Taluu/9393232 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| const WORD = 'MY FANCY WORD'; | |
| const JOKER = '\''; | |
| $parts = []; | |
| $i = 0; | |
| foreach (str_split(strrev(WORD)) as $word) { | |
| $parts[pow(2, $i++)] = $word; | |
| } | |
| for ($i = 0; $i < pow(2, count($parts)); ++$i) { | |
| $word = ''; | |
| foreach ($parts as $flag => $letter) { | |
| $word .= $i & $flag ? $letter : JOKER; | |
| } | |
| echo strrev($word) . "\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment