mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-10-29 22:17:23 +01:00
feat(challenges): add convert-number-from-base-to-another
This commit is contained in:
parent
0893aac35d
commit
42e6ade610
57
challenges/convert-number-from-base-to-another/README.md
Normal file
57
challenges/convert-number-from-base-to-another/README.md
Normal file
@ -0,0 +1,57 @@
|
||||
# convert-number-from-base-to-another
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 20 October 2021.
|
||||
|
||||
## Instructions
|
||||
|
||||
Convert a natural number (`number`) from a certain base (`base_from`) to another base (`base_target`).
|
||||
|
||||
For bases up to and including 10, we use the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.
|
||||
|
||||
For bases between 11 and 36, we use the 10 digits then the letters (capitals). For example, for base 16, the symbols used are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. For base 36, we uses the symbols 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F, G, H, I, J, K, L, M, N , O, P, Q, R, S, T, U, V, W, X, Y, Z.
|
||||
|
||||
### Input
|
||||
|
||||
- **Line 1:** The `number` to be converted (natural number)
|
||||
- **Line 2:** The base of the number `base_from`
|
||||
- **Line 3:** The base to convert to `base_target`
|
||||
|
||||
### Output
|
||||
|
||||
The converted number.
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1
|
||||
|
||||
#### Input
|
||||
|
||||
```txt
|
||||
15
|
||||
10
|
||||
16
|
||||
```
|
||||
|
||||
#### Output
|
||||
|
||||
```txt
|
||||
F
|
||||
```
|
||||
|
||||
### Example 2
|
||||
|
||||
#### Input
|
||||
|
||||
```txt
|
||||
100000000
|
||||
2
|
||||
16
|
||||
```
|
||||
|
||||
#### Output
|
||||
|
||||
```txt
|
||||
100
|
||||
```
|
||||
|
||||
See the `test` folder for examples of input/output.
|
@ -0,0 +1,3 @@
|
||||
15
|
||||
10
|
||||
16
|
@ -0,0 +1 @@
|
||||
F
|
@ -0,0 +1,3 @@
|
||||
10E
|
||||
23
|
||||
8
|
@ -0,0 +1 @@
|
||||
1037
|
@ -0,0 +1,3 @@
|
||||
100000000
|
||||
2
|
||||
16
|
@ -0,0 +1 @@
|
||||
100
|
@ -0,0 +1,3 @@
|
||||
FFFFFF
|
||||
16
|
||||
10
|
@ -0,0 +1 @@
|
||||
16777215
|
@ -0,0 +1,3 @@
|
||||
1D57
|
||||
17
|
||||
35
|
@ -0,0 +1 @@
|
||||
75C
|
@ -0,0 +1,3 @@
|
||||
80E
|
||||
20
|
||||
5
|
@ -0,0 +1 @@
|
||||
100324
|
@ -0,0 +1,3 @@
|
||||
99
|
||||
10
|
||||
10
|
@ -0,0 +1 @@
|
||||
99
|
@ -0,0 +1,3 @@
|
||||
3433024
|
||||
6
|
||||
28
|
@ -0,0 +1 @@
|
||||
8008
|
@ -0,0 +1,3 @@
|
||||
30288G3A
|
||||
17
|
||||
36
|
@ -0,0 +1 @@
|
||||
KF12OI
|
@ -0,0 +1,3 @@
|
||||
10
|
||||
9
|
||||
9
|
@ -0,0 +1 @@
|
||||
10
|
Loading…
Reference in New Issue
Block a user