Combining the egg counts
Statement
A poultry farm gathers eggs every morning. Two workers each carry one basket around the henhouse and put the eggs they find into their own basket. Let A be the number of eggs the first worker collects, and let B be the number of eggs the second worker collects.
Once both workers have been all the way round the henhouse, they bring their baskets to the storeroom. There the eggs from both baskets are taken out and moved into a single box. No egg breaks or falls out while they are moved. The box is also large enough to hold the eggs from both baskets. So the number of eggs in the box is the sum of the numbers that were in the two baskets.
Write a program that prints the number of eggs in the box when the numbers of eggs in the two baskets are given.
For example, suppose the numbers of eggs the two workers gathered are as in the following table.
| Basket | First worker | Second worker |
|---|---|---|
| Eggs | 1 | 2 |
The first worker's basket holds 1 egg, and the second worker's basket holds 2. The storeroom keeper sets down an empty box and empties the two baskets into it in order. The following table shows how the number of eggs in the box grows along the way.
| Step | Eggs in the box |
|---|---|
| After the empty box is set down | 0 |
| After the first basket is emptied | 1 |
| After the second basket is emptied | 3 |
Once both baskets have been emptied, the box holds 3 eggs, which is 1 plus 2. So the answer in this case is 3.
Putting the results for other days into one table gives the following.
| First worker | Second worker | Eggs in the box |
|---|---|---|
| 1 | 2 | 3 |
| 9 | 9 | 18 |
| 4 | 2 | 6 |
Which of the two baskets holds more does not matter. There can also be a day when the two workers gather the same number.
Input and output examples
Example 1
Input
1 2
Output
3
Example 2
Input
9 9
Output
18
Example 3
Input
4 2
Output
6
Input
First the numbers of eggs the two workers gathered, A and B, are given on the first line, in that order, separated by one space. A is the number of eggs in the first worker's basket, and B is the number of eggs in the second worker's basket. A and B are each natural numbers from 1 to 9. The two numbers can be equal, and there is no condition on which one is larger. This one line is the only line of input, and the space between the two numbers is a single space. Values such as the date of the collection or the names of the workers are not given.
Output
Print the number of eggs in the box on the first line, as a natural number. Print the single number and then break the line, and do not attach a space after the number. Do not write a unit, print only the number.
Requirements
- The input is one line, and it holds two numbers separated by one space
- A and B are each natural numbers from 1 to 9
- The two numbers can be equal
- The answer is a single number and it is printed on one line
- You must write a program that reads from standard input and writes to standard output
- Trailing spaces at the end of a line and blank lines at the end of the output are ignored when grading
- The languages you can use are Python and JavaScript
- The memory limit is 256MB. The browser does not measure it, it only states it
- The time limit is set by measuring the setter's reference solution on the same runtime
- On this problem you submit code, not a prompt. That code runs in the browser on this device, and all that goes to the server is a fingerprint of the output and the time it took. Whether it is correct is decided by the server. The run time is a number each device reports, so the code and the device details are posted next to it on the leaderboard.
- The output has to match the expected value down to the character. A space inside a line counts the same as any other character.
- There are 15 cases, and 3 of them show the input together with the expected output. The rest are used only when you submit and are not shown on this page.
- You have to pass all 15 cases to solve this.
Examples
3 public cases. Judging also uses hidden cases. You have to pass all 15 cases to solve this.
1 2
3
9 9
18
4 2
6
Solution
Your code runs on this device. Only the fingerprint of the output and the elapsed time go to the server. The server decides whether it is correct.
Submitting requires you to log in. Running against the public cases works without one.
You can test with 3 public cases. Submitting runs the hidden cases too.
People who solved this problem
Nobody yet. You could be the first.