n × n grid for studying purpose. By accident one of the laboratory technicians spills an infectious virus on some of the organism.This virus has the ability to infect the organism located immediately (east, west, north and south) of its already infected organism in 3 microseconds.
In a laboratory housed in kotebe micro-organisms were arranged in aTo mitigate the rapid spread of this deadly virus some of the grid indices were left empty. How many microseconds does it take for all the organisms to be infected for the 1 9 × 1 9 grid shown below. were 0 means infected and 1 means normal and - means empty.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Details and Assumptions
-Explicit example, If the virus was spilled on a 3 × 3 grid.
⎝ ⎛ 1 1 0 1 − 1 1 1 − ⎠ ⎞ ⟶ 3 μ s ⎝ ⎛ 1 0 0 1 − 0 1 1 − ⎠ ⎞ ⟶ 3 μ s ⎝ ⎛ 0 0 0 1 − 0 1 1 − ⎠ ⎞ ⋯ ⎝ ⎛ 0 0 0 0 − 0 0 0 − ⎠ ⎞
For a total of 15 microseconds.
The organism will quickly start infecting other organisms after being infected.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
I just counted! It's simply the minimum number of steps to get from 0 to the top right corner in this case.
Here is my solution , it's also a little lengthy. Written in javascript , so it can be tested in the browser , just hit F12 , go to console tab and paste in the code. ( Make sure to expand the log window so you can see the progression of the virus )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
Problem Loading...
Note Loading...
Set Loading...
My C++ code, pretty lengthy, but does the job: I used -3 to classify walls and 0 for infected cells with -2 for uninfected cells Temporary -1 for classifying cells infected in the nth step, later converted to 0 after the iteration.