Skip to main content
Commonmark migration
Source Link

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

###Explanation

Explanation

This uses more or less the same idea as @xnor's answer.

2i^ % take input n and compute 2^n :q % range [0,1,...,2^n-1] (row vector) t! % duplicate, transpose into a column vector Z~ % bitwise XOR with broadcast Zl % binary logarithm tk % duplicate and round down = % true if equal, i.e. for powers of 2 XR % upper triangular part, above diagonal 2#f % row and index columns of nonzero values h % concatenate vertically 

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

###Explanation

This uses more or less the same idea as @xnor's answer.

2i^ % take input n and compute 2^n :q % range [0,1,...,2^n-1] (row vector) t! % duplicate, transpose into a column vector Z~ % bitwise XOR with broadcast Zl % binary logarithm tk % duplicate and round down = % true if equal, i.e. for powers of 2 XR % upper triangular part, above diagonal 2#f % row and index columns of nonzero values h % concatenate vertically 

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

Explanation

This uses more or less the same idea as @xnor's answer.

2i^ % take input n and compute 2^n :q % range [0,1,...,2^n-1] (row vector) t! % duplicate, transpose into a column vector Z~ % bitwise XOR with broadcast Zl % binary logarithm tk % duplicate and round down = % true if equal, i.e. for powers of 2 XR % upper triangular part, above diagonal 2#f % row and index columns of nonzero values h % concatenate vertically 
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

###Explanation

This uses more or less the same idea as @xnor's answer@xnor's answer.

2i^ % take input n and compute 2^n :q % range [0,1,...,2^n-1] (row vector) t! % duplicate, transpose into a column vector Z~ % bitwise XOR with broadcast Zl % binary logarithm tk % duplicate and round down = % true if equal, i.e. for powers of 2 XR % upper triangular part, above diagonal 2#f % row and index columns of nonzero values h % concatenate vertically 

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

###Explanation

This uses more or less the same idea as @xnor's answer.

2i^ % take input n and compute 2^n :q % range [0,1,...,2^n-1] (row vector) t! % duplicate, transpose into a column vector Z~ % bitwise XOR with broadcast Zl % binary logarithm tk % duplicate and round down = % true if equal, i.e. for powers of 2 XR % upper triangular part, above diagonal 2#f % row and index columns of nonzero values h % concatenate vertically 

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

###Explanation

This uses more or less the same idea as @xnor's answer.

2i^ % take input n and compute 2^n :q % range [0,1,...,2^n-1] (row vector) t! % duplicate, transpose into a column vector Z~ % bitwise XOR with broadcast Zl % binary logarithm tk % duplicate and round down = % true if equal, i.e. for powers of 2 XR % upper triangular part, above diagonal 2#f % row and index columns of nonzero values h % concatenate vertically 
added 128 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

###Explanation

This uses more or less the same idea as @xnor's answer.

2i^ % take input n and compute 2^n :q % range [0,1,...,2^n-1] (row vector) t! % duplicate, transpose into a column vector Z~ % bitwise XOR with broadcast Zl % binary logarithm tk % duplicate and round down = % true if equal, i.e. for powers of 2 XR % upper triangular part, above diagonal 2#f % row and index columns of nonzero values h % concatenate vertically 

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

MATL, 20 bytes

2i^:qt!Z~Zltk=XR2#fh 

This works with current version (14.0.0) of the language/compiler.

Try it online!

###Explanation

This uses more or less the same idea as @xnor's answer.

2i^ % take input n and compute 2^n :q % range [0,1,...,2^n-1] (row vector) t! % duplicate, transpose into a column vector Z~ % bitwise XOR with broadcast Zl % binary logarithm tk % duplicate and round down = % true if equal, i.e. for powers of 2 XR % upper triangular part, above diagonal 2#f % row and index columns of nonzero values h % concatenate vertically 
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading