online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
import java.util.List; import java.util.ArrayList; import java.util.Arrays; public class Main { public static List<int[]> split(int[] sequence, int numberOfChunks) { int partitionSize = sequence.length / numberOfChunks; int rest = sequence.length % numberOfChunks; boolean includeRest = rest > 0 && rest <= partitionSize / 2; List<int[]> result = new ArrayList<>(); int bound = sequence.length - (includeRest ? partitionSize : 0); for(int i = 0; i < bound; i += partitionSize) { boolean isLastChunk = (i + partitionSize) >= bound; int[] chunk = Arrays.copyOfRange(sequence, i, (isLastChunk && includeRest) ? sequence.length : Math.min(sequence.length, i + partitionSize)); result.add(chunk); } return result; } public static void main(String[] args) { int[] source = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; List<int[]> chunks = split(source, 3); for(int i = 0; i < chunks.size(); i++) { System.out.println(Arrays.toString(chunks.get(i))); } } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue