Last active
August 29, 2015 14:12
-
-
Save Todd-Davies/af119fe01a81f30a4bbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class part1c { | |
public static char[] shift(char[] input, int shiftNum) { | |
char[] firstHalf = Arrays.copyOfRange(input, 0, shiftNum); | |
char[] secondHalf = Arrays.copyOfRange(input, shiftNum, input.length); | |
for(int i = 0; i < (input.length - shiftNum); i++) { | |
input[i] = secondHalf[i]; | |
} | |
for(int i = (input.length - shiftNum); i < input.length; i++) { | |
input[i] = firstHalf[i - (input.length - shiftNum)]; | |
} | |
return input; | |
} | |
public static void main(String[] args) { | |
char[] arr = {'a','b','c','d','e','f','g'}; | |
System.out.println(shift(arr, 3)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment