Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
1.12/5 (5 votes)
See more:
The Virus

There is an isolated sector of 1MB which has been infected by a virus. An antivirus program can clean the data of that sector at a rate of 5 kbits in 2^-7 seconds. The behavior of the virus is to replicate itself by 2.5 times per second. (i.e infection of 1KB in a sector will become 2.5KB in 2.5 seconds)

The return type should be an array.
VirusGuard(8*1024*1024,5.12*1024*1000,2.5) should equal to 3.625

What I have tried:

function VirusGuard(sectorzies,cleanrate,replicationrate) {
  var result = [];
  return result;

Updated 25-Feb-23 15:17pm

1 solution

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
Share this answer
Ayesha Madavi 25-Feb-23 21:12pm    
function VirusGuard(sectorSize, cleaningRate, virusReplicationRate) {
const infectedData = sectorSize / 1024; // convert sector size to KB
const virusSpreadTime = 2.5 * Math.log2(infectedData) / Math.log2(2.5);
const cleanedData = cleaningRate * virusSpreadTime;
const timeToClean = sectorSize / cleanedData;
return [timeToClean];

console.log(VirusGuard(8*1024*1024,5.12*1024*1000,2.5)); // output: [3.625]

this is the code that I generated, I can't think what Should I change
OriginalGriff 26-Feb-23 0:33am    
What does it do that you didn't expect, or not do that you did?
What have you tried to do to find out why?
Are there any error messages, and if so, where and when? What did you do to make them happen?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900