Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $start = microtime(true);
- function permutation($warehouses)
- {
- if (array_search(null, $warehouses) !== false) {
- for ($i = 0; $i < count($warehouses); $i++) {
- if (!$warehouses[$i]) {
- $warehouses[$i] = count(array_filter($warehouses)) + 1;
- permutation($warehouses);
- $warehouses[$i] = null;
- }
- }
- } else {
- // foreach ($warehouses as $warehouse) {
- // if ($warehouse) {
- // echo $warehouse . ' ';
- // }
- // }
- // echo PHP_EOL;
- }
- }
- $warehouses = array_fill(0, 9, null);
- permutation($warehouses);
- echo (microtime(true) - $start) / 60 . PHP_EOL;
- echo memory_get_peak_usage(true) / 1014 . PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement