Skip to content

Instantly share code, notes, and snippets.

@janosgyerik
Last active December 14, 2015 01:08
Show Gist options
  • Save janosgyerik/5003505 to your computer and use it in GitHub Desktop.
Save janosgyerik/5003505 to your computer and use it in GitHub Desktop.
List partitioner test

  • Write a partition method that takes a list and size parameters and returns a list of sublists, where each sublist has at most size elements.

    Example inputs and outputs:

    • Example 1: partition([1,2,3,4,5], 2) returns: [ [1,2], [3,4], [5] ]
    • Example 2: partition([1,2,3,4,5], 3) returns: [ [1,2,3], [4,5] ]
    • Example 3: partition([1,2,3,4,5], 1) returns: [ [1], [2], [3], [4], [5] ]
  • Write unit tests using JUnit4 to verify your implementation.

Important: Assume that your implementation will be part of a library used by many applications (in production).


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment