Movatterモバイル変換


[0]ホーム

URL:


Sorry, we no longer support your browser
Please upgrade toMicrosoft Edge,Google Chrome, orFirefox. Learn more about ourbrowser support.
Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities includingStack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Loading…
Code Golf

Return to Answer

added 658 characters in body
pajonk
  • 19.4k
  • 5
  • 29
  • 78

R, 43 bytes

\(s)nchar(gsub("(:)|[^ij.;!?]","\\1\\1",s))

Attempt This Online!

Port of@doubleunary's Google Sheets answer.


R,48 44 bytes

Edit: -4 bytes porting@Luis Mendo's MATL answer.

\(s)sum(outer(utf8ToInt("ij.;!?::"),s,`==`))

Attempt This Online!

Takes input as a vector of character codes.

R,48 44 bytes

Edit: -4 bytes porting@Luis Mendo's MATL answer.

\(s)sum(outer(utf8ToInt("ij.;!?::"),s,`==`))

Attempt This Online!

R, 43 bytes

\(s)nchar(gsub("(:)|[^ij.;!?]","\\1\\1",s))

Attempt This Online!

Port of@doubleunary's Google Sheets answer.


R,48 44 bytes

Edit: -4 bytes porting@Luis Mendo's MATL answer.

\(s)sum(outer(utf8ToInt("ij.;!?::"),s,`==`))

Attempt This Online!

Takes input as a vector of character codes.

added 29 characters in body
pajonk
  • 19.4k
  • 5
  • 29
  • 78

R,4848 44 bytes

Edit: -4 bytes porting@Luis Mendo's MATL answer.

\(s,`[`=gsub)ncharsum(":"["x2","[^ijouter(utf8ToInt("ij.;!?:]"["":"),s]]s,`==`))

Attempt This Online!

Slightly ungolfed (+1 byte):\(s)nchar(gsub(":","x2",gsub("[^ij.;!?:]","",s)))Attempt This Online!

R,48 bytes

\(s,`[`=gsub)nchar(":"["x2","[^ij.;!?:]"["",s]])

Attempt This Online!

Slightly ungolfed (+1 byte):\(s)nchar(gsub(":","x2",gsub("[^ij.;!?:]","",s)))

R,48 44 bytes

Edit: -4 bytes porting@Luis Mendo's MATL answer.

\(s)sum(outer(utf8ToInt("ij.;!?::"),s,`==`))

Attempt This Online!

pajonk
  • 19.4k
  • 5
  • 29
  • 78

R, 48 bytes

\(s,`[`=gsub)nchar(":"["x2","[^ij.;!?:]"["",s]])

Attempt This Online!

Slightly ungolfed (+1 byte):\(s)nchar(gsub(":","x2",gsub("[^ij.;!?:]","",s)))


[8]ページ先頭

©2009-2025 Movatter.jp