subtree(users/wpcarro): docking briefcase at '24f5a642'
git-subtree-dir: users/wpcarro git-subtree-mainline:464bbcb15cgit-subtree-split:24f5a642afChange-Id: I6105b3762b79126b3488359c95978cadb3efa789
This commit is contained in:
commit
019f8fd211
766 changed files with 175420 additions and 0 deletions
19
users/wpcarro/scratch/facebook/cafe-order-checker.py
Normal file
19
users/wpcarro/scratch/facebook/cafe-order-checker.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
def orders_are_sorted(take_out, dine_in, audit):
|
||||
if len(take_out) + len(dine_in) != len(audit):
|
||||
return False
|
||||
|
||||
i, j = 0, 0
|
||||
for x in audit:
|
||||
if i < len(take_out) and take_out[i] == x:
|
||||
i += 1
|
||||
elif j < len(dine_in) and dine_in[j] == x:
|
||||
j += 1
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
assert orders_are_sorted([1,3,5], [2,4,6], [1,2,4,3,6,5])
|
||||
assert not orders_are_sorted([1,3,5], [2,4,6], [1,2,4,5,6,3])
|
||||
assert orders_are_sorted([], [2,4,6], [2,4,6])
|
||||
print("Success!")
|
||||
Loading…
Add table
Add a link
Reference in a new issue