diff --git a/python/meltdown-mitigation/conditionals.py b/python/meltdown-mitigation/conditionals.py index 1eb0a57..32bd5db 100644 --- a/python/meltdown-mitigation/conditionals.py +++ b/python/meltdown-mitigation/conditionals.py @@ -14,7 +14,7 @@ def is_criticality_balanced(temperature, neutrons_emitted): - The product of temperature and neutrons emitted per second is less than 500000. """ - pass + return temperature < 800 and neutrons_emitted > 500 and (temperature * neutrons_emitted) < 500000 def reactor_efficiency(voltage, current, theoretical_max_power): @@ -37,7 +37,17 @@ def reactor_efficiency(voltage, current, theoretical_max_power): where generated power = voltage * current """ - pass + generated_power = voltage * current + percentage = (generated_power / theoretical_max_power) * 100 + + if percentage >= 80: + return 'green' + if percentage >= 60: + return 'orange' + if percentage >= 30: + return 'red' + + return 'black' def fail_safe(temperature, neutrons_produced_per_second, threshold): @@ -53,4 +63,13 @@ def fail_safe(temperature, neutrons_produced_per_second, threshold): 3. 'DANGER' -> `temperature * neutrons per second` is not in the above-stated ranges """ - pass + low_threshold = 90/100 * threshold + high_threshold = ((10/100)+(100/100)) * threshold + value = temperature * neutrons_produced_per_second + + if value <= low_threshold: + return 'LOW' + if value >= low_threshold and value <= high_threshold: + return 'NORMAL' + + return 'DANGER'