private static string BruteForceDoor(ScanningDroid droid, IOutput output) { var allItems = droid.GetInventory(); var allSubsets = allItems.Subsets(); droid.Drop(allItems); foreach (var subset in allSubsets) { if (subset.Count == 0) { continue; } droid.Take(subset); var result = droid.Go(Direction.South); if (result is not null && result.Contains("you are ejected back to the checkpoint.") is false) { output.WriteProperty("Items Used", string.Join(", ", subset)); return(result); } droid.Drop(subset); } throw new InvalidOperationException("We can't get to the right weight!"); }