Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
asd
# change 50 to the price of your cart price = 10.00 from random import randint # to update with new coupons search codes on community wiki # in the below list all X off Y+ purchases with their 4 digit codes # (x, y) refers to an $X off $Y+ purchase # (x, 0) refers to a x% off entire pruchase CODES = { (10, 50) : "1530" ,(20, 100) : "2525" ,(10, 0): "2377" } # define coupons def applycoupon(i, j, price): """apply coupons""" price = 1.0*price if (i, j) in CODES: if j==0: return (1-(i/100.0))*price, CODES[(i, j)] elif price >= j: return price - i, CODES[(i, j)] else: return price, CODES[(i, j)] else: return price, "code not in dict" def min_price_w_coupon(cartprice): """check the best coupon to apply to a cart""" p_w_coupon = cartprice code = "no applicable coupon" for key in CODES: i = key[0] j = key[1] test_coup = applycoupon(i, j, cartprice) test_coup_price = test_coup[0] test_coup_code = test_coup[1] if test_coup_price < p_w_coupon: p_w_coupon = test_coup_price code = test_coup_code return p_w_coupon, code def addcheckdigit(stuff): checkdigit = 0 for j in range(14): if j % 2 == 0: checkdigit += int(stuff[j]) else: checkdigit += int(stuff[j]) * 3 print(str(stuff) ) + str((10 -(checkdigit % 10))%10) def coupon_generator(price): if min_price_w_coupon(price)[1] == "no applicable coupon" or min_price_w_coupon(price)[1] == "code not in dict": print("no applicable coupon") else: for j in range(12500): i = randint(0, 9999) addcheckdigit("471525" + "%04d" % i + min_price_w_coupon(price)[1]) coupon_generator(price)
run
|
edit
|
history
|
help
0
Array Example
irctcbot
tes umur
PyPartial
Shabnam_ticket
сщые
Decimal to Binary
my first code
Dictionary - convert to lowercase
gameboy