Beta

COVID-19

Description:

A new virus attacks martians. They ask Earth scientists how long will pandemy last on their planet. The overall ammount of their population is Y and there are already X infected among them. Silly martians don't stick to quarantine and continue to hang out with each other, which makes it easier for the virus to spread. Every day each infected martian spreads the disease to N other healthy martians. Luckily the virus is not lethal and it takes D days for an infected martian to recover. After that he becomes immune to the virus and doesn't infect others.

Your job is to determine how many days will pass until there are no infected on the planet.

Example:

X = 1, Y = 5, N = 1, D = 3

Day 0: 1 infected / 4 healthy / 0 recovered

Day 1: 2 infected / 3 healthy / 0 recovered

Day 2: 4 infected / 1 healthy / 0 recovered

Day 3: 4 infected / 0 healthy / 1 recovered

Day 4: 3 infected / 0 healthy / 2 recovered

Day 5: 1 infected / 0 healthy / 4 recovered

Day 6: 0 infected / 0 healthy / 5 recovered

The answer is 6 days.

Please note that some of the variables can be 0 and X will always be not greater than Y.

Algorithms
Arrays

Stats:

CreatedMay 17, 2020
PublishedMay 17, 2020
Warriors Trained193
Total Skips57
Total Code Submissions152
Total Times Completed34
C# Completions34
Total Stars4
% of votes with a positive feedback rating75% of 16
Total "Very Satisfied" Votes10
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes2
Total Rank Assessments12
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • user5075348 Avatar
  • hobovsky Avatar
Ad