Simulate 4 rounds of population movement between Happy and Sad cities.
Unlock detailed company stats for this questionUpgrade
Two cities: Happy and Sad. Initially Sad population = 0 and Happy population = N. Simulate 4 rounds of population movement: 70% of Happy moves to Sad, and 50% of Sad moves to Happy. If the population of any city goes below 0, output "error" instead of a number. Input: the Happy population N (integer). Output: the population of each city after 4 rounds (space-separated), or "error".
Format · TCS NQT coding section: 7 test cases (2 public, 5 hidden), full program written from scratch.
Community answers
No answers contributed by the community yet.
Related questions
Simulate Happy and Sad people over four iterations.Related courses

Course

Course
Course
