Simulate Happy and Sad people over four iterations.
Unlock detailed company stats for this questionUpgrade
Starting with N Happy people and 0 Sad people, on every iteration 70% of Happy people become Sad and 50% of Sad people become Happy. Given N, print "Error!" if it is negative; otherwise print the number of happy and sad people separated by whitespace after the 4th iteration. Example: (1000,0) -> (300,700) after iteration 1 -> (90+350, 350+210) = (440,560) after iteration 2.
Format · TCS NQT advanced coding, medium question.
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
