index
| submit
| rank
| book

## digit-reverse – Reverse decimal digits

Write a program that reads several integers,
reverses their digits
and prints the result.
For example:

- if we reverse the digits of 720 we end up with 27;
- if we reverse the digits of 1234 we end up with 4321.

### Input and Output

Input will consist of several lines each with a number *d* where
0 ≤ *d* ≤ 1 000 000 000.
You should ignore leading zeroes on *d* if they are present.

For each line of input,
output should contain a single line
with a number *b* with the reversed digits of *d*.
Do not print leading zeroes on *b*.

Input is terminated by the end-of-file (EOF).

#### Example input

```
6
720
1234
98765
```

#### Example output

```
6
27
4321
56789
```

### The “reverse digits” function

Your program should be implemented using a “reverse digits” function
that receives one integer and
returns an integer with the reversed digits.
Please refer to the information for the chosen language:

- Python definition:
`def reverse_digits(x):`

- C prototype:
`int reverse_digits(int x);`

- Haskell type:
`reverseDigits :: Int -> Int`

- C++ prototype:
`int reverse_digits(int x);`

### Scoring

Submit your solution to be graded according to the following list:

- 1/6: works for the above example but produces output in an incorrect format
- 2/6: works for the above example and produces output in the correct format
- 4/6: works for other test cases
- 5/6: works for edge cases
- 6/6: implements the “reverse digits” function

### Hints

If you have difficulty with this exercise,
try digit-sum or digit-count first.

try first: digit-count digit-sum oddeven

try next: digit-palindrome

index
| submit
| rank
| book

Copyright © 2020-2021 Rudy Matela

All rights reserved