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

R, 153 135135 113 bytes

function(s){S=el(strsplit,S=utf8ToInt(s,""))
S[S=="_"]=letters[1+2^{S[S==95]=2^(4:0)%*%matrix(grepl("[A-Z]",S[greplS[S%in%c("[a-zA-Z]"65:90,S)]97:122)]<95,5)]+97
cat(tolower(intToUtf8(S),sep=""))}

Try it online!Try it online!

Issues some warnings with the use of matrix but that shouldn't affect the result. Also issues warnings as [<- assignment will remove extraneous assigned objects by default.

Thanks to @JayCe for knocking off a whopping 18 bytes, by pointing out that truncating the encoded chars is unnecessary.40(!) bytes down thanks to JayCe's improvements

R, 153 135 bytes

function(s){S=el(strsplit(s,""))
S[S=="_"]=letters[1+2^(4:0)%*%matrix(grepl("[A-Z]",S[grepl("[a-zA-Z]",S)]),5)]
cat(tolower(S),sep="")}

Try it online!

Issues some warnings with the use of matrix but that shouldn't affect the result. Also issues warnings as [<- assignment will remove extraneous assigned objects by default.

Thanks to @JayCe for knocking off a whopping 18 bytes, by pointing out that truncating the encoded chars is unnecessary.

R, 153 135 113 bytes

function(s,S=utf8ToInt(s)){S[S==95]=2^(4:0)%*%matrix(S[S%in%c(65:90,97:122)]<95,5)+97
cat(tolower(intToUtf8(S)))}

Try it online!

Issues some warnings with the use of matrix but that shouldn't affect the result. Also issues warnings as [<- assignment will remove extraneous assigned objects by default.

40(!) bytes down thanks to JayCe's improvements

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

R, 153153 135 bytes

function(s){S=el(strsplit(s,""))
L=S[grepl("[a-zA-Z]",S)]
S[S=="_"]=letters[1+2^(4:0)%*%matrix(grepl("[A-Z]",LS[grepl("[a-zA-Z]",S)]),5,length(L)%/%5)]
cat(tolower(S),sep="")}

Try it online!Try it online!

Issues some warnings with the use of matrix but that shouldn't affect the result. Also issues warnings as [<- assignment will remove extraneous assigned objects by default.

Thanks to @JayCe for knocking off a whopping 18 bytes, by pointing out that truncating the encoded chars is unnecessary.

R, 153 bytes

function(s){S=el(strsplit(s,""))
L=S[grepl("[a-zA-Z]",S)]
S[S=="_"]=letters[1+2^(4:0)%*%matrix(grepl("[A-Z]",L),5,length(L)%/%5)]
cat(tolower(S),sep="")}

Try it online!

Issues some warnings with the use of matrix but that shouldn't affect the result.

R, 153 135 bytes

function(s){S=el(strsplit(s,""))
S[S=="_"]=letters[1+2^(4:0)%*%matrix(grepl("[A-Z]",S[grepl("[a-zA-Z]",S)]),5)]
cat(tolower(S),sep="")}

Try it online!

Issues some warnings with the use of matrix but that shouldn't affect the result. Also issues warnings as [<- assignment will remove extraneous assigned objects by default.

Thanks to @JayCe for knocking off a whopping 18 bytes, by pointing out that truncating the encoded chars is unnecessary.

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

R, 153 bytes

function(s){S=el(strsplit(s,""))
L=S[grepl("[a-zA-Z]",S)]
S[S=="_"]=letters[1+2^(4:0)%*%matrix(grepl("[A-Z]",L),5,length(L)%/%5)]
cat(tolower(S),sep="")}

Try it online!

Issues some warnings with the use of matrix but that shouldn't affect the result.