Skip to main content
added 35 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

Matlab, 99 bytes

Thanks to @beaker for removing 6 bytes!

Using and anonymous function:

@(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) 

Define the function and use ans to call it:

>> @(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0)))   ans =   @(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) >> ans(['Programming' 10 'Puzzles' 10 '&' 10 'Code' 10 'Golf'], 5) %% 10 is line feed   ans =   Progr ammin g Puzzl es & Code Golf 

Matlab, 99 bytes

Thanks to @beaker for removing 6 bytes!

Using and anonymous function:

@(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) 

Define the function and use ans to call it:

>> @(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) ans = @(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) >> ans(['Programming' 10 'Puzzles' 10 '&' 10 'Code' 10 'Golf'], 5) %% 10 is line feed ans = Progr ammin g Puzzl es & Code Golf 

Matlab, 99 bytes

Thanks to @beaker for removing 6 bytes!

Using and anonymous function:

@(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) 

Define the function and use ans to call it:

>> @(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0)))   ans =   @(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) >> ans(['Programming' 10 'Puzzles' 10 '&' 10 'Code' 10 'Golf'], 5) %% 10 is line feed   ans =   Progr ammin g Puzzl es & Code Golf 
added 35 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

Matlab, 9099 bytes

Thanks to @beaker for removing 6 bytes!

Using and anonymous function:

@(s,k)fliplr(char(cellfun(@fliplr,regexpstrsplit(regexprep(s,'\Ssprintf('\\S{5%i}',k),'$0\n'),'\n','split'),'un',0))) 

Define the function and use ans to call it (with the string input):

>> @(s,k)fliplr(char(cellfun(@fliplr,regexpstrsplit(regexprep(s,'\Ssprintf('\\S{5%i}',k),'$0\n'),'\n','split'),'un',0))) ans = @(s,k)fliplr(char(cellfun(@fliplr,regexpstrsplit(regexprep(s,'\Ssprintf('\\S{5%i}',k),'$0\n'),'\n','split'),'un',0))) >> ans(['Programming' 10 'Puzzles' 10 '&' 10 'Code' 10 'Golf'], 5) %% 10 is line feed ans = Progr ammin g Puzzl es & Code Golf 

Matlab, 90 bytes

Using and anonymous function:

@(s)fliplr(char(cellfun(@fliplr,regexp(regexprep(s,'\S{5}','$0\n'),'\n','split'),'un',0))) 

Define the function and use ans to call it (with the string input):

>> @(s)fliplr(char(cellfun(@fliplr,regexp(regexprep(s,'\S{5}','$0\n'),'\n','split'),'un',0))) ans = @(s)fliplr(char(cellfun(@fliplr,regexp(regexprep(s,'\S{5}','$0\n'),'\n','split'),'un',0))) >> ans(['Programming' 10 'Puzzles' 10 '&' 10 'Code' 10 'Golf']) %% 10 is line feed ans = Progr ammin g Puzzl es & Code Golf 

Matlab, 99 bytes

Thanks to @beaker for removing 6 bytes!

Using and anonymous function:

@(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) 

Define the function and use ans to call it:

>> @(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) ans = @(s,k)fliplr(char(cellfun(@fliplr,strsplit(regexprep(s,sprintf('\\S{%i}',k),'$0\n'),'\n'),'un',0))) >> ans(['Programming' 10 'Puzzles' 10 '&' 10 'Code' 10 'Golf'], 5) %% 10 is line feed ans = Progr ammin g Puzzl es & Code Golf 
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

Matlab, 90 bytes

Using and anonymous function:

@(s)fliplr(char(cellfun(@fliplr,regexp(regexprep(s,'\S{5}','$0\n'),'\n','split'),'un',0))) 

Define the function and use ans to call it (with the string input):

>> @(s)fliplr(char(cellfun(@fliplr,regexp(regexprep(s,'\S{5}','$0\n'),'\n','split'),'un',0))) ans = @(s)fliplr(char(cellfun(@fliplr,regexp(regexprep(s,'\S{5}','$0\n'),'\n','split'),'un',0))) >> ans(['Programming' 10 'Puzzles' 10 '&' 10 'Code' 10 'Golf']) %% 10 is line feed ans = Progr ammin g Puzzl es & Code Golf