-3
In the board game Pandemic, an outbreak occurs when a city contains more than 3 disease cubes. When the outbreak occurs, any disease cubes in the city in excess of 3 are removed, and each city connected to it gains one disease cube. This means that chain reactions can, and will occur.
Important note: Each city may only outbreak once in each chain reaction.
Input
A list of cities each containing:
- An integer representing the number of disease cubes .
- And a number of identifiers of the form (A, B ... AA, AB) (lowercase is allowed) representing which cites in list order it is connected to.
Output
A list of integers representing the number of disease cubes in each city after outbreaks have been resolved.
Winning Condition
This is code-golf, so the shortest code in bytes wins.
6Could you add test cases? – HyperNeutrino – 2019-06-13T16:10:35.573
I think it's clear enough. – Who – 2019-06-13T16:12:37.630
Are city edges bidirectional? Is it strictly greater than (that is, a pandemic starts upon a city gaining its fourth cube)? – HyperNeutrino – 2019-06-13T16:12:40.090
3The point isn't that it's clear enough (which it isn't); test cases are to test people's solutions otherwise it's very inconvenient to verify that one's solution is valid. – HyperNeutrino – 2019-06-13T16:13:04.873
it would take time – Who – 2019-06-13T16:13:33.807
and yes to both of those questions – Who – 2019-06-13T16:14:00.793
Let us continue this discussion in chat.
– HyperNeutrino – 2019-06-13T16:14:11.073A list of integers
is a string of integers separated by something other than a digit (whitespace, newline, etc.) ok? – Benjamin Urquhart – 2019-06-13T16:18:05.397