I'm just getting into Empire of Code and I've come across a problem that I don't understand at all. Could someone do an ELI5 for this? I'm not sure even where to start with making the function. This is the problem:
You are given a positive number as a string along with the radix for it. Your function should convert it into decimal form. The radix is less than 37 and greater than 1. The task uses digits and the letters A-Z for the strings.
Watch out for cases when the number cannot be converted. For example: "1A" cannot be converted with radix 9. For these cases your function should return -1.
Input: Two arguments. A number as string and a radix as an integer.
Output: The converted number as an integer.
Example:
convert("AF", 16) == 175
convert("101", 2) == 5
convert("101", 5) == 26
convert("Z", 36) == 35
convert("AB", 10) == -1
What exactly is it asking? I don't know enough about number bases to have even the slightest grip on this.