Skip to main content
added 362 characters in body
Source Link
nutki
  • 3.7k
  • 11
  • 12

Perl 5 - 56 bytes

\0's can be replaced by actual null byte characters

#!/usr/bin/perl -l
$p="/\\";$_=$"x-$_\\";$_=$"x~$_.$p,y/\0/ /,print,$p^="\0\0$p"for-<>..-1

It is using the fact that if you ignore leading spaces and represent '/' as 1 and ' ' as 0 the pattern in a given row f(n) = f(n-1) ^ (f(n-1) << 1). However the calculations in the code above are executed on strings that are close to the expected output (no leading spaces, other spaces replaced by null bytes) thanks to perl's bitwise string manipulation.

$p="/\\";          # initialize
  $_=$"x~$_.$p,    # loop start, add spaces
  y/\0/ /,         # replace nulls with spaces
  print,           # output
  $p^="\0\0$p"     # calculate next string
for-<>..-1         # loop from -n to -1

Perl 5 - 56 bytes

\0's can be replaced by actual null byte characters

#!/usr/bin/perl -l
$p="/\\";$_=$"x-$_.$p,y/\0/ /,print,$p^="\0\0$p"for-<>..-1

It is using the fact that if you ignore leading spaces and represent '/' as 1 and ' ' as 0 the pattern in a given row f(n) = f(n-1) ^ (f(n-1) << 1). However the calculations in the code above are executed on strings that are close to the expected output (no leading spaces, other spaces replaced by null bytes) thanks to perl's bitwise string manipulation.

Perl 5 - 56 bytes

\0's can be replaced by actual null byte characters

#!/usr/bin/perl -l
$p="/\\";$_=$"x~$_.$p,y/\0/ /,print,$p^="\0\0$p"for-<>..-1

It is using the fact that if you ignore leading spaces and represent '/' as 1 and ' ' as 0 the pattern in a given row f(n) = f(n-1) ^ (f(n-1) << 1). However the calculations in the code above are executed on strings that are close to the expected output (no leading spaces, other spaces replaced by null bytes) thanks to perl's bitwise string manipulation.

$p="/\\";          # initialize
  $_=$"x~$_.$p,    # loop start, add spaces
  y/\0/ /,         # replace nulls with spaces
  print,           # output
  $p^="\0\0$p"     # calculate next string
for-<>..-1         # loop from -n to -1
added 362 characters in body
Source Link
nutki
  • 3.7k
  • 11
  • 12

Perl 5 - 56 bytes

\0\0's can be replaced by actual null byte characters

#!/usr/bin/perl -l
$p="/\\";$_=$"x-$_.$p,y/\0/ /,print,$p^="\0\0$p"for-<>..-1

It is using the fact that if you ignore leading spaces and represent '/' as 1 and ' ' as 0 the pattern in a given row f(n) = f(n-1) ^ (f(n-1) << 1). However the calculations in the code above are executed on strings that are close to the expected output (no leading spaces, other spaces replaced by null bytes) thanks to perl's bitwise string manipulation.

Perl 5 - 56 bytes

\0 can be replaced by actual null byte characters

#!/usr/bin/perl -l
$p="/\\";$_=$"x-$_.$p,y/\0/ /,print,$p^="\0\0$p"for-<>..-1

Perl 5 - 56 bytes

\0's can be replaced by actual null byte characters

#!/usr/bin/perl -l
$p="/\\";$_=$"x-$_.$p,y/\0/ /,print,$p^="\0\0$p"for-<>..-1

It is using the fact that if you ignore leading spaces and represent '/' as 1 and ' ' as 0 the pattern in a given row f(n) = f(n-1) ^ (f(n-1) << 1). However the calculations in the code above are executed on strings that are close to the expected output (no leading spaces, other spaces replaced by null bytes) thanks to perl's bitwise string manipulation.

Source Link
nutki
  • 3.7k
  • 11
  • 12

Perl 5 - 56 bytes

\0 can be replaced by actual null byte characters

#!/usr/bin/perl -l
$p="/\\";$_=$"x-$_.$p,y/\0/ /,print,$p^="\0\0$p"for-<>..-1