Last active
April 14, 2019 17:40
-
-
Save pa-ulander/cbd99a8447d890d7e14802377d15fa63 to your computer and use it in GitHub Desktop.
poc price calculation test: https://repl.it/@pa_ulander/poctest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# de här små data-sakerna låtsas vi att de | |
# kommer från en databasserver, eller cache | |
sqm_breakpoints = [ | |
100, | |
200, | |
300, | |
400, | |
500, | |
600, | |
700, | |
800, | |
900, | |
1000, | |
1100, | |
1200, | |
1300, | |
1400, | |
1500, | |
1600, | |
1700, | |
1800, | |
1900, | |
2000, | |
2500, | |
3000, | |
3500, | |
4000, | |
4500, | |
5000, | |
5500, | |
6000, | |
6500, | |
7000, | |
7500, | |
8000, | |
8500, | |
9000, | |
9500, | |
10000, | |
11000, | |
12000, | |
13000, | |
14000, | |
15000, | |
16000, | |
17000, | |
18000, | |
19000, | |
20000 | |
] | |
price_matrix = [ | |
[1099, 1375, 1499], | |
[1306, 1767, 1972], | |
[1722, 2547, 2920], | |
[2032, 3133, 3628], | |
[2342, 3720, 4338], | |
[2652, 4307, 5048], | |
[2962, 4894, 5758], | |
[3272, 5481, 6468], | |
[3582, 6068, 7178], | |
[3892, 6655, 7888], | |
[4202, 7242, 8598], | |
[4512, 7829, 9308], | |
[4822, 8416, 10018], | |
[5132, 9003, 10728], | |
[5442, 9590, 11438], | |
[5752, 10177, 12148], | |
[6062, 10764, 12858], | |
[6372, 11351, 13568], | |
[6682, 11938, 14278], | |
[6992, 12525, 14988], | |
[8542, 15434, 18534], | |
[10093, 18362, 22082], | |
[11643, 21291, 25629], | |
[13193, 24220, 29176], | |
[14743, 27149, 32723], | |
[16293, 30078, 36270], | |
[17843, 33007, 39817], | |
[19393, 35936, 43364], | |
[20943, 38865, 46911], | |
[22493, 41794, 50458], | |
[24043, 44723, 54005], | |
[25593, 47652, 57552], | |
[27143, 50581, 61099], | |
[28693, 53510, 64646], | |
[30243, 56439, 68193], | |
[31793, 59368, 71740], | |
[34901, 65220, 78864], | |
[38000, 71078, 85961], | |
[41102, 76935, 93060], | |
[44204, 82792, 100159], | |
[47306, 88649, 107258], | |
[50408, 94506, 114357], | |
[53510, 100363, 121456], | |
[56612, 106220, 128555], | |
[59714, 112077, 135654], | |
[62816, 117934, 142753], | |
] | |
do_ranges = [ | |
range(0, 101), | |
range(101, 313), | |
range(313, 367) | |
] | |
minimi_price = 772 | |
def calculate(square_meters, days_open_per_year, input_demo_music): | |
price_indexes = [] | |
price = 0 | |
if days_open_per_year < 50 and square_meters < 52: | |
return minimi_price | |
for idxx, do_bp in enumerate(do_ranges): | |
if days_open_per_year in do_bp: | |
price_indexes.append(idxx) | |
if square_meters > 20000: | |
price_indexes.append((len(sqm_breakpoints) -1)) | |
tmp = price_matrix[price_indexes[1]][price_indexes[0]] | |
x_sqs = square_meters - 20000 | |
if 0 == price_indexes[0]: | |
price = tmp + (x_sqs * 2.98) | |
elif 1 == price_indexes[0]: | |
price = tmp + (x_sqs * 6.57) | |
elif 2 == price_indexes[0]: | |
price = tmp + (x_sqs * 7.26) | |
else: | |
for idx, sqm_bp in enumerate(sqm_breakpoints): | |
if sqm_bp >= square_meters: | |
price_indexes.append(idx) | |
break | |
price = price_matrix[price_indexes[1]][price_indexes[0]] | |
if input_demo_music: | |
price = (price / 2) | |
return round(price) | |
input_m2 = int(input("ange antal kvadrameter:")) | |
input_days_open = int(input("ange antal öppetdagar:")) | |
input_demo_music = int(input("gäller licensen demonstrationsmusik? 1 = ja 0 = nej ")) | |
while input_m2 > 0: | |
print("Price: " + str(calculate(input_m2, input_days_open, input_demo_music))) | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment