"More generally, the goal is to make sure to avoid any trolley problem" - that's it. In real life you wouldn't be thinking whom to kill, you will be thinking how you can stop the trolley or get the people out without killing anyone. You will be "bending the rules" (cut ropes, etc), but that's why it's real life and not mathematics.