Skip to main content
Commonmark migration
Source Link

##Java, 132 103 100 bytes

Java, 132 103 100 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes! Also Olivier Grégoire for 3 bytes!

char[]c(char[]s,int l){for(int o=l;o-->0;)if(o%2>0){char t=s[o];s[o]=s[l+o+1];s[l+o+1]=t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

##Java, 132 103 100 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes! Also Olivier Grégoire for 3 bytes!

char[]c(char[]s,int l){for(int o=l;o-->0;)if(o%2>0){char t=s[o];s[o]=s[l+o+1];s[l+o+1]=t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

Java, 132 103 100 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes! Also Olivier Grégoire for 3 bytes!

char[]c(char[]s,int l){for(int o=l;o-->0;)if(o%2>0){char t=s[o];s[o]=s[l+o+1];s[l+o+1]=t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

deleted 1 character in body
Source Link
Hypino
  • 221
  • 1
  • 6

##Java, 132 103 102100 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes! Also Olivier Grégoire for 1 byte3 bytes!

char[]ichar[]c(char[]s,int l){char t;forfor(int o=l;o-->0;)if(l%2>0o%2>0){t=s[l];s[l]=s[l+o+1];s[l+o+1]=t;char t=s[o];s[o]=s[l+o+1];s[l+o+1]=t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

##Java, 132 103 102 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes! Also Olivier Grégoire for 1 byte!

char[]i(char[]s,int l){char t;for(int o=l;o-->0;)if(l%2>0){t=s[l];s[l]=s[l+o+1];s[l+o+1]=t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

##Java, 132 103 100 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes! Also Olivier Grégoire for 3 bytes!

char[]c(char[]s,int l){for(int o=l;o-->0;)if(o%2>0){char t=s[o];s[o]=s[l+o+1];s[l+o+1]=t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

added 54 characters in body
Source Link
Hypino
  • 221
  • 1
  • 6

##Java, 132 103103 102 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes! Also Olivier Grégoire for 1 byte!

char[]cchar[]i(char[]s,int l){forchar t;for(int o=l,t;oo=l;o-->0;)if(l%2>0){t=s[l];s[l]=s[l+o+1];s[l+o+1]=(char)t;t=s[l];s[l]=s[l+o+1];s[l+o+1]=t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

##Java, 132 103 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes!

char[]c(char[]s,int l){for(int o=l,t;o-->0;)if(l%2>0){t=s[l];s[l]=s[l+o+1];s[l+o+1]=(char)t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

##Java, 132 103 102 bytes

Thanks to Kevin Cruijssen for suggesting returning the array (among other improvements) and saving 29 bytes! Also Olivier Grégoire for 1 byte!

char[]i(char[]s,int l){char t;for(int o=l;o-->0;)if(l%2>0){t=s[l];s[l]=s[l+o+1];s[l+o+1]=t;}return s;} 

Called like this:

public static void main(String[] args) { System.out.println(c("Hello,world!".toCharArray(), 5)); // 5 is the length of each "String" } 

Output:

Hollo,werld!

Takes advantage of the fact that input can basically be formatted in any way (in this case, a single char array of Strings that are delimited by a comma), and pretty lenient output rules as well.

deleted 2 characters in body
Source Link
Hypino
  • 221
  • 1
  • 6
Loading
added 82 characters in body
Source Link
Hypino
  • 221
  • 1
  • 6
Loading
deleted 5 characters in body
Source Link
Hypino
  • 221
  • 1
  • 6
Loading
Source Link
Hypino
  • 221
  • 1
  • 6
Loading