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

R, 239239 230 bytes

function(s){K=table(el(strsplit(gsub(" ","",sscan(,"")),"")))
L=sum;m=matrix(" ",L<-sum(K|1)+1
M=,M<-(M=max(K))+-M%%5+1
m=matrix(" ",L,M)
m[2;m[2:L,M]=names(K)
m[1;m[1,M-g]=paste0(g<-c(1,seq(5,M,5)),"-")
m[1;m[1,]=format(m[1,],j="r")
for;for(X in 2:L)m[X,M-1:K[X-1]]="X"
write1]]=0;write(m,1,L,,"")}

Try it online!Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts.

Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge.

Thanks to @dylnan for pointing out a bug.

Thanks to @rturnbull for the scan approach, dropping 2 bytes.

R, 239 bytes

function(s){K=table(el(strsplit(gsub(" ","",s),"")))
L=sum(K|1)+1
M=(M=max(K))+-M%%5+1
m=matrix(" ",L,M)
m[2:L,M]=names(K)
m[1,M-g]=paste0(g<-c(1,seq(5,M,5)),"-")
m[1,]=format(m[1,],j="r")
for(X in 2:L)m[X,M-1:K[X-1]]="X"
write(m,1,L,,"")}

Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts.

Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge.

Thanks to @dylnan for pointing out a bug.

R, 239 230 bytes

K=table(el(strsplit(gsub(" ","",scan(,"")),"")));m=matrix(" ",L<-sum(K|1)+1,M<-(M=max(K))+-M%%5+1);m[2:L,M]=names(K);m[1,M-g]=paste0(g<-c(1,seq(5,M,5)),"-");m[1,]=format(m[1,],j="r");for(X in 2:L)m[X,M-1:K[X-1]]=0;write(m,1,L,,"")

Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts.

Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge.

Thanks to @dylnan for pointing out a bug.

Thanks to @rturnbull for the scan approach, dropping 2 bytes.

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

R, 221 217239 bytes

function(s){K=table(el(strsplit(gsub(" ","",s),"")))
L=sum(K|1)+1
M=(M=max(K))+-M%%5+1
m=matrix(" ",L+2L,M)
m[1m[2:L+2L,M]=names(K)
m[1,M-g]=g=cg]=paste0(g<-c(1,seq(5,M,5))
m[2,M-g]=""-")
m[1,]=format(m[1,],j="r")
for(X in 12:L)m[X+2m[X,M-1:K[X]]="X"K[X-1]]="X"
write(m,1,L+2L,,"")}

Try it online!Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts.

Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge.

Thanks to @dylnan for pointing out a bug.

R, 221 217 bytes

function(s){K=table(el(strsplit(gsub(" ","",s),"")))
L=sum(K|1)
M=(M=max(K))+-M%%5+1
m=matrix(" ",L+2,M)
m[1:L+2,M]=names(K)
m[1,M-g]=g=c(1,seq(5,M,5))
m[2,M-g]="-"
for(X in 1:L)m[X+2,M-1:K[X]]="X"
write(m,1,L+2,,"")}

Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts.

Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge.

R, 239 bytes

function(s){K=table(el(strsplit(gsub(" ","",s),"")))
L=sum(K|1)+1
M=(M=max(K))+-M%%5+1
m=matrix(" ",L,M)
m[2:L,M]=names(K)
m[1,M-g]=paste0(g<-c(1,seq(5,M,5)),"-")
m[1,]=format(m[1,],j="r")
for(X in 2:L)m[X,M-1:K[X-1]]="X"
write(m,1,L,,"")}

Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts.

Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge.

Thanks to @dylnan for pointing out a bug.

Post Deleted by Giuseppe
added 50 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 221221 217 bytes

function(s){s=elK=table(el(strsplit(gsub(" ","",s),""))
K=table(s)
L=sum(K|1)
M=(M=max(K))+-M%%5+1
m=matrix(" ",L+2,M)
m[1:L+2,M]=names(K)
m[1,M-g]=g=c(1,seq(5,M,5))
m[2,M-g]="-"
for(X in 1:L)m[X+2,M-1:K[X]]="X"
write(m,1,L+2,,"")}

Try it online!Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts. 

Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge.

R, 221 bytes

function(s){s=el(strsplit(gsub(" ","",s),""))
K=table(s)
L=sum(K|1)
M=(M=max(K))+-M%%5+1
m=matrix(" ",L+2,M)
m[1:L+2,M]=names(K)
m[1,M-g]=g=c(1,seq(5,M,5))
m[2,M-g]="-"
for(X in 1:L)m[X+2,M-1:K[X]]="X"
write(m,1,L+2,,"")}

Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts. Everything else is just ensuring the offsets are right for printing.

R, 221 217 bytes

function(s){K=table(el(strsplit(gsub(" ","",s),"")))
L=sum(K|1)
M=(M=max(K))+-M%%5+1
m=matrix(" ",L+2,M)
m[1:L+2,M]=names(K)
m[1,M-g]=g=c(1,seq(5,M,5))
m[2,M-g]="-"
for(X in 1:L)m[X+2,M-1:K[X]]="X"
write(m,1,L+2,,"")}

Try it online!

table does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts. 

Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge.

Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105
Loading