Statistics

Problem Statement for "NoZero"

Problem Statement

*** You may only submit a given problem once - no resubmissions will be accepted. ***

A no-zero number system uses only the digits 1 through 9. So counting begins with 1, the first "counting number", and continues:
  • 1,2,3,4,5,6,7,8,9,11,12,...,19,21,...,98,99,111,112,...
So, in this system 9 is the ninth counting number and 11 is the tenth counting number.

As usual, addition can be defined by reference to the counting sequence. Addition of the i-th counting number and the j-th counting number is defined to mean the (i+j)-th counting number. Thus, in this system 5 + 8 = 14, since 5 is the fifth counting number, 8 is the eighth, and 14 is the thirteenth counting number. Subtraction is the reverse of addition. Create a class NoZero that contains the method subtract that takes two no-zero numbers, big and small, and returns the no-zero value that results from calculating big - small.

Definition

Class:
NoZero
Method:
subtract
Parameters:
int, int
Returns:
int
Method signature:
int subtract(int big, int small)
(be sure your method is public)

Constraints

  • big and small do not contain the digit 0
  • big is between 1 and 999,999,999 inclusive
  • small is between 1 and 999,999,999 inclusive
  • big is greater than small

Examples

  1. 111

    99

    Returns: 1

    This big and small are adjacent in the counting sequence. So 99 + 1 = 111 and 111 - 99 = 1.

  2. 19

    11

    Returns: 8

  3. 191

    111

    Returns: 79

  4. 999999999

    1

    Returns: 999999998

  5. 9989

    1112

    Returns: 8877

  6. 11112

    9989

    Returns: 12

  7. 11

    1

    Returns: 9

  8. 999634343

    999634341

    Returns: 2

  9. 999634343

    77

    Returns: 999634255

  10. 999999927

    888888818

    Returns: 99999998

  11. 2

    1

    Returns: 1

  12. 111111111

    1

    Returns: 99999999

  13. 823987654

    123876543

    Returns: 689111111

  14. 143

    9

    Returns: 133

  15. 999

    9

    Returns: 989

  16. 11111

    9999

    Returns: 1


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: