Best Compromise

Question

Solution

Idea

This question is an okie question to test your ability of "Decomposition". The only thing you should notice is that the final agreement should be "generated" instead of from one of the existing input!

To "generate" the agreement, the fastest way I can think of is to get the average of each digit, and

  1. if the average < 0.5, the digit should be 0.

  2. Otherwise, it should be 1.

Here is the code snippet for this "average" part:

Code

C

https://github.com/mendax1234/Coding-Problems/blob/main/kattis/compromise/compromise.c

Last updated