Inspired by last week's APL lesson.
Given an uppercase 2D seat map and a 1D list of customers, return the seat map and the customer list but modified as follows (to indicate occupied seats and seated customers):
For each unique letter in the input passenger list, lowercase that many (or all, if there are not enough) of that letter in the seat map, going left-to-right, top-to-bottom.
For each unique letter in the seat map, lowercase that many (or all, if there are not enough) of that letter in the passenger list, going left-to-right.
- The input seat map only contains spaces and uppercase letters from the set {
F
,B
,P
,E
}, and may be:- separated into rows by line breaks
- a list of strings
- a matrix of uppercase characters
- in any other comparable format
- The input customer list only contains uppercase letters from the set {
F
,B
,P
,E
} and may be:- a string
- a list of characters
- in any other comparable format
- The returned seat map must be identical to the input one, except that zero or more letters have been folded to lowercase
- The returned customer list must be identical to the input one, except that zero or more letters have been folded to lowercase
- Leading and trailing whitespace is allowed
Examples (shortened editions of United's aircraft)
ERJ145
Seat map input:
P
E
E PP
E EE
E EE
E EE
E EE
P PP
E EE
E EE
E EE
Passenger list input:
FFEEEEEEEEEEEEEEEE
Seat map output:
P
e
e PP
e ee
e ee
e ee
e ee
P PP
e eE
E EE
E EE
Passenger list output:
FFeeeeeeeeeeeeeeee
CRJ700
Seat map input:
F FF
F FF
PP PP
PP PP
PP PP
EE EE
PP PP
EE EE
EE EE
EE EE
Customer list input:
FFFFFFFFPPEEEEEEEEEEEEEEEEEEEEE
Seat map output:
f ff
f ff
pp PP
PP PP
PP PP
ee ee
PP PP
ee ee
ee ee
ee ee
Customer list output:
ffffffFFppeeeeeeeeeeeeeeeeEEEEE
B757
Seat map input:
F F F F
F F F F
F F F F
PPP
PPP PPP
PPP PPP
PPP PPP
EEE EEE
EEE EEE
PPP PPP
EEE EEE
EEE EEE
EEE
EEE EEE
EEE EEE
EEE EEE
EEE
Passenger list input:
FEEEEEEEEFEEEFEEEEEEEEFEEFFEEFEFFFEE
Seat map output:
f f f f
f f f f
f f F F
PPP
PPP PPP
PPP PPP
PPP PPP
eee eee
eee eee
PPP PPP
eee eee
eee eee
eeE
EEE EEE
EEE EEE
EEE EEE
EEE
Passenger list output:
feeeeeeeefeeefeeeeeeeefeeffeefefffee
B767
Seat map input:
F F F
F F F
BB B B BB
BB B B BB
BB B B BB
PP BB
PP
PP PPP PP
PP PPP PP
PP PPP PP
PP PPP PP
PP EEE PP
EE EEE EE
EE EEE EE
EE EEE EE
EE EEE EE
EE EEE EE
Passenger list input:
PPFEFEEEEEEEBBEEFFPEBPEBBEEFEEEFEEEEEEFPEEEPB
Seat map output:
f f f
f f f
bb b b bb
BB B B BB
BB B B BB
pp BB
pp
pp PPP PP
PP PPP PP
PP PPP PP
PP PPP PP
PP eee PP
ee eee ee
ee eee ee
ee eee ee
ee EEE EE
EE EEE EE
Passenger list output:
ppfefeeeeeeebbeeffpebpebbeefeeefeeeeeeFpeeepb