Skip to content

Commit a0c1bfc

Browse files
committed
completed list-1 problems
1 parent c2ce0ee commit a0c1bfc

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

Solutions/list-1/has23.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Given an int array length 2, return
2+
# True if it contains a 2 or a 3.
3+
4+
# has23([2, 5]) → True
5+
# has23([4, 3]) → True
6+
# has23([4, 5]) → False
7+
8+
9+
def has23(nums):
10+
return 2 in nums or 3 in nums

Solutions/list-1/make_ends.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Given an array of ints, return a new array length 2 containing
2+
# the first and last elements from the original array.
3+
# The original array will be length 1 or more.
4+
5+
# make_ends([1, 2, 3]) → [1, 3]
6+
# make_ends([1, 2, 3, 4]) → [1, 4]
7+
# make_ends([7, 4, 6, 2]) → [7, 2]
8+
9+
10+
def make_ends(nums):
11+
return [nums[0], nums[-1]]

Solutions/list-1/middle_way.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Given 2 int arrays, a and b, each length 3, return a new
2+
# array length 2 containing their middle elements.
3+
4+
# middle_way([1, 2, 3], [4, 5, 6]) → [2, 5]
5+
# middle_way([7, 7, 7], [3, 8, 0]) → [7, 8]
6+
# middle_way([5, 2, 9], [1, 4, 5]) → [2, 4]
7+
8+
9+
def middle_way(a, b):
10+
return [a[1], b[1]]

0 commit comments

Comments
 (0)