Hello and welcome to the challenge!
Write a code which for every given integer n
returns a number s
such that:
n
equals maximum of all possible results fordigitSum(a) + digitSum(b)
a + b = n
a >= 0 and b >= 0
Example
solve(29) = 11
, because if we take15
and14
, their sum will equal29
anddigitSum = 1 + 5 + 1 + 4 = 11
, what is the maximum value
Input
n
- integer number
Output
s
- integer number
Constraints
0 < n < 10000
You can solve this programming contest in Java, JavaScript, Python, C++ and many more languages. If you want, you can also take part in other Challenges. Below you can find some of them:
Did you like this challenge and would like to try your hand at some interesting big programming competitions? Check what’s all over the news in tech world in June 2019 in our article with upcoming IT Conferences, Hackathons and Online Challenges in June 2019.
Have fun and good luck! :)