Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An e - commerce company is currently celebrating ten years in business. They are having a sale to honor their privileged members, those who have

An e
-
commerce company is currently celebrating ten years in business. They are having a sale to honor their privileged members, those who have been using their services for the past five years.
They receive the best discounts indicated by any discount tags attached to the product. Determine the minimum cost to purchase all products listed.
As each potential price is calculated, round it to the nearest integer before adding it to the total. Return the cost to purchase all items as an integer.
There are three types of discount tags:
Type
0
: discounted price, the item is sold for a given price.
Type
1
: percentage discount, the customer is given a fixed percentage discount from the retail price.
Type
2
: fixed discount, the customer is given Example
products
=
I
'10
; do; d
11
,
['15
; 'EMPTY, 'EMPTY
]
,
['20
,
d
1
; 'EMPTY
]]
discounts
=
[[
d
0
;
1
;
27]
,
[
d
1
;
'2
;
51]
3
The products array elements are in the form
['
price
,
'tag
1'
;
,
'tag
2'
,
.
.
,
tag m
-
1']
.
There may be zero or more discount codes associated with a product. Discount tags in the products array may be 'EMPTY which is the same as a null value. The discounts array elements are in the form
['
tag;
'type', 'amount'
]
.
a fixed amount off from the retail price.STDIN
Function
products
[]
size n
=
2
3
products
[1]
size m
=
3
10
sale january
-
sale
products
=
[['10'
,
'sale', 'january
-
sale'
1
,
['200'
,
'sale', 'EMPTY'
]]
200
sale EMPTY
2
discounts
[]
size d
=
2
3
discounts
|
j
]
size
=
3(
always
)
sale
010
discounts
=
[
l
'
sale
'
,
'0'
,
'10']
,
['
january
-
sale',
'1'
,
'10'11
january
-
sale
110
Sample Output
0
19
python code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions