diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-07 00:41:25 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-07 00:41:25 +0200 |
commit | 2d1901b31ce57551343dc8a24408dfcc433bc435 (patch) | |
tree | eee2960b815ebab7039e4c17b97549d0758f6c73 | |
parent | bdedded1628b3544118e5c692447a8c52d7b6e62 (diff) | |
download | problemF-2d1901b31ce57551343dc8a24408dfcc433bc435.tar.xz problemF-2d1901b31ce57551343dc8a24408dfcc433bc435.zip |
Add simple POC
Diffstat (limited to '')
-rw-r--r-- | POC/poc.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/POC/poc.py b/POC/poc.py new file mode 100644 index 0000000..e2b8af7 --- /dev/null +++ b/POC/poc.py @@ -0,0 +1,52 @@ +#!/usr/bin/python3 + +file = open("../input.txt", "r") + +story_table = [] +stories_table = [] +nb_machines = 0 +loop_number = 0 + +for line in file: + + line_table = list(map(int, line.split())) + keys_line_table_story = ['machines', 'money', 'time'] + keys_line_table_machines = ['day_sell', 'buy_price', 'resale_price', 'day_profit'] + l = list() + for a in range(0, len(line_table)): + l.append((line_table[a])) + if len(line_table) == 3: + line_table = dict(zip(keys_line_table_story,l)) + else: + line_table = dict(zip(keys_line_table_machines,l)) + + if len(line_table) == 3: + nb_machines = line_table["machines"] + if loop_number > 0: + stories_table.append(story_table) + story_table = [] + + story_table.append(line_table) + + loop_number += 1 + +case = 1 +for story in stories_table: + settings = story[0] + current_money = settings["money"] + machines_bought = [] + + for day in range(0, settings["time"]+1): + for machines in machines_bought: + current_money += machines["day_profit"] + buyable_machines = [] + for machine_number in range(1, settings["machines"]+1): + if day == story[machine_number]["day_sell"]: + buyable_machines.append(story[machine_number]) + for machines in buyable_machines: + if machines["buy_price"] <= current_money: + machines_bought.append(machines) + current_money -= machines["buy_price"] + + print("Case "+ str(case) + ": " + str(current_money)) + case += 1 |