Your question is Number Guessing Game. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Hudson River Trading's replay harness needs a deterministic simulation of an integer guessing game. Given a hidden target and an ordered sequence of guesses, report whether each guess is closer to the target than the previous guess.
The target is an integer from 0 through 1000. The first guess receives "start". For every later guess, compare its absolute distance from the target with the previous guess's distance:
"closer" if the distance decreases."farther" if the distance increases."same" if the distances are equal."correct" when a guess equals the target, and stop processing further guesses.Implement guess_feedback(target, guesses), where target is an integer and guesses is a non-empty list of integers. Return a list of strings containing one result for each processed guess. The first result is always "start" unless the first guess is correct, in which case it is "correct".
Example 1: target = 500, guesses = [100, 300, 450, 600] produces ["start", "closer", "closer", "farther"] because the distances are 400, 200, 50, and 100.
Example 2: target = 250, guesses = [0, 500, 250, 100] produces ["start", "same", "correct"]; processing stops at the exact guess.
def guess_feedback(target, guesses):