<s> """<STR_LIT>""" <EOL> from collections import namedtuple <EOL> Customer = namedtuple ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class LineItem : <EOL> def __init__ ( self , product , quantity , price ) : <EOL> self . product = product <EOL> self . quantity = quantity <EOL> self . price = price <EOL> def total ( self ) : <EOL> return self . price * self . quantity <EOL> class Order : <EOL> def __init__ ( self , customer , cart , promotion = None ) : <EOL> self . customer = customer <EOL> self . cart = list ( cart ) <EOL> self . promotion = promotion <EOL> def total ( self ) : <EOL> if not hasattr ( self , '<STR_LIT>' ) : <EOL> self . __total = sum ( item . total ( ) for item in self . cart ) <EOL> return self . __total <EOL> def due ( self ) : <EOL> if self . promotion is None : <EOL> discount = <NUM_LIT:0> <EOL> else : <EOL> discount = self . promotion ( self ) <EOL> return self . total ( ) - discount <EOL> def __repr__ ( self ) : <EOL> fmt = '<STR_LIT>' <EOL> return fmt . format ( self . total ( ) , self . due ( ) ) <EOL> def fidelity_promo ( order ) : <EOL> """<STR_LIT>""" <EOL> return order . total ( ) * <NUM_LIT> if order . customer . fidelity >= <NUM_LIT:1000> else <NUM_LIT:0> <EOL> def bulk_item_promo ( order ) : <EOL> """<STR_LIT>""" <EOL> discount = <NUM_LIT:0> <EOL> for item in order . cart : <EOL> if item . quantity >= <NUM_LIT:20> : <EOL> discount += item . total ( ) * <NUM_LIT> <EOL> return discount <EOL> def large_order_promo ( order ) : <EOL> """<STR_LIT>""" <EOL> distinct_items = { item . product for item in order . cart } <EOL> if len ( distinct_items ) >= <NUM_LIT:10> : <EOL> return order . total ( ) * <NUM_LIT> <EOL> return <NUM_LIT:0> <EOL> promos = [ globals ( ) [ name ] for name in globals ( ) <EOL> if name . endswith ( '<STR_LIT>' ) <EOL> and name != '<STR_LIT>' ] <EOL> def best_promo ( order ) : <EOL> """<STR_LIT>""" <EOL> return max ( promo ( order ) for promo in promos ) </s>
