You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On November 2nd, 1988, the first major internet worm was released, infecting about 10% of computers connected to the internet after only a day.
4
+
5
+
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:
6
+
7
+
On day 0, the first computer is infected.
8
+
Each subsequent day, the number of infected computers doubles.
9
+
Every 3rd day, a patch is applied after the virus spreads and reduces the number of infected computers by 20%. Round the number of patched computers up to the nearest whole number.
10
+
For example, on:
11
+
12
+
Day 0: 1 total computer is infected.
13
+
Day 1: 2 total computers are infected.
14
+
Day 2: 4 total computers are infected.
15
+
Day 3: 8 total computers are infected. Then, apply the patch: 8 infected * 20% = 1.6 patched. Round 1.6 up to 2. 8 computers infected - 2 patched = 6 total computers infected after day 3.
16
+
Return the number of total infected computers after the given amount of days have passed.
0 commit comments