Arrays Problem Set 4

Array.10 Middle Way

Given 2 int arrays, a and b, each length 3, return a new array length 2 containing their middle elements.

Test Case
Input A Input B
Program Output
1 {1, 2, 3} {4, 5, 6} {2, 5}
2 {7, 7, 7} {3, 8, 0} {7, 8}
3 {5, 2, 9} {1, 4, 5} {2, 4}

Solutions:

python

raptor

Array.11 Make Ends

Given an array of ints, return a new array length 2 containing the first and last elements from the original array. The original array will be length 1 or more.

Test Case
Input
Program Output
1 {1, 2, 3} {1, 3}
2 {1, 2, 3, 4} {1, 4}
3 {7, 4, 6, 2} {7, 2}

Solutions:

python

raptor

Array.12 Has 2,3

Given an int array length 2, return true if it contains a 2 or a 3.

Test Case
Input
Program Output
1 {2, 5} true
2 {4, 3} true
3 {4, 5} false

Solutions:

python

raptor