Skip to content
Related Articles
Open in App
Not now

Related Articles

Puzzle | Eliminating Virus from a Computer Network

Improve Article
Save Article
Like Article
  • Difficulty Level : Hard
  • Last Updated : 18 Jan, 2023
Improve Article
Save Article
Like Article

In a network of infinitely many computers, 650 computers got infected with certain virus. The IT support team has access to five different types of antivirus software packages (let us call them A, B, C, D and E) that can work on eliminating this virus. Each of the antivirus software packages ‘X’ can eliminate virus from Xr infected computers if there are at least Xr virus-infected computers in the network when ‘X’ is applied. But it will cause Xnew new virus-free computers in the network to be infected with the virus.

Details of the antivirus software packages are shown below:

Antivirus Software Xr Xnew
A 25 4
B 14 0
C 8 15
D 32 18
E 50 1

Any of the antivirus software packages can be used any number of times in any order. But, no two antivirus software packages can be applied simultaneously. Can the network be freed from this virus using the antivirus software packages A, B, C, D and E? If yes, what is the order of the packages and if no, why?


Observe that the antivirus software packages effectively eliminate virus from 21, 14, -7, 14, 49 respectively when they are applied on the network. (-7 implies 7 new virus-free computers got infected with virus). All these number of effective changes in the virus-infected computers give zero remainder when divided by 7.

So, no matter how many ever applied how many ever times, they will not change the remainder of the total number of virus-infected systems when divided by 7. But initially 650 infected computers are there and that is 6 modulo 7. So, after any number of usages of any of A, B, C, D, or E in any order, the remainder when the total number of infected computers in the network is divided by 7 stays to be 6 constantly.

Example: Initially 650 virus-infected computers are present. Initial remainder when divided by 7 = 6
A is applied. 25 will be virus-free but 4 new are infected. So, total 629 (650-25+4) virus-infected computers are present. Remainder when 629 is divided by 7 = 6. So, on.

In short :
  ( 650 - 7 * some_number ) % 7  = 650 % 7 -(7 * some_number)%7 = 6 - 0 = 6 

Hence , we cannot make the difference to zero in any case 

This problem and solution are based on ‘principle of invariance‘.

When things are (seemingly) changing continuously, look for what core values (though hidden) are not changing.

Note that “But, no two antivirus software packages can be applied simultaneously. ” is strictly not required. Even if we apply one or more of them simultaneously, the remainder logic remains same. But it is given to ensure that we do not need to look for minimum (A+B+…) infected computers when all of the packages are applied.

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!