Hex String to Decimal
The string s is a number in hexadecimal: each character is a digit 0 to 9 or a lowercase letter a to f (worth 10 to 15). Return its value as an integer. Do not use int(s, 16).
Example 1
s "ff"
returns 255
15*16 + 15 = 255.
Example 2
s "1a"
returns 26
16 + 10 = 26.
Constraints
1 <= len(s) <= 6
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Highest Power of TwoBeginner
- Is PrimeBeginner
- Lattice Points in a CircleBeginner
- Leap YearBeginner
- Matches in a TournamentBeginner
- Number of Common FactorsBeginner
- Power of FourBeginner
- Power of ThreeBeginner