diff --git a/challenges/convert-number-from-base-to-another/README.md b/challenges/convert-number-from-base-to-another/README.md new file mode 100644 index 0000000..bdc5e4d --- /dev/null +++ b/challenges/convert-number-from-base-to-another/README.md @@ -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. diff --git a/challenges/convert-number-from-base-to-another/solutions/.gitkeep b/challenges/convert-number-from-base-to-another/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/convert-number-from-base-to-another/test/1/input.txt b/challenges/convert-number-from-base-to-another/test/1/input.txt new file mode 100644 index 0000000..7c1b84e --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/1/input.txt @@ -0,0 +1,3 @@ +15 +10 +16 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/1/output.txt b/challenges/convert-number-from-base-to-another/test/1/output.txt new file mode 100644 index 0000000..c137216 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/1/output.txt @@ -0,0 +1 @@ +F \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/10/input.txt b/challenges/convert-number-from-base-to-another/test/10/input.txt new file mode 100644 index 0000000..c60f4e1 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/10/input.txt @@ -0,0 +1,3 @@ +10E +23 +8 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/10/output.txt b/challenges/convert-number-from-base-to-another/test/10/output.txt new file mode 100644 index 0000000..a17f506 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/10/output.txt @@ -0,0 +1 @@ +1037 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/2/input.txt b/challenges/convert-number-from-base-to-another/test/2/input.txt new file mode 100644 index 0000000..73b8973 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/2/input.txt @@ -0,0 +1,3 @@ +100000000 +2 +16 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/2/output.txt b/challenges/convert-number-from-base-to-another/test/2/output.txt new file mode 100644 index 0000000..105d7d9 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/2/output.txt @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/3/input.txt b/challenges/convert-number-from-base-to-another/test/3/input.txt new file mode 100644 index 0000000..a691199 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/3/input.txt @@ -0,0 +1,3 @@ +FFFFFF +16 +10 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/3/output.txt b/challenges/convert-number-from-base-to-another/test/3/output.txt new file mode 100644 index 0000000..0a48211 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/3/output.txt @@ -0,0 +1 @@ +16777215 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/4/input.txt b/challenges/convert-number-from-base-to-another/test/4/input.txt new file mode 100644 index 0000000..c75b74d --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/4/input.txt @@ -0,0 +1,3 @@ +1D57 +17 +35 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/4/output.txt b/challenges/convert-number-from-base-to-another/test/4/output.txt new file mode 100644 index 0000000..4b9d5cc --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/4/output.txt @@ -0,0 +1 @@ +75C \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/5/input.txt b/challenges/convert-number-from-base-to-another/test/5/input.txt new file mode 100644 index 0000000..7d5b6b5 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/5/input.txt @@ -0,0 +1,3 @@ +80E +20 +5 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/5/output.txt b/challenges/convert-number-from-base-to-another/test/5/output.txt new file mode 100644 index 0000000..b900ac2 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/5/output.txt @@ -0,0 +1 @@ +100324 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/6/input.txt b/challenges/convert-number-from-base-to-another/test/6/input.txt new file mode 100644 index 0000000..b6895da --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/6/input.txt @@ -0,0 +1,3 @@ +99 +10 +10 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/6/output.txt b/challenges/convert-number-from-base-to-another/test/6/output.txt new file mode 100644 index 0000000..d97edbb --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/6/output.txt @@ -0,0 +1 @@ +99 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/7/input.txt b/challenges/convert-number-from-base-to-another/test/7/input.txt new file mode 100644 index 0000000..f415bf7 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/7/input.txt @@ -0,0 +1,3 @@ +3433024 +6 +28 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/7/output.txt b/challenges/convert-number-from-base-to-another/test/7/output.txt new file mode 100644 index 0000000..052e9a5 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/7/output.txt @@ -0,0 +1 @@ +8008 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/8/input.txt b/challenges/convert-number-from-base-to-another/test/8/input.txt new file mode 100644 index 0000000..08b88ae --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/8/input.txt @@ -0,0 +1,3 @@ +30288G3A +17 +36 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/8/output.txt b/challenges/convert-number-from-base-to-another/test/8/output.txt new file mode 100644 index 0000000..9ac4f0a --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/8/output.txt @@ -0,0 +1 @@ +KF12OI \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/9/input.txt b/challenges/convert-number-from-base-to-another/test/9/input.txt new file mode 100644 index 0000000..c7c1acd --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/9/input.txt @@ -0,0 +1,3 @@ +10 +9 +9 \ No newline at end of file diff --git a/challenges/convert-number-from-base-to-another/test/9/output.txt b/challenges/convert-number-from-base-to-another/test/9/output.txt new file mode 100644 index 0000000..9a03714 --- /dev/null +++ b/challenges/convert-number-from-base-to-another/test/9/output.txt @@ -0,0 +1 @@ +10 \ No newline at end of file