-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplay.py
More file actions
45 lines (28 loc) · 655 Bytes
/
play.py
File metadata and controls
45 lines (28 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
#
#
#
# Kim Brugger contact: kim@brugger.dk
import sys
import pprint
import re
import os
pp = pprint.PrettyPrinter(indent=4)
def merge_int_arrays( a1, a2):
a1 = sorted( a1, key = int )
a2 = sorted( a2, key = int )
pp.pprint( a1 )
pp.pprint( a2 )
merged_array = []
while ( len (a1) or len( a2 ) ):
if ( len (a1) and len( a2 )):
if ( a1[ 0 ] < a2 [ 0 ]):
merged_array.append( a1.pop(0))
else:
merged_array.append( a2.pop(0))
elif( len( a1 )):
merged_array.append( a1.pop(0))
else:
merged_array.append( a2.pop(0))
return merged_array
pp.pprint( merge_int_arrays( [1,3,4,5], [2,9,5,10,6]))