In the city there was one person infected with a virus. Every day every sick person is visited by all his healthy friends, they become infected with the virus and get sick the next day. And all patients recover the next day and are immune to the virus for exactly one day.
$\cdot$Prove that the epidemic will end sometime
I don't really know how to solve this.
Consider the friendship graph of the city, with an edge between friends. On day $n$, exactly those people get infected whose shortest path in this graph to the original source has length $n$.
You can prove this by induction. It’s true on day $1$. If it’s true on day $n$, then the people at distance $n$ who were infected on day $n$ are sick on day $n+1$. They can’t infect the people at distance $n-1$ because those are immune. They can’t infect people at a distance less than $n-1$ because an edge to them would form a shorter path. They also can’t infect people at a distance greater than $n+1$ because an edge to them would form a shorter path. So the only ones they can infect are the people at distance $n+1$, and those are indeed all infected because they necessarily have friends at distance $n$.
Note that none of this required coding. All it required was to draw a small example of a friendship network and play around with it and notice how the virus keeps spreading further away from the source. I write “play around” because that’s the most important part of learning. Reading this answer may give you some ideas how problems can be solved, but deeper insight usually comes from playing around with the problems yourself and getting a feel for what happens.