<?php
$len = 5;
for( $i = 1; $i < pow( 2, $len ); $i++ ) { for( $j = 0; $j < $len; $j++ ) {
if( ( 1 << $j ) & $i ) $line[] = $j + 1;
}
$output[count($line)][] = $line; }
foreach( $output as $group ) {
foreach( $group as $line ) {
foreach( $line as $item ) echo "$item ";
echo "\n";
}
}
?>
PD9waHAKICAgJGxlbiA9IDU7CiAgICRvdXRwdXQgPSBhcnJheSgpOwogICBmb3IoICRpID0gMTsgJGkgPCBwb3coIDIsICRsZW4gKTsgJGkrKyApIHsKICAgICAgJGxpbmUgPSBhcnJheSgpOwogICAgICBmb3IoICRqID0gMDsgJGogPCAkbGVuOyAkaisrICkgewogICAgICAgICBpZiggKCAxIDw8ICRqICkgJiAkaSApICRsaW5lW10gPSAkaiArIDE7CiAgICAgIH0KICAgICAgJG91dHB1dFtjb3VudCgkbGluZSldW10gPSAkbGluZTsKICAgfQogICAKICAgZm9yZWFjaCggJG91dHB1dCBhcyAkZ3JvdXAgKSB7CiAgICAgIGZvcmVhY2goICRncm91cCBhcyAkbGluZSApIHsKICAgICAgICAgZm9yZWFjaCggJGxpbmUgYXMgJGl0ZW0gKSBlY2hvICIkaXRlbSAiOwogICAgICAgICBlY2hvICJcbiI7CiAgICAgIH0KICAgfQo/Pg==