Sum Of Pairs Medium

+100 PTS

Before you start the test, check out our tutorial challenge

  • TYPE CODE PRACTICE CHALLENGE
  • LANGUAGES C++, C#, JAVA, JAVASCRIPT AND 6 MORE
    LANGUAGES C++, C#, JAVA, JAVASCRIPT, PHP, PYTHON2, PYTHON, RUBY, SWIFT, TYPESCRIPT
  • TIME ~25MIN

Sum Of Pairs

Challenge outline

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 for digitSum(a) + digitSum(b)
  • a + b = n
  • a >= 0 and b >= 0

Example

  • solve(29) = 11, because if we take 15 and 14, their sum will equal 29 and digitSum = 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 June 2019 competitions. 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! :)