Skip to main content
added 546 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%x%x)),sep='')

This differs from Jarko Dubbeldam's intended solution, but the general idea is the same: to generate 1:n repeated 1:n times, it leverages diag in two different ways:

  • diag(matrix) returns the diagonal of a matrix.
  • diag(vector, nrow) generates an nrowxnrow matrix with vector along the diagonal, recycling as necessary.

%x% is the Kronecker matrix product which when applied to two numbers returns their usual product.

Finally, cat prints the diagonal out with separator '' which results in the sequence.

Try it online!

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%x%x)),sep='')

Try it online!

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%x%x)),sep='')

This differs from Jarko Dubbeldam's intended solution, but the general idea is the same: to generate 1:n repeated 1:n times, it leverages diag in two different ways:

  • diag(matrix) returns the diagonal of a matrix.
  • diag(vector, nrow) generates an nrowxnrow matrix with vector along the diagonal, recycling as necessary.

%x% is the Kronecker matrix product which when applied to two numbers returns their usual product.

Finally, cat prints the diagonal out with separator '' which results in the sequence.

Try it online!

Post Undeleted by Giuseppe
deleted 45 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%o%xx%x%x)),sep='')

This is not a vaild crack as it uses o

Try it online!Try it online!

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%o%x)),sep='')

This is not a vaild crack as it uses o

Try it online!

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%x%x)),sep='')

Try it online!

added 44 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%o%x)),sep='')

This is not a vaild crack as it uses o

Try it online!

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%o%x)),sep='')

Try it online!

R, Jarko, again

cat(diag(diag(('i'%in%'i'):(x=scan()),x%o%x)),sep='')

This is not a vaild crack as it uses o

Try it online!

Post Deleted by Giuseppe
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105
Loading