Skip to main content
added 53 characters in body
Source Link
J.Doe
  • 2.7k
  • 12
  • 15

R, 86 85 bytes

Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.

-1 bytes by stealing @GB's Ruby solution'sRuby solution's translation strings - upvote it!

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr('zb-yadehinotu','b-zefijopuva',s)) 

Try it online!

R, 86 85 bytes

Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.

-1 bytes by stealing @GB's Ruby solution's translation strings - upvote it!

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr('zb-yadehinotu','b-zefijopuva',s)) 

Try it online!

R, 86 85 bytes

Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.

-1 bytes by stealing @GB's Ruby solution's translation strings - upvote it!

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr('zb-yadehinotu','b-zefijopuva',s)) 

Try it online!

added 88 characters in body
Source Link
J.Doe
  • 2.7k
  • 12
  • 15

R, 8686 85 bytes

Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.

-1 bytes by stealing @GB's Ruby solution's translation strings - upvote it!

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr("a'zb-z"yadehinotu',"ecdfighjok-npuq-tvaw'b-zb"zefijopuva',s)) 

Try it online!Try it online!

R, 86 bytes

Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr("a-z","ecdfighjok-npuq-tvaw-zb",s)) 

Try it online!

R, 86 85 bytes

Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.

-1 bytes by stealing @GB's Ruby solution's translation strings - upvote it!

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr('zb-yadehinotu','b-zefijopuva',s)) 

Try it online!

added 40 characters in body
Source Link
J.Doe
  • 2.7k
  • 12
  • 15

R, 10186 bytes

The simpleSimple way. Now slightly less obviouschartr has the charming and useful property that it can specify letter ranges, which save a few bytes.

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr(intToUtf8(97:122)"a-z","ecdfighjoklmnpuqrstvawxyzb""ecdfighjok-npuq-tvaw-zb",s)) 

Try it online!Try it online!

R, 101 bytes

The simple way. Now slightly less obvious.

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr(intToUtf8(97:122),"ecdfighjoklmnpuqrstvawxyzb",s)) 

Try it online!

R, 86 bytes

Simple way. chartr has the charming and useful property that it can specify letter ranges, which save a few bytes.

function(s)sub("^([^aeiou])(.*)","\\2\\1ay",chartr("a-z","ecdfighjok-npuq-tvaw-zb",s)) 

Try it online!

added 19 characters in body
Source Link
J.Doe
  • 2.7k
  • 12
  • 15
Loading
deleted 8 characters in body
Source Link
J.Doe
  • 2.7k
  • 12
  • 15
Loading
Source Link
J.Doe
  • 2.7k
  • 12
  • 15
Loading