Interactive tasks are tasks where your code interacts with another program, often called a grader, rather than simply reading input and printing output. Due to this novel format, people are often scared off and avoid attempting these problems. My goal in this blog is to remove your fear towards interactive tasks.

## Example

Let's start with a basic example, Guess the Number, which you can view in more detail here.

There is some hidden number and you have to interactively guess it. The hidden number is always an integer from 1 to 1000000.

You can make queries to the grader. Each query is an integer from 1 to 1000000. There are two different responses the grader can provide:
• "<" (without quotes), if the hidden number is less than the integer in your query,
• ">=" (without quotes), if the hidden number is greater than or equal to the integer in your query.
When your program wants to guess the hidden number, print "! x" (without quotes), where x is the answer.

Your program is allowed to make at most 25 queries (not including printing the answer)

This is a classic problem which can be solved using binary search (which you can read about here if you're not familiar). Here is some C code which solves the problem.