internal void SolveInteractively() { initialInput = new CaseInput(commsStream.ReadSingleLineOfLongsInput()); var firstStepInput = new CaseStepInput(commsStream.ReadSingleLineOfLongsInput()); samples = new List <Sample>(); samples.Add(new Sample { Value = firstStepInput.NumberOfPassages, Weight = 1 }); knownRooms.Add(firstStepInput.RoomNumber); var maxSteps = Math.Min(initialInput.K, initialInput.N); for (int step = 1; step < maxSteps + 1; step++) { var nextAction = DetermineNextAction(step); commsStream.WriteSingleInteractiveOutput(nextAction.ToString()); var stepInput = new CaseStepInput(commsStream.ReadSingleLineOfLongsInput()); UpdateSamples(step, stepInput); } var integerGuess = CalculateFinalGuess(); commsStream.WriteSingleInteractiveOutput(CaseStepOutput.FinalGuess(integerGuess).ToString()); }
private CaseStepOutput DetermineNextAction(int step) { if (step % 2 == 1) { return(CaseStepOutput.Walk()); } else { while (knownRooms.Contains(nextTeleportRoom) && nextTeleportRoom < initialInput.N) { nextTeleportRoom++; } var nextRoom = Math.Min(nextTeleportRoom, initialInput.N); return(CaseStepOutput.Teleport(nextRoom)); } }