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

R, 175 172172 154 bytes

function(n)write(`[<-`(m<-matrixc(S<-el" ",0:9)[1+(strsplitx=utf8ToInt(x<-Reduce(paste0,1:n,""),"")),y<-nchar(x),y47),*!upper.tri(mdiag(y<-sum(x|1)))["if"(n%%4%in%2:3n%%4>1,1:y,y:1),"if"(n%%4%in%1:2,1:y!n%%4%%3,y:1)]," "1:y)]],1,y,,"")

Try it online!Try it online!

A horrible in-line mess!

-3 bytes by changing the rotation condition

Ungolfed and simplified a bit:-17 bytes thanks to digEmAll's suggestion, and another byte after golfing that further

function(n){
Concat <- Reduce(paste0,1:n,init="")				# concatenate all the digits, with init = "" to handle the n=1 case
digits <- el(strsplit(Concat,""))				# split the string to get component digits
mat    <- matrix(digits,nchar(Concat),nchar(Concat))		# create a matrix with the digits running down the columns,
								# for example, n = 4 is [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
mat[upper.tri(mat)[(n%%4 condiditon),(n%%4 condition)]] <- " "	# conditioned on (n %% 4), replace the values in mat with spaces
write(mat,1,nchar(Concat),,"")					# print the transpose of mat
}

R, 175 172 bytes

function(n)write(`[<-`(m<-matrix(S<-el(strsplit(x<-Reduce(paste0,1:n,""),"")),y<-nchar(x),y),upper.tri(m)["if"(n%%4%in%2:3,1:y,y:1),"if"(n%%4%in%1:2,1:y,y:1)]," "),1,y,,"")

Try it online!

A horrible in-line mess!

-3 bytes by changing the rotation condition

Ungolfed and simplified a bit:

function(n){
Concat <- Reduce(paste0,1:n,init="")				# concatenate all the digits, with init = "" to handle the n=1 case
digits <- el(strsplit(Concat,""))				# split the string to get component digits
mat    <- matrix(digits,nchar(Concat),nchar(Concat))		# create a matrix with the digits running down the columns,
								# for example, n = 4 is [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
mat[upper.tri(mat)[(n%%4 condiditon),(n%%4 condition)]] <- " "	# conditioned on (n %% 4), replace the values in mat with spaces
write(mat,1,nchar(Concat),,"")					# print the transpose of mat
}

R, 175 172 154 bytes

function(n)write(c(" ",0:9)[1+(x=utf8ToInt(Reduce(paste0,1:n,""))-47)*!upper.tri(diag(y<-sum(x|1)))["if"(n%%4>1,1:y,y:1),"if"(!n%%4%%3,y:1,1:y)]],1,y,,"")

Try it online!

A horrible in-line mess!

-3 bytes by changing the rotation condition

-17 bytes thanks to digEmAll's suggestion, and another byte after golfing that further

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

R, 175175 172 bytes

function(n)write(`[<-`(m<-matrix(S<-el(strsplit(x<-Reduce(paste0,1:n,""),"")),y<-nchar(x),y),upper.tri(m)["if"(n%%4%in%0n%%4%in%2:3,1:y,y:1,1:y),"if"(n%%4%in%c(0,3),yn%%4%in%1:12,1:y,y:1)]," "),1,y,,"")

Try it online!Try it online!

A horrible in-line mess!

-3 bytes by changing the rotation condition

Ungolfed and simplified a bit:

function(n){
Concat <- Reduce(paste0,1:n,init="")				# concatenate all the digits, with init = "" to handle the n=1 case
digits <- el(strsplit(Concat,""))				# split the string to get component digits
mat    <- matrix(digits,nchar(Concat),nchar(Concat))		# create a matrix with the digits running down the columns,
								# for example, n = 4 is [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
mat[upper.tri(mat)[(n%%4 condiditon),(n%%4 condition)]] <- " "	# conditioned on (n %% 4), replace the values in mat with spaces
write(mat,1,nchar(Concat),,"")					# print the transpose of mat
}

R, 175 bytes

function(n)write(`[<-`(m<-matrix(S<-el(strsplit(x<-Reduce(paste0,1:n,""),"")),y<-nchar(x),y),upper.tri(m)["if"(n%%4%in%0:1,y:1,1:y),"if"(n%%4%in%c(0,3),y:1,1:y)]," "),1,y,,"")

Try it online!

A horrible in-line mess! Ungolfed and simplified a bit:

function(n){
Concat <- Reduce(paste0,1:n,init="")				# concatenate all the digits, with init = "" to handle the n=1 case
digits <- el(strsplit(Concat,""))				# split the string to get component digits
mat    <- matrix(digits,nchar(Concat),nchar(Concat))		# create a matrix with the digits running down the columns,
								# for example, n = 4 is [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
mat[upper.tri(mat)[(n%%4 condiditon),(n%%4 condition)]] <- " "	# conditioned on (n %% 4), replace the values in mat with spaces
write(mat,1,nchar(Concat),,"")					# print the transpose of mat
}

R, 175 172 bytes

function(n)write(`[<-`(m<-matrix(S<-el(strsplit(x<-Reduce(paste0,1:n,""),"")),y<-nchar(x),y),upper.tri(m)["if"(n%%4%in%2:3,1:y,y:1),"if"(n%%4%in%1:2,1:y,y:1)]," "),1,y,,"")

Try it online!

A horrible in-line mess!

-3 bytes by changing the rotation condition

Ungolfed and simplified a bit:

function(n){
Concat <- Reduce(paste0,1:n,init="")				# concatenate all the digits, with init = "" to handle the n=1 case
digits <- el(strsplit(Concat,""))				# split the string to get component digits
mat    <- matrix(digits,nchar(Concat),nchar(Concat))		# create a matrix with the digits running down the columns,
								# for example, n = 4 is [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
mat[upper.tri(mat)[(n%%4 condiditon),(n%%4 condition)]] <- " "	# conditioned on (n %% 4), replace the values in mat with spaces
write(mat,1,nchar(Concat),,"")					# print the transpose of mat
}
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 175 bytes

function(n)write(`[<-`(m<-matrix(S<-el(strsplit(x<-Reduce(paste0,1:n,""),"")),y<-nchar(x),y),upper.tri(m)["if"(n%%4%in%0:1,y:1,1:y),"if"(n%%4%in%c(0,3),y:1,1:y)]," "),1,y,,"")

Try it online!

A horrible in-line mess! Ungolfed and simplified a bit:

function(n){
Concat <- Reduce(paste0,1:n,init="")				# concatenate all the digits, with init = "" to handle the n=1 case
digits <- el(strsplit(Concat,""))				# split the string to get component digits
mat    <- matrix(digits,nchar(Concat),nchar(Concat))		# create a matrix with the digits running down the columns,
								# for example, n = 4 is [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
mat[upper.tri(mat)[(n%%4 condiditon),(n%%4 condition)]] <- " "	# conditioned on (n %% 4), replace the values in mat with spaces
write(mat,1,nchar(Concat),,"")					# print the transpose of mat
}