diff --git a/gas.py b/gas.py deleted file mode 100644 index 2776200e..00000000 --- a/gas.py +++ /dev/null @@ -1,106 +0,0 @@ -import re -from collections import defaultdict - -def process_gas_consumption(input_text): - # Regular expression to match the log line format - pattern = r'Contract (\w+) - Gas left (\d+)' - - # Dictionary to store the initial gas left value for each contract - initial_gas_left = {} - - # Dictionary to store the cumulative gas consumption for each contract - gas_consumption = defaultdict(list) - - # Process each line - for line in input_text.strip().split('\n'): - match = re.search(pattern, line) - if match: - contract = match.group(1) - current_gas = int(match.group(2)) - - if contract not in initial_gas_left: - # Set the initial gas value for this contract - initial_gas_left[contract] = current_gas - - # Calculate cumulative gas consumed for this contract - gas_consumed = initial_gas_left[contract] - current_gas - gas_consumption[contract].append(gas_consumed) - - return dict(gas_consumption) - -# Example usage -input_text = """ -Contract 562824648592572320847590478409708627183864037263 - Gas left 99943880 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99943877 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99943874 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99943871 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99943868 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99941262 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99941259 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99941256 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99941253 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99941250 -Contract 775825949159984944649286309097944276303872193968 - Gas left 98316661 -Contract 775825949159984944649286309097944276303872193968 - Gas left 98316658 -Contract 775825949159984944649286309097944276303872193968 - Gas left 98316655 -Contract 775825949159984944649286309097944276303872193968 - Gas left 98316652 -Contract 775825949159984944649286309097944276303872193968 - Gas left 98316649 -Contract 775825949159984944649286309097944276303872193968 - Gas left 98316646 -Contract 775825949159984944649286309097944276303872193968 - Gas left 98316637 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99875018 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99875015 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99852915 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99852912 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99852812 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99852809 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99830709 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99830706 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99830606 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99830603 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808503 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808500 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808497 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808494 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808491 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808488 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808485 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808482 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808479 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808476 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99808474 -Contract 775825949159984944649286309097944276303872193968 - Gas left 30000000 -Contract 775825949159984944649286309097944276303872193968 - Gas left 29999997 -Contract 775825949159984944649286309097944276303872193968 - Gas left 29999995 -Contract 775825949159984944649286309097944276303872193968 - Gas left 29997895 -Contract 775825949159984944649286309097944276303872193968 - Gas left 29997892 -Contract 775825949159984944649286309097944276303872193968 - Gas left 29997890 -Contract 775825949159984944649286309097944276303872193968 - Gas left 29977890 -Contract 775825949159984944649286309097944276303872193968 - Gas left 29977887 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99778661 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99778658 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99756558 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99756555 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99756455 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99756452 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99754252 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99754249 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99754149 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99754146 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99732046 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99732043 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99731943 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99731940 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99709840 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99709837 -Contract 562824648592572320847590478409708627183864037263 - Gas left 99709834 -""" - -result = process_gas_consumption(input_text) - -print("Cumulative gas consumption by contract:") -for contract, consumption in result.items(): - print(f"Contract 0x{contract}:") - for i, gas in enumerate(consumption, 1): - print(f" Operation {i}: {gas} cumulative gas used") - print(f" Total gas used: {consumption[-1]}") - print()