Skip to main content
Slimmed down the join to save 3 bytes.
Source Link

Php 7.1, 166163 bytes

Via CLI providing the number as an argument:

<?foreach(str_split($argv[1])as$k=>$d)$a[]=array_fill(0,$s+=$k+1,array_fill(0,$s,$d));foreach(array_replace_recursive(...array_reverse($a))as$v)echo join('',$v)."\n";

Not so golfed:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Php 7.1, 166 bytes

Via CLI providing the number as an argument:

<?foreach(str_split($argv[1])as$k=>$d)$a[]=array_fill(0,$s+=$k+1,array_fill(0,$s,$d));foreach(array_replace_recursive(...array_reverse($a))as$v)echo join('',$v)."\n";

Not so golfed:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Php 7.1, 163 bytes

Via CLI providing the number as an argument:

<?foreach(str_split($argv[1])as$k=>$d)$a[]=array_fill(0,$s+=$k+1,array_fill(0,$s,$d));foreach(array_replace_recursive(...array_reverse($a))as$v)echo join($v)."\n";

Not so golfed:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Small golf changes, added omited Php opening tag.
Source Link

Php 7.1, 165166 bytes

Via CLI providing the number as an argument:

<?foreach(str_split($argv[1])as$k=>$d)$a[]=array_fill(0,$s+=$k+1,array_fill(0,$s,$d));foreach(array_replace_recursive(...array_reverse($a))as$v)echo join(0'',$v)."\n";

Not so golfed:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Php 7.1, 165 bytes

Via CLI providing the number as an argument:

<?foreach(str_split($argv[1])as$k=>$d)$a[]=array_fill(0,$s+=$k+1,array_fill(0,$s,$d));foreach(array_replace_recursive(...array_reverse($a))as$v)echo join(0,$v)."\n";

Not so golfed:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Php 7.1, 166 bytes

Via CLI providing the number as an argument:

<?foreach(str_split($argv[1])as$k=>$d)$a[]=array_fill(0,$s+=$k+1,array_fill(0,$s,$d));foreach(array_replace_recursive(...array_reverse($a))as$v)echo join('',$v)."\n";

Not so golfed:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Small golf changes, added omited Php opening tag.
Source Link

Php 7.1, 173165 bytes

Via CLI providing the number as an argument:

<?foreach(str_split($argv[1])as$k=>$d){$s+=$k+1;$a[]=array_fill$a[]=array_fill(0,$s$s+=$k+1,array_fill(0,$s,$d));};foreach(array_replace_recursive(...array_reverse($a))as$v)echo implodejoin(''0,$v)."\n";

ReadableNot so golfed:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Php 7.1, 173 bytes

Via CLI providing the number as an argument:

foreach(str_split($argv[1])as$k=>$d){$s+=$k+1;$a[]=array_fill(0,$s,array_fill(0,$s,$d));};foreach(array_replace_recursive(...array_reverse($a))as$v)echo implode('',$v)."\n";

Readable:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Php 7.1, 165 bytes

Via CLI providing the number as an argument:

<?foreach(str_split($argv[1])as$k=>$d)$a[]=array_fill(0,$s+=$k+1,array_fill(0,$s,$d));foreach(array_replace_recursive(...array_reverse($a))as$v)echo join(0,$v)."\n";

Not so golfed:

$n = 123;

foreach(str_split($n) as $k => $d) {
    $s += $k + 1;
    $a[] = array_fill(0, $s, array_fill(0, $s, $d));
}

foreach(array_replace_recursive(...array_reverse($a)) as $v)
    echo implode('', $v) . "\n";

Output:

122333
222333
222333
333333
333333
333333

Method:

Basically build multi-dimensional array squares consisting of the digit, and then superimpose all of them (array_replace_recursive).

(Yes, I know this is embarrassingly long.)

Source Link
Loading