curriculum/challenges/english/blocks/daily-coding-challenges-python/68e39ed6106dac2f0a98fd66.md
On November 2nd, 1988, the first major internet worm was released, infecting about 10% of computers connected to the internet after only a day.
In this challenge, you are given a number of days that have passed since an internet worm was released, and you need to determine how many computers are infected using the following rules:
For example, on:
Return the number of total infected computers after the given amount of days have passed.
infected(1) should return 2.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(infected(1), 2)`)
}})
infected(3) should return 6.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(infected(3), 6)`)
}})
infected(8) should return 152.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(infected(8), 152)`)
}})
infected(17) should return 39808.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(infected(17), 39808)`)
}})
infected(25) should return 5217638.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(infected(25), 5217638)`)
}})
def infected(days):
return days
import math
def infected(days):
infected = 1
for day in range(1, days + 1):
infected *= 2
if day % 3 == 0:
patched = math.ceil(infected * 0.2)
infected -= patched
return infected